diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 09:08:09 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-03-17 09:08:09 -0700 |
commit | eb3a527a254731929cc45e90dcbc8d6477a99054 (patch) | |
tree | 1b72d9be9117903eee6f0cab86bdefd2f23b3f58 /cpp | |
parent | b1bbe92da37dd44df458ffa122e052612bb9eff3 (diff) | |
download | mu-eb3a527a254731929cc45e90dcbc8d6477a99054.tar.gz |
946 - selectively run just some tests
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/001test | 46 | ||||
-rw-r--r-- | cpp/010vm | 7 |
2 files changed, 34 insertions, 19 deletions
diff --git a/cpp/001test b/cpp/001test index 32014689..f0cb2c15 100644 --- a/cpp/001test +++ b/cpp/001test @@ -40,8 +40,25 @@ long Num_failures = 0; } :(before "End Main") -if (argc > 1 && is_equal(argv[1], "test")) { +if (argc == 2 && is_equal(argv[1], "test")) { run_tests(); + cerr << '\n'; + if (Num_failures > 0) + cerr << Num_failures << " failure" + << (Num_failures > 1 ? "s" : "") + << '\n'; + return 0; +} +// pass in a set of line numbers in test_file to run just those tests +if (argc > 2 && is_equal(argv[1], "test")) { + for (int i = 2; i < argc; ++i) { + run_test(to_int(argv[i])-1); + } + cerr << '\n'; + if (Num_failures > 0) + cerr << Num_failures << " failure" + << (Num_failures > 1 ? "s" : "") + << '\n'; return 0; } @@ -50,25 +67,30 @@ void run_tests() { time_t t; time(&t); cerr << "C tests: " << ctime(&t); for (unsigned long i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { - setup(); - // End Test Setup - (*Tests[i])(); - if (Passed) cerr << "."; - // Test Teardown - // End Test Teardown + run_test(i); } +} - cerr << '\n'; - if (Num_failures > 0) - cerr << Num_failures << " failure" - << (Num_failures > 1 ? "s" : "") - << '\n'; +void run_test(int i) { + setup(); + // End Test Setup + (*Tests[i])(); + if (Passed) cerr << "."; + // Test Teardown + // End Test Teardown } bool is_equal(char* s, const char* lit) { return strncmp(s, lit, strlen(lit)) == 0; } +int to_int(string n) { + char* end = NULL; + int result = strtol(n.c_str(), &end, /*any base*/0); + assert(*end == '\0'); + return result; +} + :(before "End Includes") #include<iostream> using std::istream; diff --git a/cpp/010vm b/cpp/010vm index 870df1e4..049630d3 100644 --- a/cpp/010vm +++ b/cpp/010vm @@ -201,10 +201,3 @@ void dump_memory() { cout << p->first << ": " << p->second << '\n'; } } - -int to_int(string n) { - char* end = NULL; - int result = strtol(n.c_str(), &end, /*any base*/0); - assert(*end == '\0'); - return result; -} |