diff --git a/dbtests/dbtests.cpp b/dbtests/dbtests.cpp index 4ce568510ea..3069ad21b31 100644 --- a/dbtests/dbtests.cpp +++ b/dbtests/dbtests.cpp @@ -22,5 +22,5 @@ #include "dbtests.h" int main( int argc, char** argv ) { - return Suite::run(argc, argv, "/tmp/unittest/"); + return Suite::run(argc, argv, "/tmp/unittest"); } diff --git a/dbtests/framework.cpp b/dbtests/framework.cpp index 7b35921de07..05f3719d978 100644 --- a/dbtests/framework.cpp +++ b/dbtests/framework.cpp @@ -162,17 +162,22 @@ namespace mongo { boost::filesystem::path p(dbpathSpec); - /* try removing and recreating the directory - * - * we let this fail because some of the test machines have - * special setups for /tmp/unittest/ which we don't want - * to destroy. */ - try { - if (boost::filesystem::exists(p)) { - boost::filesystem::remove_all(p); + /* remove the contents of the test directory if it exists. */ + if (boost::filesystem::exists(p)) { + /* TODO maybe should check for symlinks to regular files too */ + if (boost::filesystem::is_regular_file(p)) { + cout << "ERROR: path \"" << p << "\" is not a directory" << endl << endl; + show_help_text(argv[0], shell_options); + return EXIT_BADOPTIONS; } + boost::filesystem::directory_iterator end_iter; + for (boost::filesystem::directory_iterator dir_iter(p); + dir_iter != end_iter; ++dir_iter) { + boost::filesystem::remove_all(dir_iter->path()); + } + } else { boost::filesystem::create_directory(p); - } catch (std::runtime_error &e) {} + } string dbpathString = p.native_directory_string(); dbpath = dbpathString.c_str(); diff --git a/dbtests/perf/perftest.cpp b/dbtests/perf/perftest.cpp index dc2fe358cdc..6fe9d6aacfb 100644 --- a/dbtests/perf/perftest.cpp +++ b/dbtests/perf/perftest.cpp @@ -691,5 +691,5 @@ int main( int argc, char **argv ) { logLevel = -1; client_ = new DBDirectClient(); - return Suite::run(argc, argv, "/data/db/perftest/"); + return Suite::run(argc, argv, "/data/db/perftest"); }