about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-11-15 21:55:56 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-11-15 22:22:11 -0800
commit4cec4143d3f35be3f4379e00cc4fea357ef2a349 (patch)
treec067f33b8193344993dd45d495be4e22951a1bc0
parent293732951a2052dd079c253942922eab6c1a734d (diff)
downloadmu-4cec4143d3f35be3f4379e00cc4fea357ef2a349.tar.gz
3675
-rw-r--r--003trace.cc12
-rw-r--r--020run.cc4
-rw-r--r--030container.cc4
-rw-r--r--050scenario.cc4
-rw-r--r--052tangle.cc4
5 files changed, 16 insertions, 12 deletions
diff --git a/003trace.cc b/003trace.cc
index aa519eb1..d75596eb 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -183,9 +183,13 @@ int Trace_errors = 0;  // used only when Trace_stream is NULL
 // Inside tests, fail any tests that displayed (unexpected) errors.
 // Expected errors in tests should always be hidden and silently checked for.
 :(before "End Test Teardown")
-if (Passed && !Hide_errors && trace_count("error") > 0) {
+if (Passed && !Hide_errors && trace_contains_errors()) {
   Passed = false;
 }
+:(code)
+bool trace_contains_errors() {
+  return Trace_errors > 0 || trace_count("error") > 0;
+}
 
 :(before "End Types")
 struct end {};
@@ -223,9 +227,9 @@ START_TRACING_UNTIL_END_OF_SCOPE
 :(before "End Includes")
 #define CHECK_TRACE_CONTENTS(...)  check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 
-#define CHECK_TRACE_CONTAINS_ERROR()  CHECK(trace_count("error") > 0)
-#define CHECK_TRACE_DOESNT_CONTAIN_ERROR() \
-  if (Passed && trace_count("error") > 0) { \
+#define CHECK_TRACE_CONTAINS_ERRORS()  CHECK(trace_contains_errors())
+#define CHECK_TRACE_DOESNT_CONTAIN_ERRORS() \
+  if (Passed && trace_contains_errors()) { \
     cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
     DUMP("error"); \
     Passed = false; \
diff --git a/020run.cc b/020run.cc
index a6b6e4e0..ed594210 100644
--- a/020run.cc
+++ b/020run.cc
@@ -177,7 +177,7 @@ if (argc > 1) {
 transform_all();
 //? DUMP("");
 //? exit(0);
-if (Trace_errors) return 1;
+if (trace_contains_errors()) return 1;
 save_snapshots();
 
 //: Step 3: if we aren't running tests, locate a recipe called 'main' and
@@ -374,7 +374,7 @@ void run(const string& form) {
   vector<recipe_ordinal> tmp = load(form);
   transform_all();
   if (tmp.empty()) return;
-  if (trace_count("error") > 0) return;
+  if (trace_contains_errors()) return;
   // if a test defines main, it probably wants to start there regardless of
   // definition order
   if (contains_key(Recipe, get(Recipe_ordinal, "main")))
diff --git a/030container.cc b/030container.cc
index 9db8344d..3e09fec5 100644
--- a/030container.cc
+++ b/030container.cc
@@ -779,12 +779,12 @@ void test_error_on_transform_all_between_container_definition_and_extension() {
       "]\n");
   // try to extend the container after transform
   transform_all();
-  CHECK_TRACE_DOESNT_CONTAIN_ERROR();
+  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
   Hide_errors = true;
   run("container foo [\n"
       "  b:num\n"
       "]\n");
-  CHECK_TRACE_CONTAINS_ERROR();
+  CHECK_TRACE_CONTAINS_ERRORS();
 }
 
 //:: Allow container definitions anywhere in the codebase, but complain if you
diff --git a/050scenario.cc b/050scenario.cc
index a9617df3..8f8d2d8f 100644
--- a/050scenario.cc
+++ b/050scenario.cc
@@ -190,7 +190,7 @@ void run_mu_scenario(const scenario& s) {
   transform_all();
   run(tmp.front());
   // End Mu Test Teardown
-  if (!Hide_errors && trace_count("error") > 0 && !Scenario_testing_scenario)
+  if (!Hide_errors && trace_contains_errors() && !Scenario_testing_scenario)
     Passed = false;
   if (not_already_inside_test && Trace_stream) {
     teardown();
@@ -242,7 +242,7 @@ void test_maybe_make_raw() {
   bind_special_scenario_names(tmp.at(0));
   transform_all();
   run(tmp.at(0));
-  CHECK_EQ(trace_count("error"), 0);
+  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
 }
 
 //: Watch out for redefinitions of scenario routines. We should never ever be
diff --git a/052tangle.cc b/052tangle.cc
index f53e8736..2136a60d 100644
--- a/052tangle.cc
+++ b/052tangle.cc
@@ -452,13 +452,13 @@ void test_new_fragment_after_tangle() {
        "  1:num/raw <- copy 34\n"
        "]\n");
   transform_all();
-  CHECK_TRACE_DOESNT_CONTAIN_ERROR();
+  CHECK_TRACE_DOESNT_CONTAIN_ERRORS();
   Hide_errors = true;
   // try to tangle into recipe foo after transform
   load("before <label> [\n"
        "  2:num/raw <- copy 35\n"
        "]\n");
-  CHECK_TRACE_CONTAINS_ERROR();
+  CHECK_TRACE_CONTAINS_ERRORS();
 }
 
 :(before "End before Command Handler")