about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-01-19 20:53:00 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-01-19 20:53:18 -0800
commit7163e18a774781c62f0c0542e4cb9037f6a71d22 (patch)
tree6cb88378652a2124ce701d8d96428fbc8fb8f552
parentff9d5f43cfcc18e853de8d92ade1f962961fa516 (diff)
downloadmu-7163e18a774781c62f0c0542e4cb9037f6a71d22.tar.gz
2575 - better messages on trace count failures
-rw-r--r--003trace.cc10
-rw-r--r--tangle/030tangle.cc2
-rw-r--r--tangle/030tangle.test.cc4
3 files changed, 13 insertions, 3 deletions
diff --git a/003trace.cc b/003trace.cc
index 5b48f1c4..4b254919 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -272,6 +272,16 @@ int trace_count(string label, string line) {
     return; \
   }
 
+#define CHECK_TRACE_COUNT(label, count) \
+  if (trace_count(label) != (count)) { \
+    ++Num_failures; \
+    cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
+    cerr << "  got " << trace_count(label) << '\n';  /* multiple eval */ \
+    DUMP(label); \
+    Passed = false; \
+    return;  /* Currently we stop at the very first failure. */ \
+  }
+
 bool trace_doesnt_contain(string label, string line) {
   return trace_count(label, line) == 0;
 }
diff --git a/tangle/030tangle.cc b/tangle/030tangle.cc
index 618d7fa1..c4a3db5f 100644
--- a/tangle/030tangle.cc
+++ b/tangle/030tangle.cc
@@ -318,7 +318,7 @@ void emit_test(const string& name, list<Line>& lines, list<Line>& result) {
       size_t pos = in.find(": ");
       string layer = in.substr(1, pos-1);
       string count = in.substr(pos+2);
-      result.push_back(Line("  CHECK_EQ(trace_count(\""+layer+"\"), "+count+");", front(lines)));
+      result.push_back(Line("  CHECK_TRACE_COUNT(\""+layer+"\", "+count+");", front(lines)));
       lines.pop_front();
     }
     if (!lines.empty() && front(lines).contents == "===") {
diff --git a/tangle/030tangle.test.cc b/tangle/030tangle.test.cc
index d44a408a..7a329803 100644
--- a/tangle/030tangle.test.cc
+++ b/tangle/030tangle.test.cc
@@ -321,7 +321,7 @@ void test_tangle_can_check_for_count_in_scenario() {
   CHECK_EQ(lines.front().contents, "void test_does_bar() {");  lines.pop_front();
   CHECK_EQ(lines.front().contents, "  Trace_file = \"does_bar\";"); lines.pop_front();
   CHECK_EQ(lines.front().contents, "  run(\"abc def\\n  efg\\n\");");  lines.pop_front();
-  CHECK_EQ(lines.front().contents, "  CHECK_EQ(trace_count(\"layer1\"), 2);");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "  CHECK_TRACE_COUNT(\"layer1\", 2);");  lines.pop_front();
   CHECK_EQ(lines.front().contents, "}");  lines.pop_front();
   CHECK(lines.empty());
 }
@@ -335,7 +335,7 @@ void test_tangle_can_handle_mu_comments_in_scenario() {
   CHECK_EQ(lines.front().contents, "  run(\"abc def\\n# comment1\\n  efg\\n  # indented comment 2\\n\");");  lines.pop_front();
   CHECK_EQ(lines.front().contents, "  CHECK_TRACE_CONTENTS(\"layer1: pqrlayer1: xyz\");");  lines.pop_front();
   CHECK_EQ(lines.front().contents, "  CHECK_TRACE_DOESNT_CONTAIN(\"layer1: z\");");  lines.pop_front();
-  CHECK_EQ(lines.front().contents, "  CHECK_EQ(trace_count(\"layer1\"), 2);");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "  CHECK_TRACE_COUNT(\"layer1\", 2);");  lines.pop_front();
   CHECK_EQ(lines.front().contents, "}");  lines.pop_front();
   CHECK(lines.empty());
 }