about summary refs log tree commit diff stats
path: root/cpp/tangle
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-19 20:21:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-19 20:21:48 -0700
commit4b72aa8ba510376d5ed2576e328972433213058c (patch)
tree5dedcba4680fb195121190c9ef8fafcb1a84d456 /cpp/tangle
parent69d95127b03ba92be03ed42beeab099dbcc808b9 (diff)
downloadmu-4b72aa8ba510376d5ed2576e328972433213058c.tar.gz
1102
Diffstat (limited to 'cpp/tangle')
-rw-r--r--cpp/tangle/030tangle.cc9
-rw-r--r--cpp/tangle/030tangle.test.cc14
2 files changed, 23 insertions, 0 deletions
diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc
index fc40880f..bbd0e178 100644
--- a/cpp/tangle/030tangle.cc
+++ b/cpp/tangle/030tangle.cc
@@ -233,6 +233,11 @@ void emit_test(const string& name, list<string>& lines, list<string>& result) {
       result.push_back("  Hide_warnings = true;");
       lines.pop_front();
     }
+    if (starts_with(lines.front(), "dump ")) {
+      string line = lines.front().substr(strlen("dump "));
+      result.push_back("  Trace_stream->dump_layer = \""+line+"\";");
+      lines.pop_front();
+    }
     result.push_back("  "+Toplevel+"(\""+input_lines(lines)+"\");");
     if (!lines.empty() && lines.front()[0] == '+')
       result.push_back("  CHECK_TRACE_CONTENTS(\""+expected_in_trace(lines)+"\");");
@@ -268,6 +273,10 @@ bool is_warn(const string& line) {
   return line == "hide warnings";
 }
 
+bool is_dump(const string& line) {
+  return starts_with(line, "dump ");
+}
+
 string input_lines(list<string>& hunk) {
   string result;
   while (!hunk.empty() && is_input(hunk.front())) {
diff --git a/cpp/tangle/030tangle.test.cc b/cpp/tangle/030tangle.test.cc
index 3f86fdb8..bdf24a5c 100644
--- a/cpp/tangle/030tangle.test.cc
+++ b/cpp/tangle/030tangle.test.cc
@@ -196,6 +196,20 @@ void test_tangle_can_hide_warnings_in_scenarios() {
   CHECK(lines.empty());
 }
 
+void test_tangle_can_dump_traces_in_scenarios() {
+  istringstream in(":(scenario does_bar)\ndump foo\nabc def\n+layer1: pqr\n+layer2: xyz");
+  list<string> lines;
+  tangle(in, lines);
+  CHECK_EQ(lines.front(), "#line 1");  lines.pop_front();
+  CHECK_EQ(lines.front(), "#line 2");  lines.pop_front();
+  CHECK_EQ(lines.front(), "TEST(does_bar)");  lines.pop_front();
+  CHECK_EQ(lines.front(), "  Trace_stream->dump_layer = \"foo\";");  lines.pop_front();
+  CHECK_EQ(lines.front(), "  run(\"abc def\\n\");");  lines.pop_front();
+  CHECK_EQ(lines.front(), "  CHECK_TRACE_CONTENTS(\"layer1: pqrlayer2: xyz\");");  lines.pop_front();
+  CHECK_EQ(lines.front(), "}");  lines.pop_front();
+  CHECK(lines.empty());
+}
+
 void test_tangle_supports_strings_in_scenarios() {
   istringstream in(":(scenario does_bar)\nabc \"def\"\n+layer1: pqr\n+layer2: \"xyz\"");
   list<string> lines;