about summary refs log tree commit diff stats
path: root/tangle
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-27 11:27:50 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-27 11:27:50 -0700
commit1326a4ec1ba2dfa093f8cf66e02d93ff7f4cebc6 (patch)
treebffbf0999e8c017e00f146930cc4c378461393e8 /tangle
parentab3aa2d4c141c30958f65aaf5bd86091b0e61621 (diff)
downloadmu-1326a4ec1ba2dfa093f8cf66e02d93ff7f4cebc6.tar.gz
1483 - *really* check color screens in scenarios
Required fixing two levels of bugs:

a) The hack in tangle to drop initial comments a '%' directive..

b) ..was masking a bug where run_mu_scenario wasn't robust to initial
comments.

Mildly concerned that neither of the sub-issues have their own tests,
but I'm just removing hacks, and writing tests for that throwaway
function like run_mu_scenario seems pointless. Instead I've solved the
problem by disallowing comments before '%' directives.

I've also taken this opportunity to at least try to document the
'scenarios' and '%' directives at the first layer where they appear.
Diffstat (limited to 'tangle')
-rw-r--r--tangle/030tangle.cc5
-rw-r--r--tangle/030tangle.test.cc24
2 files changed, 12 insertions, 17 deletions
diff --git a/tangle/030tangle.cc b/tangle/030tangle.cc
index 5e25c742..4949808a 100644
--- a/tangle/030tangle.cc
+++ b/tangle/030tangle.cc
@@ -301,11 +301,6 @@ list<Line>::iterator balancing_curly(list<Line>::iterator curr) {
 void emit_test(const string& name, list<Line>& lines, list<Line>& result) {
   result.push_back(Line("TEST("+name+")", front(lines).filename, front(lines).line_number-1));  // use line number of directive
   while (!lines.empty()) {
-    // hack: drop mu comments at the start, just in case there's a '%' line after them
-    // So the tangler only passes through mu comments inside scenarios between
-    // the first input line and the last input line.
-    while (!lines.empty() && starts_with(front(lines).contents, "#"))
-      lines.pop_front();
     while (!lines.empty() && starts_with(front(lines).contents, "% ")) {
       result.push_back(Line("  "+front(lines).contents.substr(strlen("% ")), front(lines)));
       lines.pop_front();
diff --git a/tangle/030tangle.test.cc b/tangle/030tangle.test.cc
index 0d4da899..cee0ac83 100644
--- a/tangle/030tangle.test.cc
+++ b/tangle/030tangle.test.cc
@@ -221,6 +221,18 @@ void test_tangle_can_hide_warnings_in_scenarios() {
   CHECK(lines.empty());
 }
 
+void test_tangle_can_handle_in_scenarios() {
+  istringstream in(":(scenario does_bar)\n% Hide_warnings = true;\nabc def\n+layer1: pqr\n+layer2: xyz");
+  list<Line> lines;
+  tangle(in, lines);
+  CHECK_EQ(lines.front().contents, "TEST(does_bar)");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "  Hide_warnings = true;");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "  run(\"abc def\\n\");");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "  CHECK_TRACE_CONTENTS(\"layer1: pqrlayer2: xyz\");");  lines.pop_front();
+  CHECK_EQ(lines.front().contents, "}");  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<Line> lines;
@@ -315,18 +327,6 @@ void test_tangle_can_handle_mu_comments_in_scenario() {
   CHECK(lines.empty());
 }
 
-void test_tangle_can_handle_escaped_setup_after_mu_comments() {
-  istringstream in(":(scenario does_bar)\n# comment\n% int x = 1;\nabc\n+layer1: pqr\n");
-  list<Line> lines;
-  tangle(in, lines);
-  CHECK_EQ(lines.front().contents, "TEST(does_bar)");  lines.pop_front();
-  CHECK_EQ(lines.front().contents, "  int x = 1;"); lines.pop_front();
-  CHECK_EQ(lines.front().contents, "  run(\"abc\\n\");");  lines.pop_front();
-  CHECK_EQ(lines.front().contents, "  CHECK_TRACE_CONTENTS(\"layer1: pqr\");");  lines.pop_front();
-  CHECK_EQ(lines.front().contents, "}");  lines.pop_front();
-  CHECK(lines.empty());
-}
-
 
 
 void test_trim() {