From 3d046e9a94b84fd7c651867a9bc73516791f4689 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 9 Jun 2010 12:07:32 -0400 Subject: [PATCH] ./test takes a --filter option to filter out certain tests --- dbtests/framework.cpp | 23 +++++++++++++++++------ dbtests/framework.h | 4 ++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dbtests/framework.cpp b/dbtests/framework.cpp index f0b8bc2b72d..e6242114ac1 100644 --- a/dbtests/framework.cpp +++ b/dbtests/framework.cpp @@ -77,7 +77,7 @@ namespace mongo { Result * Result::cur = 0; - Result * Suite::run(){ + Result * Suite::run( const string& filter ){ tlogLevel = -1; log(1) << "\t about to setupTests" << endl; @@ -92,9 +92,13 @@ namespace mongo { for ( list::iterator i=_tests.begin(); i!=_tests.end(); i++ ){ TestCase * tc = *i; + if ( filter.size() && tc->getName().find( filter ) == string::npos ){ + log(1) << "\t skipping test: " << tc->getName() << " because doesn't match filter" << endl; + continue; + } r->_tests++; - + bool passes = false; log(1) << "\t going to run test: " << tc->getName() << endl; @@ -157,10 +161,11 @@ namespace mongo { "directory will be overwritten if it already exists") ("debug", "run tests with verbose output") ("list,l", "list available test suites") + ("filter,f" , po::value() , "string substring filter on test name" ) ("verbose,v", "verbose") ("seed", po::value(&seed), "random number seed") ; - + hidden_options.add_options() ("suites", po::value< vector >(), "test suites to run") ; @@ -239,7 +244,13 @@ namespace mongo { if (params.count("suites")) { suites = params["suites"].as< vector >(); } - int ret = run(suites); + + string filter = ""; + if ( params.count( "filter" ) ){ + filter = params["filter"].as(); + } + + int ret = run(suites,filter); #if !defined(_WIN32) && !defined(__sunos__) flock( lockFile, LOCK_UN ); @@ -250,7 +261,7 @@ namespace mongo { return ret; } - int Suite::run( vector suites ){ + int Suite::run( vector suites , const string& filter ){ for ( unsigned int i = 0; i < suites.size(); i++ ) { if ( _suites->find( suites[i] ) == _suites->end() ) { cout << "invalid test [" << suites[i] << "], use --list to see valid names" << endl; @@ -272,7 +283,7 @@ namespace mongo { assert( s ); log() << "going to run suite: " << name << endl; - results.push_back( s->run() ); + results.push_back( s->run( filter ) ); } Logstream::get().flush(); diff --git a/dbtests/framework.h b/dbtests/framework.h index a21d6cc2866..bec14a2f28d 100644 --- a/dbtests/framework.h +++ b/dbtests/framework.h @@ -112,9 +112,9 @@ namespace mongo { _tests.push_back( new TestHolder1(a) ); } - Result * run(); + Result * run( const string& filter ); - static int run( vector suites ); + static int run( vector suites , const string& filter ); static int run( int argc , char ** argv , string default_dbpath );