diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-07-25 15:26:58 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-07-25 15:26:58 -0700 |
commit | 00c2ca083e004e9fdf3176f3362fd3b1091370ae (patch) | |
tree | 7ab794a0983ac20dac936ff0d05db87cfc0494b6 /tangle | |
parent | a18f5328ebe8d5cb878c90bf9ca03c1ab864a7d2 (diff) | |
download | mu-00c2ca083e004e9fdf3176f3362fd3b1091370ae.tar.gz |
4406
Fix CI.
Diffstat (limited to 'tangle')
-rw-r--r-- | tangle/003tangle.cc | 8 | ||||
-rw-r--r-- | tangle/003tangle.test.cc | 23 |
2 files changed, 29 insertions, 2 deletions
diff --git a/tangle/003tangle.cc b/tangle/003tangle.cc index 384af5e6..bcb3c315 100644 --- a/tangle/003tangle.cc +++ b/tangle/003tangle.cc @@ -296,11 +296,14 @@ list<Line>::iterator balancing_curly(list<Line>::iterator curr) { // one or more lines of escaped setup in C/C++ ('%') // followed by one or more lines of input, // followed optionally by (in order): -// one or more lines expected in trace in order ('+') -// one or more lines trace shouldn't include ('-') +// one or more lines expected in trace in order ('+') and one or more lines trace shouldn't include ('-') // one or more lines expressing counts of specific layers emitted in trace ('$') // a directive to print the trace just for debugging ('?') // Remember to update is_input below if you add to this format. +// +// Allowing interleaving of '+' and '-' lines is a kludgy way to indicate that +// two sets of trace lines can occur in any order. We should come up with a +// better way to specify order-independence. void emit_test(const string& name, list<Line>& lines, list<Line>& result) { result.push_back(Line("void test_"+name+"() {", front(lines).filename, front(lines).line_number-1)); // use line number of directive //? result.push_back("cerr << \""+name+"\\n\";"); // debug: uncomment this to print scenario names as you run them @@ -343,6 +346,7 @@ bool is_input(const string& line) { void emit_input_lines(list<Line>& hunk, list<Line>& out) { assert(!hunk.empty()); + if (!is_input(front(hunk).contents)) return; Line curr_out; curr_out.line_number = hunk.front().line_number; curr_out.filename = hunk.front().filename; diff --git a/tangle/003tangle.test.cc b/tangle/003tangle.test.cc index 4a1dc8de..732c8f2e 100644 --- a/tangle/003tangle.test.cc +++ b/tangle/003tangle.test.cc @@ -660,6 +660,29 @@ void test_tangle_can_handle_mu_comments_in_scenario() { CHECK(lines.empty()); } +void test_tangle_can_interleave_present_and_absent_lines_to_kludgily_avoid_specifying_order() { + istringstream in(":(scenario does_bar)\n" + "abc def\n" + "+layer1: pqr\n" + "-absent\n" + "+layer2: xyz"); + list<Line> lines; + tangle(in, lines); + CHECK_EQ(lines.front().contents, "void test_does_bar() {"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " run("); lines.pop_front(); + CHECK_EQ(lines.front().contents, " \"abc def\\n\""); lines.pop_front(); + CHECK_EQ(lines.front().contents, " );"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " CHECK_TRACE_CONTENTS("); lines.pop_front(); + CHECK_EQ(lines.front().contents, " \"layer1: pqr\""); lines.pop_front(); + CHECK_EQ(lines.front().contents, " );"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " CHECK_TRACE_DOESNT_CONTAIN(\"absent\");"); lines.pop_front(); + CHECK_EQ(lines.front().contents, " CHECK_TRACE_CONTENTS("); lines.pop_front(); + CHECK_EQ(lines.front().contents, " \"layer2: xyz\""); lines.pop_front(); + CHECK_EQ(lines.front().contents, " );"); lines.pop_front(); + CHECK_EQ(lines.front().contents, "}"); lines.pop_front(); + CHECK(lines.empty()); +} + //// helpers void test_trim() { |