From 97f3bbacd9fec1d898d9ae147797b7164fb78833 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 4 Apr 2015 09:19:56 -0700 Subject: 1016 --- cpp/tangle/030tangle.cc | 8 ++++++++ cpp/tangle/030tangle.test.cc | 12 ++++++++++++ 2 files changed, 20 insertions(+) (limited to 'cpp') 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::iterator balancing_curly(list::iterator orig) { void emit_test(const string& name, list& lines, list& 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& 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 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 lines; -- cgit 1.4.1-2-gfad0