aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-20 15:07:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:33 +0200
commitcf4af1e966c5f005d5cb4b4080a9e11c106982bd (patch)
tree07dde02c35d96c2d08a64eb058b18f72fca2baf4
parent62436ec452ea4453fdffc7cda2c7bfcdcbdd5a71 (diff)
Change all testscript expansions to simple name mode
-rw-r--r--build2/test/script/parser.cxx24
-rw-r--r--unit-tests/test/script/parser/expansion.test13
2 files changed, 30 insertions, 7 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index f2f9b81..243b931 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -174,10 +174,20 @@ namespace build2
next (t, tt);
type kind (tt); // Assignment kind.
- // We cannot reuse the value mode since it will recognize { which
- // we want to treat as a literal.
+ // We cannot reuse the value mode since it will recognize { which we
+ // want to treat as a literal.
//
- value rhs (parse_variable_value (t, tt, lexer_mode::variable_line));
+ mode (lexer_mode::variable_line);
+ next (t, tt);
+
+ // Parse value attributes if any. Note that it's ok not to have
+ // anything after the attributes (e.g., foo=[null]).
+ //
+ attributes_push (t, tt, true);
+
+ value rhs (tt != type::newline && tt != type::eos
+ ? parse_names_value (t, tt, "variable value", nullptr)
+ : value (names ()));
if (tt != type::newline)
fail (t) << "unexpected " << t;
@@ -480,12 +490,12 @@ namespace build2
}
default:
{
- // Parse the next chunk as names to get variable expansion, etc.
+ // Parse the next chunk as simple names to get expansion, etc.
// Note that we do it in the chunking mode to detect whether
// anything in each chunk is quoted.
//
reset_quoted (t);
- parse_names (t, tt, ns, true, "command");
+ parse_names (t, tt, ns, true, "command line", nullptr);
if (pre_parse_) // Nothing else to do if we are pre-parsing.
break;
@@ -677,7 +687,7 @@ namespace build2
// The next chunk should be the exit status.
//
next (t, tt);
- names ns (parse_names (t, tt, true, "exit status"));
+ names ns (parse_names (t, tt, true, "exit status", nullptr));
unsigned long es (256);
if (!pre_parse_)
@@ -717,7 +727,7 @@ namespace build2
// Expand the line.
//
- names ns (parse_names (t, tt, false, "here-document line"));
+ names ns (parse_names (t, tt, false, "here-document line", nullptr));
if (!pre_parse_)
{
diff --git a/unit-tests/test/script/parser/expansion.test b/unit-tests/test/script/parser/expansion.test
new file mode 100644
index 0000000..c23d598
--- /dev/null
+++ b/unit-tests/test/script/parser/expansion.test
@@ -0,0 +1,13 @@
+# Make sure everything expanded as strings.
+#
+
+# quote
+#
+$* <<EOI >>EOO
+x = dir/ proj% proj%name proj%proj%dir/type{name name {name}}
+cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}}
+cmd \$x
+EOI
+cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}}
+cmd dir/ proj% proj%name proj%proj%dir/type{name name {name}}
+EOO