diff options
-rw-r--r-- | cpp/001test | 56 | ||||
-rw-r--r-- | cpp/010vm | 2 | ||||
-rw-r--r-- | cpp/050scenario | 1 |
3 files changed, 37 insertions, 22 deletions
diff --git a/cpp/001test b/cpp/001test index 2319348b..38e5a2b6 100644 --- a/cpp/001test +++ b/cpp/001test @@ -38,30 +38,40 @@ long Num_failures = 0; } :(before "End Main") -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'; +if (argc <= 1 || is_equal(argv[1], "--help")) { + // need some way to distribute this across layers + cerr << "To load files and run 'main': mu file1.mu file2.mu ...\n" + << "To run all core tests: mu test\n" + << "To load files and run tests defined in them: mu test file1.mu file2.mu ...\n" + << "To run just some C++ tests in `test_list` file: mu test n1 n2 ...\n" + << " (look up n1 n2 ... by running `grep -n` on test_list`)\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") && is_number(argv[2])) { - assert(Next_recipe_number < 1000); // see vm layer - for (int i = 2; i < argc; ++i) { - run_test(to_int(argv[i])-1); +if (argc > 1 && is_equal(argv[1], "test")) { + // End Test Run Initialization + if (argc == 2) { + run_tests(); + cerr << '\n'; + if (Num_failures > 0) + cerr << Num_failures << " failure" + << (Num_failures > 1 ? "s" : "") + << '\n'; + return 0; + } + if (is_number(argv[2])) { + // all args are line numbers in test_file specifying tests to run + run_tests(argc, argv); + cerr << '\n'; + if (Num_failures > 0) + cerr << Num_failures << " failure" + << (Num_failures > 1 ? "s" : "") + << '\n'; + return 0; } - cerr << '\n'; - if (Num_failures > 0) - cerr << Num_failures << " failure" - << (Num_failures > 1 ? "s" : "") - << '\n'; - return 0; -} -// End Test Runs + // End Test Runs +} :(code) void run_tests() { @@ -73,6 +83,12 @@ void run_tests() { // End Tests } +void run_tests(int argc, char* argv[]) { + for (int i = 2; i < argc; ++i) { + run_test(to_int(argv[i])-1); + } +} + void run_test(size_t i) { if (i >= sizeof(Tests)/sizeof(Tests[0])) { cerr << "no test " << i << '\n'; diff --git a/cpp/010vm b/cpp/010vm index 0dbafc03..92e712d3 100644 --- a/cpp/010vm +++ b/cpp/010vm @@ -153,7 +153,7 @@ assert(MAX_PRIMITIVE_RECIPES < 100); // level 0 is primitives; until 99 Next_recipe_number = 100; // End Load Recipes delete Trace_stream; Trace_stream = new trace_stream; -:(after "void run_tests()") +:(before "End Test Run Initialization") assert(Next_recipe_number < 1000); // functions being tested didn't overflow into test space :(before "End Setup") Next_recipe_number = 1000; // consistent new numbers for each test diff --git a/cpp/050scenario b/cpp/050scenario index 1dfc36bf..c863b1b4 100644 --- a/cpp/050scenario +++ b/cpp/050scenario @@ -21,7 +21,6 @@ run_mu_tests(); :(code) void run_mu_tests() { - assert(Next_recipe_number < 1000); // don't load into test space for (size_t i = 0; i < Scenarios.size(); ++i) { setup(); Trace_file = Scenarios[i].name; |