aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-06-05 16:14:52 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-06-05 16:14:52 +0300
commit952c3b41399247615fe3a3c6e5109199aacf73b5 (patch)
tree1b6bd246df528efd0ff4c04e3f8638597c569e69
parent2ea2446b8ff5c08469d16a0deb951b0962924cec (diff)
Add test id verification
-rw-r--r--build2/test/script/parser.cxx14
-rw-r--r--doc/testscript.cli7
2 files changed, 17 insertions, 4 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 250a61e..2ae0b05 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -1139,8 +1139,20 @@ namespace build2
// Otherwise, see if it is the id. Failed that we assume it is
// the summary until we see the next line.
//
- (l.find_first_of (" \t", i) >= j ? r.id : r.summary).
+ (l.find_first_of (" \t.", i) >= j ? r.id : r.summary).
assign (l, i, n);
+
+ // If this is an id then validate it.
+ //
+ if (!r.id.empty ())
+ {
+ for (char c: r.id)
+ {
+ if (!(alnum (c) || c == '_' || c == '-' || c == '+'))
+ fail (loc) << "illegal character '" << c
+ << "' in test id '" << r.id << "'";
+ }
+ }
}
}
else if (ln == 2)
diff --git a/doc/testscript.cli b/doc/testscript.cli
index 41f8111..4433375 100644
--- a/doc/testscript.cli
+++ b/doc/testscript.cli
@@ -273,9 +273,10 @@ The description lines precede the test command. They start with a colon
The recommended format for \c{<id>} is \c{<keyword>-<keyword>...} with at
least two keywords. The id is used in diagnostics, to name the test working
directory, as well as to run individual tests. It can only contain
-alphanumeric characters as well as underscores and minuses. The recommended
-style for \c{<summary>} is that of the \c{git(1)} commit summary. The detailed
-description is free-form. Here are some examples (\c{#} starts a comment):
+alphanumeric characters as well as underscores, pluses, and minuses. The
+recommended style for \c{<summary>} is that of the \c{git(1)} commit summary.
+The detailed description is free-form. Here are some examples (\c{#} starts a
+comment):
\
# Only id.