diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/tangle/030tangle.cc | 8 | ||||
-rw-r--r-- | cpp/tangle/030tangle.test.cc | 12 |
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; |