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-04 09:19:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-04 09:19:56 -0700
commit97f3bbacd9fec1d898d9ae147797b7164fb78833 (patch)
tree5aaedd351eb5cd2cd8b70d95e918cfadfed19b47 /cpp/tangle
parent25d10ece4ef65863fa4e47f8239c737db9b72c98 (diff)
downloadmu-97f3bbacd9fec1d898d9ae147797b7164fb78833.tar.gz
1016
Diffstat (limited to 'cpp/tangle')
-rw-r--r--cpp/tangle/030tangle.cc8
-rw-r--r--cpp/tangle/030tangle.test.cc12
2 files changed, 20 insertions, 0 deletions
diff --git a/cpp/tangle/030tangle.cc b/cpp/tangle/030tangle.cc
index 2f81b23f..088ba7e8 100644
--- a/cpp/tangle/030tangle.cc
+++ b/cpp/tangle/030tangle.cc
@@ -203,6 +203,10 @@ list<string>::iterator balancing_curly(list<string>::iterator orig) {
 void emit_test(const string& name, list<string>& lines, list<string>& result) {
   result.push_back("TEST("+name+")");
   while (any_non_input_line(lines)) {
+    if (is_warn(lines.front())) {
+      result.push_back("  Hide_warnings = true;");
+      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)+"\");");
@@ -234,6 +238,10 @@ bool is_input(const string& line) {
   return line != "===" && line[0] != '+' && line[0] != '-' && !starts_with(line, "=>");
 }
 
+bool is_warn(const string& line) {
+  return line == "hide warnings";
+}
+
 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 950123f2..18fe62ad 100644
--- a/cpp/tangle/030tangle.test.cc
+++ b/cpp/tangle/030tangle.test.cc
@@ -119,6 +119,18 @@ void test_tangle_supports_configurable_toplevel() {
   tangle(cleanup, lines);
 }
 
+void test_tangle_can_hide_warnings_in_scenarios() {
+  istringstream in(":(scenario does_bar)\nhide warnings\nabc def\n+layer1: pqr\n+layer2: xyz");
+  list<string> lines;
+  tangle(in, lines);
+  CHECK_EQ(lines.front(), "TEST(does_bar)");  lines.pop_front();
+  CHECK_EQ(lines.front(), "  Hide_warnings = true;");  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;