about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--003trace.cc31
-rw-r--r--003trace.test.cc51
2 files changed, 15 insertions, 67 deletions
diff --git a/003trace.cc b/003trace.cc
index 8b48d0ef..4b6c0141 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -184,6 +184,8 @@ struct lease_tracer {
 START_TRACING_UNTIL_END_OF_SCOPE
 //? Trace_stream->dump_layer = "all"; //? 1
 
+#define CHECK_TRACE_CONTENTS(...)  check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
+
 :(before "End Tracing")
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {  // missing layer == anywhere
   vector<string> expected_lines = split(expected, "");
@@ -195,7 +197,7 @@ bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expecte
   string layer, contents;
   split_layer_contents(expected_lines.at(curr_expected_line), &layer, &contents);
   for (vector<pair<string, string> >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
-    if (!layer.empty() && layer != p->first)
+    if (layer != p->first)
       continue;
 
     if (contents != p->second)
@@ -230,33 +232,6 @@ void split_layer_contents(const string& s, string* layer, string* contents) {
 
 
 
-bool check_trace_contents(string FUNCTION, string FILE, int LINE, string layer, string expected) {  // empty layer == everything
-  vector<string> expected_lines = split(expected, "");
-  long long int curr_expected_line = 0;
-  while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty())
-    ++curr_expected_line;
-  if (curr_expected_line == SIZE(expected_lines)) return true;
-  Trace_stream->newline();
-  for (vector<pair<string, string> >::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
-    if (!layer.empty() && layer != p->first)
-      continue;
-    if (p->second != expected_lines.at(curr_expected_line))
-      continue;
-    ++curr_expected_line;
-    while (curr_expected_line < SIZE(expected_lines) && expected_lines.at(curr_expected_line).empty())
-      ++curr_expected_line;
-    if (curr_expected_line == SIZE(expected_lines)) return true;
-  }
-
-  ++Num_failures;
-  cerr << "\nF - " << FUNCTION << "(" << FILE << ":" << LINE << "): missing [" << expected_lines.at(curr_expected_line) << "] in trace:\n";
-  DUMP(layer);
-  Passed = false;
-  return false;
-}
-
-#define CHECK_TRACE_CONTENTS(...)  check_trace_contents(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
-
 int trace_count(string layer) {
   return trace_count(layer, "");
 }
diff --git a/003trace.test.cc b/003trace.test.cc
index 2389b810..419fc5e4 100644
--- a/003trace.test.cc
+++ b/003trace.test.cc
@@ -1,64 +1,37 @@
 void test_trace_check_compares() {
-  CHECK_TRACE_CONTENTS("test layer", "");
   trace("test layer") << "foo";
-  CHECK_TRACE_CONTENTS("test layer", "foo");
+  CHECK_TRACE_CONTENTS("test layer: foo");
 }
 
-void test_trace_check_filters_layers() {
+void test_trace_check_ignores_other_layers() {
   trace("test layer 1") << "foo";
   trace("test layer 2") << "bar";
-  CHECK_TRACE_CONTENTS("test layer 1", "foo");
+  CHECK_TRACE_CONTENTS("test layer 1: foo");
+  CHECK_TRACE_DOESNT_CONTAIN("test layer 2: foo");
 }
 
 void test_trace_check_ignores_other_lines() {
   trace("test layer 1") << "foo";
   trace("test layer 1") << "bar";
-  CHECK_TRACE_CONTENTS("test layer 1", "foo");
+  CHECK_TRACE_CONTENTS("test layer 1: foo");
 }
 
-void test_trace_ignores_trailing_whitespace() {
-  trace("test layer 1") << "foo\n";
-  CHECK_TRACE_CONTENTS("test layer 1", "foo");
-}
-
-void test_trace_check_always_finds_empty_lines() {
-  CHECK_TRACE_CONTENTS("test layer 1", "");
-}
-
-void test_trace_check_treats_empty_layers_as_wildcards() {
+void test_trace_check_ignores_other_lines2() {
   trace("test layer 1") << "foo";
-  CHECK_TRACE_CONTENTS("", "foo");
-}
-
-void test_trace_check_multiple_lines_at_once() {
-  trace("test layer 1") << "foo";
-  trace("test layer 2") << "bar";
-  CHECK_TRACE_CONTENTS("", "foobar");
+  trace("test layer 1") << "bar";
+  CHECK_TRACE_CONTENTS("test layer 1: bar");
 }
 
-void test_trace_check_always_finds_empty_lines2() {
-  CHECK_TRACE_CONTENTS("test layer 1", "");
+void test_trace_ignores_trailing_whitespace() {
+  trace("test layer 1") << "foo\n";
+  CHECK_TRACE_CONTENTS("test layer 1: foo");
 }
 
 void test_trace_orders_across_layers() {
   trace("test layer 1") << "foo";
   trace("test layer 2") << "bar";
   trace("test layer 1") << "qux";
-  CHECK_TRACE_CONTENTS("", "foobarqux");
-}
-
-void test_trace_orders_across_layers2() {
-  trace("test layer 1") << "foo";
-  trace("test layer 2") << "bar";
-  trace("test layer 1") << "qux";
-  CHECK_TRACE_CONTENTS("foobarqux");
-}
-
-void test_trace_checks_ordering_spanning_multiple_layers() {
-  trace("layer1") << "foo";
-  trace("layer2") << "bar";
-  trace("layer1") << "qux";
-  CHECK_TRACE_CONTENTS("layer1: foolayer2: barlayer1: qux");
+  CHECK_TRACE_CONTENTS("test layer 1: footest layer 2: bartest layer 1: qux");
 }
 
 void test_trace_supports_count() {