From da1de5cdb5c42ce811a66d377789e585042b98c7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 14 Apr 2012 18:04:52 +0000 Subject: Added support for running subsets of unit tests to Bu::UnitSuite, now just list the names of the tests you want to run on the command line. Also, fixed some minor issues in two of the test suites. --- src/stable/unitsuite.cpp | 20 +++++++++++++++++++- src/stable/unitsuite.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/stable') diff --git a/src/stable/unitsuite.cpp b/src/stable/unitsuite.cpp index db930a4..e508c6f 100644 --- a/src/stable/unitsuite.cpp +++ b/src/stable/unitsuite.cpp @@ -32,7 +32,6 @@ Bu::UnitSuite::~UnitSuite() { } -// Argument handling is coming soon, I promise. int Bu::UnitSuite::run( int argc, char *argv[] ) { bool bCleanup = true; @@ -41,9 +40,22 @@ int Bu::UnitSuite::run( int argc, char *argv[] ) "List available test cases." ); p.addOption( bCleanup, "no-cleanup", "Don't erase temp files."); p.setOverride( "no-cleanup", false ); + p.setNonOption( Bu::slot( this, &Bu::UnitSuite::onAddTest ) ); p.addHelpOption(); p.parse( argc, argv ); + if( !hSelTests.isEmpty() ) + { + TestList lSub; + for( TestList::iterator i = lTests.begin(); i != lTests.end(); i++ ) + { + if( hSelTests.has( (*i).sName ) ) + lSub.append( *i ); + } + + lTests = lSub; + } + int iEPass = 0; int iEFail = 0; int iUPass = 0; @@ -239,6 +251,12 @@ int Bu::UnitSuite::onListCases( StrArray ) return 0; } +int Bu::UnitSuite::onAddTest( StrArray aParam ) +{ + hSelTests.insert( aParam[0], true ); + return 0; +} + Bu::Formatter &Bu::operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e ) { switch( e ) diff --git a/src/stable/unitsuite.h b/src/stable/unitsuite.h index 2250a4d..6915fb4 100644 --- a/src/stable/unitsuite.h +++ b/src/stable/unitsuite.h @@ -13,6 +13,7 @@ #include "bu/string.h" #include "bu/file.h" #include "bu/array.h" +#include "bu/hash.h" namespace Bu { @@ -103,6 +104,7 @@ namespace Bu private: int onListCases( Bu::Array aParam ); + int onAddTest( Bu::Array aParam ); private: typedef struct TestInfo @@ -124,6 +126,8 @@ namespace Bu int iStepCount; int iProgress; time_t tLastUpdate; + + Bu::Hash hSelTests; }; Bu::Formatter &operator<<( Bu::Formatter &f, const Bu::UnitSuite::Expect &e ); -- cgit v1.2.3