diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-07-09 13:55:32 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-07-09 13:55:32 -0700 |
commit | 6ff9413c5dc624df6a33d7680a6667c27cd9352e (patch) | |
tree | 3282068e32eb5605b5d79029aa4eb6a3260d4a53 | |
parent | 9e32e4736dc12479e3855e8d29ba7ecb6ac50ff6 (diff) | |
download | mu-6ff9413c5dc624df6a33d7680a6667c27cd9352e.tar.gz |
3964 - eliminate one global from the test harness
I'm in the process of making it more self-contained so I can use it in another project.
-rw-r--r-- | 002test.cc | 12 | ||||
-rw-r--r-- | 050scenario.cc | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/002test.cc b/002test.cc index 1d8efb08..1f89b05c 100644 --- a/002test.cc +++ b/002test.cc @@ -19,7 +19,6 @@ const test_fn Tests[] = { :(before "End Globals") bool Run_tests = false; bool Passed = true; // set this to false inside any test to indicate failure -long Num_failures = 0; :(before "End Includes") #define CHECK(X) \ @@ -50,18 +49,21 @@ if (Run_tests) { // Test Runs // we run some tests and then exit; assume no state need be maintained afterward + long num_failures = 0; // End Test Run Initialization time_t t; time(&t); cerr << "C tests: " << ctime(&t); for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { //? cerr << "running .build/test_list line " << (i+1) << '\n'; run_test(i); + if (Passed) cerr << '.'; + else ++num_failures; } cerr << '\n'; // End Tests - if (Num_failures > 0) { - cerr << Num_failures << " failure" - << (Num_failures > 1 ? "s" : "") + if (num_failures > 0) { + cerr << num_failures << " failure" + << (num_failures > 1 ? "s" : "") << '\n'; return 1; } @@ -79,8 +81,6 @@ void run_test(size_t i) { (*Tests[i])(); // End Test Teardown teardown(); - if (Passed) cerr << '.'; - else ++Num_failures; } bool is_integer(const string& s) { diff --git a/050scenario.cc b/050scenario.cc index 9b6182bc..375da6cb 100644 --- a/050scenario.cc +++ b/050scenario.cc @@ -163,7 +163,7 @@ if (Num_core_mu_scenarios > 0) { //? cerr << '\n' << i << ": " << Scenarios.at(i).name; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; - else ++Num_failures; + else ++num_failures; } cerr << "\n"; } @@ -175,7 +175,7 @@ if (Num_core_mu_scenarios != SIZE(Scenarios)) { //? cerr << '\n' << i << ": " << Scenarios.at(i).name; run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; - else ++Num_failures; + else ++num_failures; } cerr << "\n"; } |