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 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/stable/unitsuite.cpp') 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 ) -- cgit v1.2.3