aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-06 14:39:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-06 14:39:18 +0200
commite66597b5a811e3f3313566cfff955c10ff5b1ccd (patch)
tree9a6d3e1b5be85fdbbc60ac5f8bac5da1595b04b0
parent5545b9e9627029e1e16c945f19c6d90a1dd51831 (diff)
Add testscript lexer support for portable path modifier (/)
-rw-r--r--build2/test/script/lexer.cxx28
-rw-r--r--unit-tests/test/script/parser/regex.test12
2 files changed, 28 insertions, 12 deletions
diff --git a/build2/test/script/lexer.cxx b/build2/test/script/lexer.cxx
index 53b166e..ba3f1ae 100644
--- a/build2/test/script/lexer.cxx
+++ b/build2/test/script/lexer.cxx
@@ -193,7 +193,9 @@ namespace build2
};
auto make_token_with_modifiers =
- [&make_token, this] (type t, const char* mods, bool exc = false)
+ [&make_token, this] (type t,
+ const char* mods, // To recorgnize.
+ const char* stop = nullptr) // To stop after.
{
string v;
if (mods != nullptr)
@@ -206,9 +208,7 @@ namespace build2
get ();
v += p;
- // If mutually exclusive, then we are done.
- //
- if (exc)
+ if (stop != nullptr && strchr (stop, p) != nullptr)
break;
}
}
@@ -342,7 +342,10 @@ namespace build2
return make_token (type::log_and);
}
- return make_token_with_modifiers (type::clean, "!?", true);
+ // These modifiers are mutually exclusive so stop after seeing
+ // either one.
+ //
+ return make_token_with_modifiers (type::clean, "!?", "!?");
}
// <
//
@@ -376,14 +379,14 @@ namespace build2
// Handle modifiers.
//
- const char* mod (nullptr);
+ const char* mods (nullptr);
switch (r)
{
case type::in_str:
- case type::in_doc: mod = ":"; break;
+ case type::in_doc: mods = ":/"; break;
}
- return make_token_with_modifiers (r, mod);
+ return make_token_with_modifiers (r, mods);
}
// >
//
@@ -418,15 +421,16 @@ namespace build2
// Handle modifiers.
//
- const char* mod (nullptr);
+ const char* mods (nullptr);
+ const char* stop (nullptr);
switch (r)
{
case type::out_str:
- case type::out_doc: mod = "~:"; break;
- case type::out_file: mod = "&"; break;
+ case type::out_doc: mods = ":/~"; stop = "~"; break;
+ case type::out_file: mods = "&"; break;
}
- return make_token_with_modifiers (r, mod);
+ return make_token_with_modifiers (r, mods, stop);
}
}
}
diff --git a/unit-tests/test/script/parser/regex.test b/unit-tests/test/script/parser/regex.test
index 58b1606..9f2e737 100644
--- a/unit-tests/test/script/parser/regex.test
+++ b/unit-tests/test/script/parser/regex.test
@@ -83,6 +83,12 @@
testscript:1:8: error: no introducer character in stderr regex redirect
EOE
}
+
+ : modifier-last
+ :
+ $* <'cmd >~/x' 2>>EOE != 0
+ testscript:1:7: error: no closing introducer character in stdout regex redirect
+ EOE
}
: here-doc
@@ -185,4 +191,10 @@
testscript:1:9: error: expected here-document regex end marker
EOE
}
+
+ : modifier-last
+ :
+ $* <'cmd >>~:/FOO/' 2>>EOE != 0
+ testscript:1:8: error: expected here-document regex end marker
+ EOE
}