aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-21 17:07:18 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:34 +0200
commitd9b26553b67e87dd45b652dd91eaac782fdf91f9 (patch)
treea42f2e8d4d6bf2e6232861b57d262d2cf8cc0a33 /unit-tests/test/script
parenta36a5042a35ddf5e8e32dd351168d9e71cd761f2 (diff)
Add support for testscript scope id, working directory
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r--unit-tests/test/script/lexer/driver.cxx4
-rw-r--r--unit-tests/test/script/parser/buildfile2
-rw-r--r--unit-tests/test/script/parser/driver.cxx14
-rw-r--r--unit-tests/test/script/parser/scope.test15
4 files changed, 26 insertions, 9 deletions
diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx
index 6d9bfb7..cd7110f 100644
--- a/unit-tests/test/script/lexer/driver.cxx
+++ b/unit-tests/test/script/lexer/driver.cxx
@@ -19,11 +19,11 @@ namespace build2
{
namespace script
{
+ // Usage: argv[0] <lexer-mode>
+ //
int
main (int argc, char* argv[])
{
- // Usage: argv[0] <lexer-mode>
- //
lexer_mode m;
{
assert (argc == 2);
diff --git a/unit-tests/test/script/parser/buildfile b/unit-tests/test/script/parser/buildfile
index af602b1..a6be1f6 100644
--- a/unit-tests/test/script/parser/buildfile
+++ b/unit-tests/test/script/parser/buildfile
@@ -11,6 +11,6 @@ filesystem config/{utility init operation} dump types-parsers \
test/{target script/{token lexer parser script}}
exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \
-test{pre-parse expansion here-document command-re-parse}
+test{pre-parse expansion here-document command-re-parse scope}
include ../../../../build2/
diff --git a/unit-tests/test/script/parser/driver.cxx b/unit-tests/test/script/parser/driver.cxx
index 148a081..db253eb 100644
--- a/unit-tests/test/script/parser/driver.cxx
+++ b/unit-tests/test/script/parser/driver.cxx
@@ -29,7 +29,7 @@ namespace build2
{
public:
virtual void
- run (const command& t, size_t, const location&) override
+ run (const scope&, const command& t, size_t, const location&) override
{
// Here we assume we are running serially.
//
@@ -37,8 +37,10 @@ namespace build2
}
};
+ // Usage: argv[0] [<testscript-name>]
+ //
int
- main ()
+ main (int argc, char* argv[])
{
tracer trace ("main");
@@ -47,7 +49,7 @@ namespace build2
try
{
- path name ("testscript");
+ path name (argc > 1 ? argv[1] : "testscript");
cin.exceptions (istream::failbit | istream::badbit);
// Enter mock targets. Use fixed names and paths so that we can use
@@ -70,7 +72,7 @@ namespace build2
trace));
tt.path (path ("driver"));
- st.path (path ("testscript"));
+ st.path (name);
// Parse and run.
//
@@ -93,7 +95,7 @@ namespace build2
}
int
-main ()
+main (int argc, char* argv[])
{
- return build2::test::script::main ();
+ return build2::test::script::main (argc, argv);
}
diff --git a/unit-tests/test/script/parser/scope.test b/unit-tests/test/script/parser/scope.test
new file mode 100644
index 0000000..a2c6d9f
--- /dev/null
+++ b/unit-tests/test/script/parser/scope.test
@@ -0,0 +1,15 @@
+$* testscript <'cmd $@' >"cmd 1" # id-testscript
+$* foo.test <'cmd $@' >"cmd foo/1" # id
+
+wd = [dir_path] $build.work
+wd += test
+wd += 1
+$* testscript <'cmd $~' >"cmd $wd" # wd-testscript
+
+# @@ TMP wd1
+#
+wd1 = [dir_path] $build.work
+wd1 += test
+wd1 += foo
+wd1 += 1
+$* foo.test <'cmd $~' >"cmd $wd1" # wd