diff options
Diffstat (limited to 'unit-tests/test')
-rw-r--r-- | unit-tests/test/script/lexer/driver.cxx | 4 | ||||
-rw-r--r-- | unit-tests/test/script/parser/buildfile | 2 | ||||
-rw-r--r-- | unit-tests/test/script/parser/driver.cxx | 14 | ||||
-rw-r--r-- | unit-tests/test/script/parser/scope.test | 15 |
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 |