From 5007870b52aa549971824959a55ad3bb886f09e0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 3 Sep 2018 16:37:32 +0200 Subject: Rename .test/test{} to .testscript/testscript{} --- build2/test/rule.cxx | 4 +- build2/test/target.cxx | 8 +- doc/manual.cli | 2 +- doc/testscript.cli | 71 +-- tests/bash/testscript | 2 +- tests/build/root.build | 2 +- tests/buildfile | 2 +- tests/cc/libu/testscript | 2 +- tests/cc/modules/testscript | 2 +- tests/cc/preprocessed/testscript | 2 +- tests/common.test | 45 -- tests/common.testscript | 45 ++ tests/directive/assert.test | 28 -- tests/directive/assert.testscript | 28 ++ tests/directive/buildfile | 2 +- tests/directive/run.test | 37 -- tests/directive/run.testscript | 37 ++ tests/eval/buildfile | 2 +- tests/eval/comma.test | 13 - tests/eval/comma.testscript | 13 + tests/eval/comp.test | 47 -- tests/eval/comp.testscript | 47 ++ tests/eval/or-and.test | 28 -- tests/eval/or-and.testscript | 28 ++ tests/eval/qual.test | 28 -- tests/eval/qual.testscript | 28 ++ tests/eval/ternary.test | 30 -- tests/eval/ternary.testscript | 30 ++ tests/eval/value.test | 23 - tests/eval/value.testscript | 23 + tests/expansion/buildfile | 2 +- tests/expansion/concat.test | 28 -- tests/expansion/concat.testscript | 28 ++ tests/expansion/type.test | 50 -- tests/expansion/type.testscript | 50 ++ tests/function/builtin/testscript | 2 +- tests/function/filesystem/testscript | 2 +- tests/function/install/testscript | 2 +- tests/function/path/testscript | 2 +- tests/function/process/testscript | 2 +- tests/function/regex/testscript | 2 +- tests/hooks/testscript | 2 +- tests/in/testscript | 2 +- tests/loop/buildfile | 2 +- tests/loop/for.test | 112 ----- tests/loop/for.testscript | 112 +++++ tests/name/buildfile | 2 +- tests/name/cross.test | 115 ----- tests/name/cross.testscript | 115 +++++ tests/name/extension.test | 86 ---- tests/name/extension.testscript | 86 ++++ tests/name/pattern.test | 332 ------------ tests/name/pattern.testscript | 332 ++++++++++++ tests/search/dir/testscript | 2 +- tests/test/buildfile | 2 +- tests/test/common.test | 29 -- tests/test/common.testscript | 29 ++ tests/test/config-test/testscript | 6 +- tests/test/script/buildfile | 2 +- tests/test/script/builtin/buildfile | 2 +- tests/test/script/builtin/cat.test | 84 ---- tests/test/script/builtin/cat.testscript | 84 ++++ tests/test/script/builtin/cp.test | 376 -------------- tests/test/script/builtin/cp.testscript | 376 ++++++++++++++ tests/test/script/builtin/echo.test | 27 - tests/test/script/builtin/echo.testscript | 27 + tests/test/script/builtin/ln.test | 184 ------- tests/test/script/builtin/ln.testscript | 184 +++++++ tests/test/script/builtin/mkdir.test | 66 --- tests/test/script/builtin/mkdir.testscript | 66 +++ tests/test/script/builtin/mv.test | 252 ---------- tests/test/script/builtin/mv.testscript | 252 ++++++++++ tests/test/script/builtin/rm.test | 119 ----- tests/test/script/builtin/rm.testscript | 119 +++++ tests/test/script/builtin/rmdir.test | 114 ----- tests/test/script/builtin/rmdir.testscript | 114 +++++ tests/test/script/builtin/sed.test | 333 ------------- tests/test/script/builtin/sed.testscript | 333 +++++++++++++ tests/test/script/builtin/test.test | 69 --- tests/test/script/builtin/test.testscript | 69 +++ tests/test/script/builtin/touch.test | 88 ---- tests/test/script/builtin/touch.testscript | 88 ++++ tests/test/script/common.test | 36 -- tests/test/script/common.testscript | 37 ++ tests/test/script/generated/testscript | 4 +- tests/test/script/integration/testscript | 28 +- tests/test/script/runner/buildfile | 4 +- tests/test/script/runner/cleanup.test | 346 ------------- tests/test/script/runner/cleanup.testscript | 346 +++++++++++++ tests/test/script/runner/exit.test | 400 --------------- tests/test/script/runner/exit.testscript | 400 +++++++++++++++ tests/test/script/runner/expr.test | 522 ------------------- tests/test/script/runner/expr.testscript | 522 +++++++++++++++++++ tests/test/script/runner/if.test | 25 - tests/test/script/runner/if.testscript | 25 + tests/test/script/runner/output.test | 87 ---- tests/test/script/runner/output.testscript | 87 ++++ tests/test/script/runner/pipe.test | 35 -- tests/test/script/runner/pipe.testscript | 35 ++ tests/test/script/runner/redirect.test | 515 ------------------- tests/test/script/runner/redirect.testscript | 515 +++++++++++++++++++ tests/test/script/runner/regex.test | 312 ------------ tests/test/script/runner/regex.testscript | 312 ++++++++++++ tests/test/script/runner/set.test | 278 ----------- tests/test/script/runner/set.testscript | 278 +++++++++++ tests/test/script/runner/status.test | 57 --- tests/test/script/runner/status.testscript | 57 +++ tests/test/simple/generated/testscript | 2 +- tests/value/buildfile | 2 +- tests/value/concat.test | 73 --- tests/value/concat.testscript | 73 +++ tests/value/reverse.test | 82 --- tests/value/reverse.testscript | 82 +++ tests/variable/override/testscript | 2 +- tests/variable/prerequisite-specific/testscript | 2 +- tests/variable/scope-specific/testscript | 2 +- tests/variable/target-specific/testscript | 2 +- unit-tests/cc/lexer/buildfile | 2 +- unit-tests/cc/lexer/char-literal.test | 67 --- unit-tests/cc/lexer/char-literal.testscript | 67 +++ unit-tests/cc/lexer/comment.test | 88 ---- unit-tests/cc/lexer/comment.testscript | 88 ++++ unit-tests/cc/lexer/line.test | 67 --- unit-tests/cc/lexer/line.testscript | 67 +++ unit-tests/cc/lexer/number.test | 48 -- unit-tests/cc/lexer/number.testscript | 48 ++ unit-tests/cc/lexer/preprocessor.test | 73 --- unit-tests/cc/lexer/preprocessor.testscript | 73 +++ unit-tests/cc/lexer/raw-string-literal.test | 90 ---- unit-tests/cc/lexer/raw-string-literal.testscript | 90 ++++ unit-tests/cc/lexer/string-literal.test | 65 --- unit-tests/cc/lexer/string-literal.testscript | 65 +++ unit-tests/cc/parser/buildfile | 2 +- unit-tests/cc/parser/module.test | 149 ------ unit-tests/cc/parser/module.testscript | 149 ++++++ unit-tests/function/buildfile | 2 +- unit-tests/function/call.test | 161 ------ unit-tests/function/call.testscript | 161 ++++++ unit-tests/function/syntax.test | 29 -- unit-tests/function/syntax.testscript | 29 ++ unit-tests/lexer/buildfile | 2 +- unit-tests/lexer/buildspec.test | 16 - unit-tests/lexer/buildspec.testscript | 16 + unit-tests/lexer/comment.test | 139 ------ unit-tests/lexer/comment.testscript | 139 ++++++ unit-tests/lexer/eval.test | 76 --- unit-tests/lexer/eval.testscript | 76 +++ unit-tests/lexer/quoting.test | 108 ---- unit-tests/lexer/quoting.testscript | 108 ++++ unit-tests/test/script/lexer/buildfile | 2 +- .../test/script/lexer/command-expansion.test | 248 --------- .../test/script/lexer/command-expansion.testscript | 248 +++++++++ unit-tests/test/script/lexer/command-line.test | 208 -------- .../test/script/lexer/command-line.testscript | 208 ++++++++ unit-tests/test/script/lexer/description-line.test | 33 -- .../test/script/lexer/description-line.testscript | 33 ++ unit-tests/test/script/lexer/first-token.test | 97 ---- .../test/script/lexer/first-token.testscript | 97 ++++ unit-tests/test/script/lexer/second-token.test | 68 --- .../test/script/lexer/second-token.testscript | 68 +++ unit-tests/test/script/lexer/variable-line.test | 28 -- .../test/script/lexer/variable-line.testscript | 28 ++ unit-tests/test/script/lexer/variable.test | 70 --- unit-tests/test/script/lexer/variable.testscript | 70 +++ unit-tests/test/script/parser/buildfile | 2 +- unit-tests/test/script/parser/cleanup.test | 58 --- unit-tests/test/script/parser/cleanup.testscript | 58 +++ unit-tests/test/script/parser/command-if.test | 548 -------------------- .../test/script/parser/command-if.testscript | 548 ++++++++++++++++++++ .../test/script/parser/command-re-parse.test | 12 - .../test/script/parser/command-re-parse.testscript | 12 + unit-tests/test/script/parser/description.test | 486 ------------------ .../test/script/parser/description.testscript | 486 ++++++++++++++++++ unit-tests/test/script/parser/directive.test | 74 --- unit-tests/test/script/parser/directive.testscript | 74 +++ unit-tests/test/script/parser/exit.test | 27 - unit-tests/test/script/parser/exit.testscript | 27 + unit-tests/test/script/parser/expansion.test | 36 -- unit-tests/test/script/parser/expansion.testscript | 36 ++ unit-tests/test/script/parser/here-document.test | 213 -------- .../test/script/parser/here-document.testscript | 213 ++++++++ unit-tests/test/script/parser/here-string.test | 19 - .../test/script/parser/here-string.testscript | 19 + unit-tests/test/script/parser/include.test | 104 ---- unit-tests/test/script/parser/include.testscript | 104 ++++ unit-tests/test/script/parser/pipe-expr.test | 133 ----- unit-tests/test/script/parser/pipe-expr.testscript | 133 +++++ unit-tests/test/script/parser/pre-parse.test | 23 - unit-tests/test/script/parser/pre-parse.testscript | 23 + unit-tests/test/script/parser/redirect.test | 356 ------------- unit-tests/test/script/parser/redirect.testscript | 356 +++++++++++++ unit-tests/test/script/parser/regex.test | 223 --------- unit-tests/test/script/parser/regex.testscript | 223 +++++++++ unit-tests/test/script/parser/scope-if.test | 554 --------------------- unit-tests/test/script/parser/scope-if.testscript | 554 +++++++++++++++++++++ unit-tests/test/script/parser/scope.test | 280 ----------- unit-tests/test/script/parser/scope.testscript | 280 +++++++++++ unit-tests/test/script/parser/setup-teardown.test | 151 ------ .../test/script/parser/setup-teardown.testscript | 151 ++++++ 199 files changed, 10836 insertions(+), 10834 deletions(-) delete mode 100644 tests/common.test create mode 100644 tests/common.testscript delete mode 100644 tests/directive/assert.test create mode 100644 tests/directive/assert.testscript delete mode 100644 tests/directive/run.test create mode 100644 tests/directive/run.testscript delete mode 100644 tests/eval/comma.test create mode 100644 tests/eval/comma.testscript delete mode 100644 tests/eval/comp.test create mode 100644 tests/eval/comp.testscript delete mode 100644 tests/eval/or-and.test create mode 100644 tests/eval/or-and.testscript delete mode 100644 tests/eval/qual.test create mode 100644 tests/eval/qual.testscript delete mode 100644 tests/eval/ternary.test create mode 100644 tests/eval/ternary.testscript delete mode 100644 tests/eval/value.test create mode 100644 tests/eval/value.testscript delete mode 100644 tests/expansion/concat.test create mode 100644 tests/expansion/concat.testscript delete mode 100644 tests/expansion/type.test create mode 100644 tests/expansion/type.testscript delete mode 100644 tests/loop/for.test create mode 100644 tests/loop/for.testscript delete mode 100644 tests/name/cross.test create mode 100644 tests/name/cross.testscript delete mode 100644 tests/name/extension.test create mode 100644 tests/name/extension.testscript delete mode 100644 tests/name/pattern.test create mode 100644 tests/name/pattern.testscript delete mode 100644 tests/test/common.test create mode 100644 tests/test/common.testscript delete mode 100644 tests/test/script/builtin/cat.test create mode 100644 tests/test/script/builtin/cat.testscript delete mode 100644 tests/test/script/builtin/cp.test create mode 100644 tests/test/script/builtin/cp.testscript delete mode 100644 tests/test/script/builtin/echo.test create mode 100644 tests/test/script/builtin/echo.testscript delete mode 100644 tests/test/script/builtin/ln.test create mode 100644 tests/test/script/builtin/ln.testscript delete mode 100644 tests/test/script/builtin/mkdir.test create mode 100644 tests/test/script/builtin/mkdir.testscript delete mode 100644 tests/test/script/builtin/mv.test create mode 100644 tests/test/script/builtin/mv.testscript delete mode 100644 tests/test/script/builtin/rm.test create mode 100644 tests/test/script/builtin/rm.testscript delete mode 100644 tests/test/script/builtin/rmdir.test create mode 100644 tests/test/script/builtin/rmdir.testscript delete mode 100644 tests/test/script/builtin/sed.test create mode 100644 tests/test/script/builtin/sed.testscript delete mode 100644 tests/test/script/builtin/test.test create mode 100644 tests/test/script/builtin/test.testscript delete mode 100644 tests/test/script/builtin/touch.test create mode 100644 tests/test/script/builtin/touch.testscript delete mode 100644 tests/test/script/common.test create mode 100644 tests/test/script/common.testscript delete mode 100644 tests/test/script/runner/cleanup.test create mode 100644 tests/test/script/runner/cleanup.testscript delete mode 100644 tests/test/script/runner/exit.test create mode 100644 tests/test/script/runner/exit.testscript delete mode 100644 tests/test/script/runner/expr.test create mode 100644 tests/test/script/runner/expr.testscript delete mode 100644 tests/test/script/runner/if.test create mode 100644 tests/test/script/runner/if.testscript delete mode 100644 tests/test/script/runner/output.test create mode 100644 tests/test/script/runner/output.testscript delete mode 100644 tests/test/script/runner/pipe.test create mode 100644 tests/test/script/runner/pipe.testscript delete mode 100644 tests/test/script/runner/redirect.test create mode 100644 tests/test/script/runner/redirect.testscript delete mode 100644 tests/test/script/runner/regex.test create mode 100644 tests/test/script/runner/regex.testscript delete mode 100644 tests/test/script/runner/set.test create mode 100644 tests/test/script/runner/set.testscript delete mode 100644 tests/test/script/runner/status.test create mode 100644 tests/test/script/runner/status.testscript delete mode 100644 tests/value/concat.test create mode 100644 tests/value/concat.testscript delete mode 100644 tests/value/reverse.test create mode 100644 tests/value/reverse.testscript delete mode 100644 unit-tests/cc/lexer/char-literal.test create mode 100644 unit-tests/cc/lexer/char-literal.testscript delete mode 100644 unit-tests/cc/lexer/comment.test create mode 100644 unit-tests/cc/lexer/comment.testscript delete mode 100644 unit-tests/cc/lexer/line.test create mode 100644 unit-tests/cc/lexer/line.testscript delete mode 100644 unit-tests/cc/lexer/number.test create mode 100644 unit-tests/cc/lexer/number.testscript delete mode 100644 unit-tests/cc/lexer/preprocessor.test create mode 100644 unit-tests/cc/lexer/preprocessor.testscript delete mode 100644 unit-tests/cc/lexer/raw-string-literal.test create mode 100644 unit-tests/cc/lexer/raw-string-literal.testscript delete mode 100644 unit-tests/cc/lexer/string-literal.test create mode 100644 unit-tests/cc/lexer/string-literal.testscript delete mode 100644 unit-tests/cc/parser/module.test create mode 100644 unit-tests/cc/parser/module.testscript delete mode 100644 unit-tests/function/call.test create mode 100644 unit-tests/function/call.testscript delete mode 100644 unit-tests/function/syntax.test create mode 100644 unit-tests/function/syntax.testscript delete mode 100644 unit-tests/lexer/buildspec.test create mode 100644 unit-tests/lexer/buildspec.testscript delete mode 100644 unit-tests/lexer/comment.test create mode 100644 unit-tests/lexer/comment.testscript delete mode 100644 unit-tests/lexer/eval.test create mode 100644 unit-tests/lexer/eval.testscript delete mode 100644 unit-tests/lexer/quoting.test create mode 100644 unit-tests/lexer/quoting.testscript delete mode 100644 unit-tests/test/script/lexer/command-expansion.test create mode 100644 unit-tests/test/script/lexer/command-expansion.testscript delete mode 100644 unit-tests/test/script/lexer/command-line.test create mode 100644 unit-tests/test/script/lexer/command-line.testscript delete mode 100644 unit-tests/test/script/lexer/description-line.test create mode 100644 unit-tests/test/script/lexer/description-line.testscript delete mode 100644 unit-tests/test/script/lexer/first-token.test create mode 100644 unit-tests/test/script/lexer/first-token.testscript delete mode 100644 unit-tests/test/script/lexer/second-token.test create mode 100644 unit-tests/test/script/lexer/second-token.testscript delete mode 100644 unit-tests/test/script/lexer/variable-line.test create mode 100644 unit-tests/test/script/lexer/variable-line.testscript delete mode 100644 unit-tests/test/script/lexer/variable.test create mode 100644 unit-tests/test/script/lexer/variable.testscript delete mode 100644 unit-tests/test/script/parser/cleanup.test create mode 100644 unit-tests/test/script/parser/cleanup.testscript delete mode 100644 unit-tests/test/script/parser/command-if.test create mode 100644 unit-tests/test/script/parser/command-if.testscript delete mode 100644 unit-tests/test/script/parser/command-re-parse.test create mode 100644 unit-tests/test/script/parser/command-re-parse.testscript delete mode 100644 unit-tests/test/script/parser/description.test create mode 100644 unit-tests/test/script/parser/description.testscript delete mode 100644 unit-tests/test/script/parser/directive.test create mode 100644 unit-tests/test/script/parser/directive.testscript delete mode 100644 unit-tests/test/script/parser/exit.test create mode 100644 unit-tests/test/script/parser/exit.testscript delete mode 100644 unit-tests/test/script/parser/expansion.test create mode 100644 unit-tests/test/script/parser/expansion.testscript delete mode 100644 unit-tests/test/script/parser/here-document.test create mode 100644 unit-tests/test/script/parser/here-document.testscript delete mode 100644 unit-tests/test/script/parser/here-string.test create mode 100644 unit-tests/test/script/parser/here-string.testscript delete mode 100644 unit-tests/test/script/parser/include.test create mode 100644 unit-tests/test/script/parser/include.testscript delete mode 100644 unit-tests/test/script/parser/pipe-expr.test create mode 100644 unit-tests/test/script/parser/pipe-expr.testscript delete mode 100644 unit-tests/test/script/parser/pre-parse.test create mode 100644 unit-tests/test/script/parser/pre-parse.testscript delete mode 100644 unit-tests/test/script/parser/redirect.test create mode 100644 unit-tests/test/script/parser/redirect.testscript delete mode 100644 unit-tests/test/script/parser/regex.test create mode 100644 unit-tests/test/script/parser/regex.testscript delete mode 100644 unit-tests/test/script/parser/scope-if.test create mode 100644 unit-tests/test/script/parser/scope-if.testscript delete mode 100644 unit-tests/test/script/parser/scope.test create mode 100644 unit-tests/test/script/parser/scope.testscript delete mode 100644 unit-tests/test/script/parser/setup-teardown.test create mode 100644 unit-tests/test/script/parser/setup-teardown.testscript diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx index 282540c..64cd56c 100644 --- a/build2/test/rule.cxx +++ b/build2/test/rule.cxx @@ -113,8 +113,8 @@ namespace build2 // it may not be a testable target at all). So as the first step // determine which case this is. // - // If we have any prerequisites of the test{} type, then this is the - // testscript case. + // If we have any prerequisites of the testscript{} type, then this is + // the testscript case. // // If we can, go inside see-through groups. Normally groups won't be // resolvable for this action but then normally they won't contain any diff --git a/build2/test/target.cxx b/build2/test/target.cxx index 25afd0d..a6adde9 100644 --- a/build2/test/target.cxx +++ b/build2/test/target.cxx @@ -15,9 +15,9 @@ namespace build2 testscript_target_extension (const target_key& tk) { // If the name is special 'testscript', then there is no extension, - // otherwise it is .test. + // otherwise it is .testscript. // - return *tk.name == "testscript" ? "" : "test"; + return *tk.name == "testscript" ? "" : "testscript"; } static bool @@ -39,7 +39,7 @@ namespace build2 if (!e && v != "testscript") { - e = "test"; + e = "testscript"; return true; } } @@ -49,7 +49,7 @@ namespace build2 const target_type testscript::static_type { - "test", + "testscript", &file::static_type, &target_factory, &testscript_target_extension, diff --git a/doc/manual.cli b/doc/manual.cli index 4a6f854..00a6eb5 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -1742,7 +1742,7 @@ expect to see when running the tests: b test c++ hello/cxx{hello} ld hello/exe{hello} -test hello/test{testscript} hello/exe{hello} +test hello/testscript{testscript} hello/exe{hello} hello/testscript:7:1: error: hello/hello exit code 0 == 0 info: stdout: hello/test-hello/missing-name/stdout \ diff --git a/doc/testscript.cli b/doc/testscript.cli index deeba89..921a0f1 100644 --- a/doc/testscript.cli +++ b/doc/testscript.cli @@ -104,7 +104,7 @@ testscript file tests a specific target we simply list it as a target's prerequisite, for example: \ -exe{hello}: cxx{hello} test{testscript} +exe{hello}: cxx{hello} testscript \ Let's assume our \c{hello} program expects us to pass the name to greet as a @@ -482,9 +482,9 @@ platform test to \c{buildfile}: \ # buildfile -exe{hello}: cxx{hello} test{testscript} +exe{hello}: cxx{hello} testscript -test{*}: windows = ($cxx.target.class == windows) +testscript{*}: windows = ($cxx.target.class == windows) \ \ @@ -612,13 +612,14 @@ prerequisite that describes how to test the target similar to how, for example, the \c{INSTALL} file describes how to install it. For example: \ -exe{hello}: test{testscript} doc{INSTALL README} +exe{hello}: testscript doc{INSTALL README} \ By convention, the testscript file should be called either \c{testscript} if -you only have one or have the \c{.test} extension, for example, -\c{basics.test}. The \c{test} module registers the \c{test{\}} target type to -be used for testscript files. +you only have one or have the \c{.testscript} extension, for example, +\c{basics.testscript}. The \c{test} module registers the \c{testscript{\}} +target type to be used for testscript files. We don't have to use explicit +target type for the \c{testscript} file. A testscript prerequisite can be specified for any target. For example, if our directory contains a bunch of shell scripts that we want to test together, @@ -626,22 +627,22 @@ then it makes sense to specify the testscript prerequisite for the directory target: \ -./: test{basics} +./: testscript{basics} \ During variable lookup if a variable is not found in one of the testscript scopes (see \l{#model Model and Execution}), then the search continues in the \c{buildfile} starting with the target-specific variables of the target being tested (e.g., \c{exe{hello\}}; called \i{test target}), then target-specific -variables of the testscript target (e.g., \c{test{basics\}}; called \i{script -target}), and then continuing with the scopes starting with the one containing -the script target. As a result, a testscript can \"see\" all the existing -buildfile variables plus we can use target-specific variables to pass +variables of the testscript target (e.g., \c{testscript{basics\}}; called +\i{script target}), and then continuing with the scopes starting with the one +containing the script target. As a result, a testscript can \"see\" all the +existing buildfile variables plus we can use target-specific variables to pass additional, test-specific, information to testscrips. As an example, consider this testscript and buildfile pair: \ -# basics.test +# basics.testscript if ($cxx.target.class == windows) test.arguments += $foo @@ -655,19 +656,19 @@ end \ # buildfile -exe{hello}: test{basics} +exe{hello}: testscript{basics} # All testscripts in this scope. # -test{*}: windows = ($cxx.target.class == windows) +testscript{*}: windows = ($cxx.target.class == windows) # All testscripts for target exe{hello}. # exe{hello}: bar = BAR -# Only basics.test. +# Only basics.testscript. # -test{basics}@./: foo = FOO +testscript{basics}@./: foo = FOO \ Additionally, by convention, a number of pre-defined \c{test.*} variables are @@ -678,7 +679,7 @@ variable is automatically set to the target path being tested. For example, given this \c{buildfile}: \ -exe{hello}: test{testscript} +exe{hello}: testscript \ The value of \c{test} inside the testscript will be the absolute path to the @@ -704,7 +705,7 @@ This is how we can implement \c{tests/buildfile} for this setup: \ hello = ../hello/exe{hello} -./: $hello test{testscript} +./: $hello testscript ./: test = $hello include ../hello/ @@ -762,8 +763,8 @@ directory, then the subdirectory is called \c{test}. Otherwise, it is the name of the target prefixed with\c{test-}. For example: \ -./: test{foo} # $out_base/test/ -exe{hello}: test{bar} # $out_base/test-hello/ +./: testscript{foo} # $out_base/test/ +exe{hello}: testscript{bar} # $out_base/test-hello/ \ @@ -787,8 +788,8 @@ A scope (both group and test) has an \i{id}. If not specified explicitly (as part of the description), it is derived automatically from the group/test location in the testscript file (see \l{#syntax-description Description} for details). The id of the implicit outermost scope is the script file name -without the \c{.test} extension, except if the file name is \c{testscript}, -in which case the id is empty. +without the \c{.testscript} extension, except if the file name is +\c{testscript}, in which case the id is empty. Based on the ids each nested group and test has an \i{id path} that uniquely identifies it. It starts with the id of the implied outermost group (unless @@ -799,7 +800,7 @@ temporary directory where the test is executed (as described below). Inside a scope its id path is available via the special \c{$@} variable (read-only). As an example, consider the following testscript file which we assume is -called \c{basics.test}: +called \c{basics.testscript}: \ test0: test0 @@ -861,9 +862,9 @@ is not empty, then the test is considered to have failed (unexpected output). Inside a scope its working directory is available via the special \c{$~} variable (read-only). -As an example, consider the following version of \c{basics.test}. We also -assume that its test target is a directory (so the target test directory is -\c{$out_base/test/}). +As an example, consider the following version of \c{basics.testscript}. We +also assume that its test target is a directory (so the target test directory +is \c{$out_base/test/}). \ : group @@ -960,7 +961,7 @@ the teardown commands are executed sequentially and in the order specified. Again, if any of them fail, the group execution is terminated and the group is considered to have failed. -As an example, consider the following version of \c{basics.test}: +As an example, consider the following version of \c{basics.testscript}: \ test0 @@ -1016,7 +1017,7 @@ for this example: A testscript would normally contain multiple tests and sometimes it is desirable to only execute a specific test or a group of tests. For example, you may be debugging a failing test and would like to re-run it. As an -example, consider the following testscript file called \c{basics.test}: +example, consider the following testscript file called \c{basics.testscript}: \ $* foo : foo @@ -1037,10 +1038,10 @@ basics/fox/baz \ To only run individual tests, test groups, or testscript files we can specify -their id paths in the \c{config.test} variable, for example: +their id paths in the \c{config.testscript} variable, for example: \ -$ b test config.test=basics # All in basics.test +$ b test config.test=basics # All in basics.testscript $ b test config.test=basics/fox # All in fox $ b test config.test=basics/foo # Only foo $ b test 'config.test=basics/foo basics/fox/bar' # Only foo and bar @@ -1624,7 +1625,7 @@ variable is assigned. You can, however, use variables assigned in the buildfile. For example: \ -include common-$(cxx.target.class).test +include common-$(cxx.target.class).testscript \ \h2#syntax-directive-include|Include| @@ -2827,9 +2828,9 @@ tests. It is also a good idea to give the summary of the group, for example: \ In the same vein, don't repeat the testscript id in group or test ids. For -example, if the above tests were in the \c{greeting.test} testscript, then -using \c{custom-greeting} as the group id would be unnecessarily repetitive -since the id path would then become \c{greeting/custom-greeting/john}, etc. +example, if the above tests were in \c{greeting.testscript}, then using +\c{custom-greeting} as the group id would be unnecessarily repetitive since +the id path would then become \c{greeting/custom-greeting/john}, etc. We quote values that are \i{strings} as opposed to options, file names, paths (unless contain spaces), integers, or boolean. When quoting, use the single diff --git a/tests/bash/testscript b/tests/bash/testscript index 39f247b..11f50c7 100644 --- a/tests/bash/testscript +++ b/tests/bash/testscript @@ -11,7 +11,7 @@ if ($test.target == $build.host && $build.host.class != 'windows') buildfile = true test.arguments = - .include ../common.test + .include ../common.testscript +cat <+build/bootstrap.build using test diff --git a/tests/build/root.build b/tests/build/root.build index 6e4fea9..749e6c3 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -13,7 +13,7 @@ cxx{*}: extension = cxx # as our $build.path). # import b = build2%exe{b} -test{*}: test = $b +testscript{*}: test = $b # Specify the test target for cross-testing. # diff --git a/tests/buildfile b/tests/buildfile index 092b2ad..e53cbc9 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: {*/ -build/} file{common.test} +./: {*/ -build/} file{common.testscript} diff --git a/tests/cc/libu/testscript b/tests/cc/libu/testscript index 4552141..66424b8 100644 --- a/tests/cc/libu/testscript +++ b/tests/cc/libu/testscript @@ -5,7 +5,7 @@ crosstest = false test.arguments = config.cxx="$recall($cxx.path)" -.include ../../common.test +.include ../../common.testscript +cat <+build/bootstrap.build using test diff --git a/tests/cc/modules/testscript b/tests/cc/modules/testscript index 4401bfd..ea7bd97 100644 --- a/tests/cc/modules/testscript +++ b/tests/cc/modules/testscript @@ -5,7 +5,7 @@ crosstest = false test.arguments = config.cxx="$recall($cxx.path)" -.include ../../common.test +.include ../../common.testscript +cat <+build/bootstrap.build using test diff --git a/tests/cc/preprocessed/testscript b/tests/cc/preprocessed/testscript index 2c20d3f..853d563 100644 --- a/tests/cc/preprocessed/testscript +++ b/tests/cc/preprocessed/testscript @@ -5,7 +5,7 @@ crosstest = false test.arguments = config.cxx="$recall($cxx.path)" update -.include ../../common.test +.include ../../common.testscript # Trace filter. # diff --git a/tests/common.test b/tests/common.test deleted file mode 100644 index 586e793..0000000 --- a/tests/common.test +++ /dev/null @@ -1,45 +0,0 @@ -# file : tests/common.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Commonly-used build system test project setup and driver command line. -# - -# If the includer indicated that no cross-testing should be supported, then -# use the build system driver that is building, not the one being built. -# -# In many cases expecting a cross-compiled driver to perform a native build -# under emulation is pushing things a bit too far. Plus, we have no way of -# knowing the native compiler name/path. -# -# So the idea here is to test cross-compilation with the understanding that -# the build system driver we are testing is not the one being cross-compiled -# but rather the one doing the cross-compilation. -# -if ($null($crosstest)) - crosstest = true -end - -if (!$crosstest && $test.target != $build.host) - test = $recall($build.path) -end - -# Common bootstrap.build. -# -+mkdir build -+cat <=build/bootstrap.build -project = test -amalgamation = -EOI - -test.options += --serial-stop --quiet - -if ($null($buildfile) || !$buildfile) - test.options += --buildfile - -end - -# By default just load the buildfile. -# -if ($null($test.arguments)) - test.arguments = noop -end diff --git a/tests/common.testscript b/tests/common.testscript new file mode 100644 index 0000000..369c798 --- /dev/null +++ b/tests/common.testscript @@ -0,0 +1,45 @@ +# file : tests/common.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Commonly-used build system test project setup and driver command line. +# + +# If the includer indicated that no cross-testing should be supported, then +# use the build system driver that is building, not the one being built. +# +# In many cases expecting a cross-compiled driver to perform a native build +# under emulation is pushing things a bit too far. Plus, we have no way of +# knowing the native compiler name/path. +# +# So the idea here is to test cross-compilation with the understanding that +# the build system driver we are testing is not the one being cross-compiled +# but rather the one doing the cross-compilation. +# +if ($null($crosstest)) + crosstest = true +end + +if (!$crosstest && $test.target != $build.host) + test = $recall($build.path) +end + +# Common bootstrap.build. +# ++mkdir build ++cat <=build/bootstrap.build +project = test +amalgamation = +EOI + +test.options += --serial-stop --quiet + +if ($null($buildfile) || !$buildfile) + test.options += --buildfile - +end + +# By default just load the buildfile. +# +if ($null($test.arguments)) + test.arguments = noop +end diff --git a/tests/directive/assert.test b/tests/directive/assert.test deleted file mode 100644 index 2d70573..0000000 --- a/tests/directive/assert.test +++ /dev/null @@ -1,28 +0,0 @@ -# file : tests/directive/assert.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -$* <'assert true' : true -$* <'assert! false foo' : not-false -$* <'assert true $no_such_function()' : skip-line -$* <'assert! $empty($build.version)' : expr - -: false -: -$* <'assert false' 2>>EOE != 0 -:1:1: error: assertion failed -EOE - -: false-desc -: -$* <'assert false bad thing happened: (a == b)' 2>>EOE != 0 -:1:1: error: assertion failed: bad thing happened: false -EOE - -: invalid -: -$* <'assert junk' 2>>EOE != 0 -:1:8: error: invalid bool value: 'junk' -EOE diff --git a/tests/directive/assert.testscript b/tests/directive/assert.testscript new file mode 100644 index 0000000..ffe6aa0 --- /dev/null +++ b/tests/directive/assert.testscript @@ -0,0 +1,28 @@ +# file : tests/directive/assert.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +$* <'assert true' : true +$* <'assert! false foo' : not-false +$* <'assert true $no_such_function()' : skip-line +$* <'assert! $empty($build.version)' : expr + +: false +: +$* <'assert false' 2>>EOE != 0 +:1:1: error: assertion failed +EOE + +: false-desc +: +$* <'assert false bad thing happened: (a == b)' 2>>EOE != 0 +:1:1: error: assertion failed: bad thing happened: false +EOE + +: invalid +: +$* <'assert junk' 2>>EOE != 0 +:1:8: error: invalid bool value: 'junk' +EOE diff --git a/tests/directive/buildfile b/tests/directive/buildfile index c03a08d..ac4c752 100644 --- a/tests/directive/buildfile +++ b/tests/directive/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/directive/run.test b/tests/directive/run.test deleted file mode 100644 index 30d4a6a..0000000 --- a/tests/directive/run.test +++ /dev/null @@ -1,37 +0,0 @@ -# file : tests/directive/run.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# We are going to run the build system driver so no cross-testing. -# -crosstest = false - -.include ../common.test - -: no-output -: -cat <'assert true' >=buildfile; -$* <"run '$0' noop" - -: output -: -cat <'print foo=bar' >=buildfile; -$* <<"EOI" >'bar' -run '$0' noop -print \$foo -EOI - -: bad-exit -: -cat <'assert false' >=buildfile; -$* <"run '$0' noop" 2>>EOE != 0 -buildfile:1:1: error: assertion failed -EOE - -: bad-output -: -cat <'print run' >=buildfile; -$* <"run '$0' noop" 2>>"EOE" != 0 -:1:4: error: executable name expected after run - :1:5: info: while parsing $0 output -EOE diff --git a/tests/directive/run.testscript b/tests/directive/run.testscript new file mode 100644 index 0000000..ba4a413 --- /dev/null +++ b/tests/directive/run.testscript @@ -0,0 +1,37 @@ +# file : tests/directive/run.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# We are going to run the build system driver so no cross-testing. +# +crosstest = false + +.include ../common.testscript + +: no-output +: +cat <'assert true' >=buildfile; +$* <"run '$0' noop" + +: output +: +cat <'print foo=bar' >=buildfile; +$* <<"EOI" >'bar' +run '$0' noop +print \$foo +EOI + +: bad-exit +: +cat <'assert false' >=buildfile; +$* <"run '$0' noop" 2>>EOE != 0 +buildfile:1:1: error: assertion failed +EOE + +: bad-output +: +cat <'print run' >=buildfile; +$* <"run '$0' noop" 2>>"EOE" != 0 +:1:4: error: executable name expected after run + :1:5: info: while parsing $0 output +EOE diff --git a/tests/eval/buildfile b/tests/eval/buildfile index 8fa0064..f7fa2d5 100644 --- a/tests/eval/buildfile +++ b/tests/eval/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/eval/comma.test b/tests/eval/comma.test deleted file mode 100644 index 1a36dd1..0000000 --- a/tests/eval/comma.test +++ /dev/null @@ -1,13 +0,0 @@ -# file : tests/eval/comma.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test value packs (eval-comma). - -.include ../common.test - -: comma -: -$* <'print (foo, bar)' 2>>EOE != 0 -:1:7: error: expected single value -EOE diff --git a/tests/eval/comma.testscript b/tests/eval/comma.testscript new file mode 100644 index 0000000..bb748d1 --- /dev/null +++ b/tests/eval/comma.testscript @@ -0,0 +1,13 @@ +# file : tests/eval/comma.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test value packs (eval-comma). + +.include ../common.testscript + +: comma +: +$* <'print (foo, bar)' 2>>EOE != 0 +:1:7: error: expected single value +EOE diff --git a/tests/eval/comp.test b/tests/eval/comp.test deleted file mode 100644 index c1a4cf7..0000000 --- a/tests/eval/comp.test +++ /dev/null @@ -1,47 +0,0 @@ -# file : tests/eval/comp.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test comparison operators (eval-comp). - -.include ../common.test - -$* <'print (foo == bar)' >'false' : eq-false -$* <'print (foo == foo)' >'true' : eq-true - -$* <'print (foo != foo)' >'false' : ne-false -$* <'print (foo != bar)' >'true' : ne-true - -$* <'print (foo < bar)' >'false' : lt-false -$* <'print (bar < foo)' >'true' : lt-true - -$* <'print (bar > foo)' >'false' : gt-false -$* <'print (foo > bar)' >'true' : gt-true - -$* <'print (foo <= bar)' >'false' : le-false -$* <'print (bar <= foo)' >'true' : le-true -$* <'print (bar <= bar)' >'true' : le-true-eq - -$* <'print (bar >= foo)' >'false' : ge-false -$* <'print (foo >= bar)' >'true' : ge-true -$* <'print (foo >= foo)' >'true' : ge-true-eq - -: associativity -: -$* <'print (foo == bar == false)' >'true' - -: type -: -{ - $* <'print ((foo bar) == foo bar)' >'true' : untyped-list - $* <'print ("" == "")' >'true' : untyped-empty - - $* <'print (0 < 00)' >'true' : untyped-untyped - $* <'print (0 < [null])' >'false' : untyped-null - $* <'print ([uint64] 00 < 0)' >'false' : uint64-untyped - $* <'print ([uint64] 00 < [null])' >'false' : uint64-null - $* <'print ([uint64] 00 < [uint64] 0)' >'false' : uint64-uint64 - $* <'print ([uint64] 00 < [string] 0)' 2>>EOE != 0 : uint64-string - :1:20: error: comparison between uint64 and string - EOE -} diff --git a/tests/eval/comp.testscript b/tests/eval/comp.testscript new file mode 100644 index 0000000..481c50b --- /dev/null +++ b/tests/eval/comp.testscript @@ -0,0 +1,47 @@ +# file : tests/eval/comp.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test comparison operators (eval-comp). + +.include ../common.testscript + +$* <'print (foo == bar)' >'false' : eq-false +$* <'print (foo == foo)' >'true' : eq-true + +$* <'print (foo != foo)' >'false' : ne-false +$* <'print (foo != bar)' >'true' : ne-true + +$* <'print (foo < bar)' >'false' : lt-false +$* <'print (bar < foo)' >'true' : lt-true + +$* <'print (bar > foo)' >'false' : gt-false +$* <'print (foo > bar)' >'true' : gt-true + +$* <'print (foo <= bar)' >'false' : le-false +$* <'print (bar <= foo)' >'true' : le-true +$* <'print (bar <= bar)' >'true' : le-true-eq + +$* <'print (bar >= foo)' >'false' : ge-false +$* <'print (foo >= bar)' >'true' : ge-true +$* <'print (foo >= foo)' >'true' : ge-true-eq + +: associativity +: +$* <'print (foo == bar == false)' >'true' + +: type +: +{ + $* <'print ((foo bar) == foo bar)' >'true' : untyped-list + $* <'print ("" == "")' >'true' : untyped-empty + + $* <'print (0 < 00)' >'true' : untyped-untyped + $* <'print (0 < [null])' >'false' : untyped-null + $* <'print ([uint64] 00 < 0)' >'false' : uint64-untyped + $* <'print ([uint64] 00 < [null])' >'false' : uint64-null + $* <'print ([uint64] 00 < [uint64] 0)' >'false' : uint64-uint64 + $* <'print ([uint64] 00 < [string] 0)' 2>>EOE != 0 : uint64-string + :1:20: error: comparison between uint64 and string + EOE +} diff --git a/tests/eval/or-and.test b/tests/eval/or-and.test deleted file mode 100644 index 796f92a..0000000 --- a/tests/eval/or-and.test +++ /dev/null @@ -1,28 +0,0 @@ -# file : tests/eval/or-and.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test logical operators (eval-or, eval-and). - -.include ../common.test - -$* <'print (false || false)' >'false' : or-false -$* <'print (false || true)' >'true' : or-true-1 -$* <'print (true || false)' >'true' : or-true-2 - -$* <'print (false && true)' >'false' : and-false-1 -$* <'print (true && false)' >'false' : and-false-2 -$* <'print (true && true)' >'true' : and-true - -: associativity -: -: Also tests short-circuit. -: -{ - $* <'print (true || $bogus($foo) || false)' >'true' : or - $* <'print (false && $bogus($foo) && false)' >'false' : and -} - -: priority -: -$* <'print (false && true || true)' >'true' diff --git a/tests/eval/or-and.testscript b/tests/eval/or-and.testscript new file mode 100644 index 0000000..7796f74 --- /dev/null +++ b/tests/eval/or-and.testscript @@ -0,0 +1,28 @@ +# file : tests/eval/or-and.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test logical operators (eval-or, eval-and). + +.include ../common.testscript + +$* <'print (false || false)' >'false' : or-false +$* <'print (false || true)' >'true' : or-true-1 +$* <'print (true || false)' >'true' : or-true-2 + +$* <'print (false && true)' >'false' : and-false-1 +$* <'print (true && false)' >'false' : and-false-2 +$* <'print (true && true)' >'true' : and-true + +: associativity +: +: Also tests short-circuit. +: +{ + $* <'print (true || $bogus($foo) || false)' >'true' : or + $* <'print (false && $bogus($foo) && false)' >'false' : and +} + +: priority +: +$* <'print (false && true || true)' >'true' diff --git a/tests/eval/qual.test b/tests/eval/qual.test deleted file mode 100644 index babd956..0000000 --- a/tests/eval/qual.test +++ /dev/null @@ -1,28 +0,0 @@ -# file : tests/eval/qual.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test qualified name (eval-qual). - -.include ../common.test - -$* <'print (file{foo}: bar)' >'file{foo}:bar' : target -$* <'print (foo/dir{}: bar)' >'dir{foo/}:bar' : scope - -: attribute -: -$* <'([string] foo:bar)' 2>>EOE != 0 -:1:2: error: attributes before target-qualified variable name -EOE - -: leader -: -$* <'(foo == foo:bar)' 2>>EOE != 0 -:1:12: error: unexpected ':' -EOE - -: trailer -: -$* <'(foo:bar == foo)' 2>>EOE != 0 -:1:10: error: expected ')' after variable name -EOE diff --git a/tests/eval/qual.testscript b/tests/eval/qual.testscript new file mode 100644 index 0000000..e7bf472 --- /dev/null +++ b/tests/eval/qual.testscript @@ -0,0 +1,28 @@ +# file : tests/eval/qual.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test qualified name (eval-qual). + +.include ../common.testscript + +$* <'print (file{foo}: bar)' >'file{foo}:bar' : target +$* <'print (foo/dir{}: bar)' >'dir{foo/}:bar' : scope + +: attribute +: +$* <'([string] foo:bar)' 2>>EOE != 0 +:1:2: error: attributes before target-qualified variable name +EOE + +: leader +: +$* <'(foo == foo:bar)' 2>>EOE != 0 +:1:12: error: unexpected ':' +EOE + +: trailer +: +$* <'(foo:bar == foo)' 2>>EOE != 0 +:1:10: error: expected ')' after variable name +EOE diff --git a/tests/eval/ternary.test b/tests/eval/ternary.test deleted file mode 100644 index a220110..0000000 --- a/tests/eval/ternary.test +++ /dev/null @@ -1,30 +0,0 @@ -# file : tests/eval/ternary.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test the ternary operator (eval-ternary). - -.include ../common.test - -$* <'print (true ? foo : bar)' >'foo' : true -$* <'print (false ? foo : bar)' >'bar' : false - -: associativity -: -{ - $* <'print (true ? false ? foo : bar : baz)' >'bar' : middle - $* <'print (true ? foo : true ? bar : baz)' >'foo' : right - $* <'print (true ? false ? foo : bar : true ? baz : fox)' >'bar' : both - $* <'print (false ? foo ? false ? bar : false : baz : fox)' >'fox' : chain -} - -: short-circuit -: -{ - $* <'print (false ? $bogus() : foo)' >'foo' : middle - $* <'print (true ? foo : $bogus())' >'foo' : right - - # @@ TODO: complate pre-parse support in parse_name(). - # - #$* <'print (true ? foo : $out_base/{foo bar})' >'foo' : pre-parse -} diff --git a/tests/eval/ternary.testscript b/tests/eval/ternary.testscript new file mode 100644 index 0000000..fc405e5 --- /dev/null +++ b/tests/eval/ternary.testscript @@ -0,0 +1,30 @@ +# file : tests/eval/ternary.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test the ternary operator (eval-ternary). + +.include ../common.testscript + +$* <'print (true ? foo : bar)' >'foo' : true +$* <'print (false ? foo : bar)' >'bar' : false + +: associativity +: +{ + $* <'print (true ? false ? foo : bar : baz)' >'bar' : middle + $* <'print (true ? foo : true ? bar : baz)' >'foo' : right + $* <'print (true ? false ? foo : bar : true ? baz : fox)' >'bar' : both + $* <'print (false ? foo ? false ? bar : false : baz : fox)' >'fox' : chain +} + +: short-circuit +: +{ + $* <'print (false ? $bogus() : foo)' >'foo' : middle + $* <'print (true ? foo : $bogus())' >'foo' : right + + # @@ TODO: complate pre-parse support in parse_name(). + # + #$* <'print (true ? foo : $out_base/{foo bar})' >'foo' : pre-parse +} diff --git a/tests/eval/value.test b/tests/eval/value.test deleted file mode 100644 index a3e1d4c..0000000 --- a/tests/eval/value.test +++ /dev/null @@ -1,23 +0,0 @@ -# file : tests/eval/value.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test value part of the grammar (eval-value). - -.include ../common.test - -$* <'print (foo)' >'foo' : value -$* <'print ()' >'' : value-empty -$* <'print ((foo bar))' >'foo bar' : eval -$* <'print (!false)' >'true' : not -$* <'print (!!true)' >'true' : not-double - -: attribute -: -{ - $* <'print $type([string] foo)' >'string' : type - $* <'print ([uint64] 001)' >'1' : value - $* <'print $null([null])' >'true' : null - $* <'print $type([string] (foo == bar))' >'string' : eval - $* <'print $type([string] !true)' >'string' : not -} diff --git a/tests/eval/value.testscript b/tests/eval/value.testscript new file mode 100644 index 0000000..7cae6e2 --- /dev/null +++ b/tests/eval/value.testscript @@ -0,0 +1,23 @@ +# file : tests/eval/value.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test value part of the grammar (eval-value). + +.include ../common.testscript + +$* <'print (foo)' >'foo' : value +$* <'print ()' >'' : value-empty +$* <'print ((foo bar))' >'foo bar' : eval +$* <'print (!false)' >'true' : not +$* <'print (!!true)' >'true' : not-double + +: attribute +: +{ + $* <'print $type([string] foo)' >'string' : type + $* <'print ([uint64] 001)' >'1' : value + $* <'print $null([null])' >'true' : null + $* <'print $type([string] (foo == bar))' >'string' : eval + $* <'print $type([string] !true)' >'string' : not +} diff --git a/tests/expansion/buildfile b/tests/expansion/buildfile index c144c23..7a73b9d 100644 --- a/tests/expansion/buildfile +++ b/tests/expansion/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/expansion/concat.test b/tests/expansion/concat.test deleted file mode 100644 index baaf1e1..0000000 --- a/tests/expansion/concat.test +++ /dev/null @@ -1,28 +0,0 @@ -# file : tests/expansion/type.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test concatenated expansion. - -.include ../common.test - -: typed-exceptions -: -$* <>/EOO -d = [dir_path] dir -s = [string] foo - -print $d/{bar} -print $s{bar} -print $d/$s{bar} -print file{x$s} -print $d/{x$s} -print prj%{x$s} -EOI -dir/bar -foo{bar} -dir/foo{bar} -file{xfoo} -dir/xfoo -prj%xfoo -EOO diff --git a/tests/expansion/concat.testscript b/tests/expansion/concat.testscript new file mode 100644 index 0000000..75487b5 --- /dev/null +++ b/tests/expansion/concat.testscript @@ -0,0 +1,28 @@ +# file : tests/expansion/type.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test concatenated expansion. + +.include ../common.testscript + +: typed-exceptions +: +$* <>/EOO +d = [dir_path] dir +s = [string] foo + +print $d/{bar} +print $s{bar} +print $d/$s{bar} +print file{x$s} +print $d/{x$s} +print prj%{x$s} +EOI +dir/bar +foo{bar} +dir/foo{bar} +file{xfoo} +dir/xfoo +prj%xfoo +EOO diff --git a/tests/expansion/type.test b/tests/expansion/type.test deleted file mode 100644 index 8899aa3..0000000 --- a/tests/expansion/type.test +++ /dev/null @@ -1,50 +0,0 @@ -# file : tests/expansion/type.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test type propagation during expansion. - -.include ../common.test - -: var -: -$* <'true' - -: retypify-quote -: -$* <'print [bool] "([string] true)"' >'true' - -: retypify-name -: Test the "steal" case of untypify() -: -$* <'print [bool] "([name] true)"' >'true' diff --git a/tests/expansion/type.testscript b/tests/expansion/type.testscript new file mode 100644 index 0000000..12204a3 --- /dev/null +++ b/tests/expansion/type.testscript @@ -0,0 +1,50 @@ +# file : tests/expansion/type.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test type propagation during expansion. + +.include ../common.testscript + +: var +: +$* <'true' + +: retypify-quote +: +$* <'print [bool] "([string] true)"' >'true' + +: retypify-name +: Test the "steal" case of untypify() +: +$* <'print [bool] "([name] true)"' >'true' diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript index d15eeb3..e54fb0f 100644 --- a/tests/function/builtin/testscript +++ b/tests/function/builtin/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : type : diff --git a/tests/function/filesystem/testscript b/tests/function/filesystem/testscript index 7dcfde9..42c09db 100644 --- a/tests/function/filesystem/testscript +++ b/tests/function/filesystem/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : path-search : diff --git a/tests/function/install/testscript b/tests/function/install/testscript index 73aba00..e2afc39 100644 --- a/tests/function/install/testscript +++ b/tests/function/install/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript +cat <+build/bootstrap.build using config diff --git a/tests/function/path/testscript b/tests/function/path/testscript index 8446bf0..84a1cc1 100644 --- a/tests/function/path/testscript +++ b/tests/function/path/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript s = ($cxx.target.class != 'windows' ? '/' : '\') diff --git a/tests/function/process/testscript b/tests/function/process/testscript index f01af6f..d4fe864 100644 --- a/tests/function/process/testscript +++ b/tests/function/process/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : run : diff --git a/tests/function/regex/testscript b/tests/function/regex/testscript index 28d6c8e..4d48e04 100644 --- a/tests/function/regex/testscript +++ b/tests/function/regex/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : replace : diff --git a/tests/hooks/testscript b/tests/hooks/testscript index f0d5c14..92c9964 100644 --- a/tests/hooks/testscript +++ b/tests/hooks/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../common.test +.include ../common.testscript +cat <'print bootstrap' >+build/bootstrap.build +cat <'print root' >=build/root.build diff --git a/tests/in/testscript b/tests/in/testscript index 3e06137..9b4b38a 100644 --- a/tests/in/testscript +++ b/tests/in/testscript @@ -5,7 +5,7 @@ crosstest = false test.arguments = -.include ../common.test +.include ../common.testscript +cat <=build/root.build using in diff --git a/tests/loop/buildfile b/tests/loop/buildfile index e583492..3807ddf 100644 --- a/tests/loop/buildfile +++ b/tests/loop/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/loop/for.test b/tests/loop/for.test deleted file mode 100644 index 66bfc80..0000000 --- a/tests/loop/for.test +++ /dev/null @@ -1,112 +0,0 @@ -# file : tests/loop/for.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test for-loop. - -.include ../common.test - -: line -: -$* <>EOO -for i: 1 2 3 - print $i -EOI -1 -2 -3 -EOO - -: block -: -$* <>EOO -for i: 1 2 3 -{ - # This is a block if you haven't noticed. - j = $i - print $j -} -EOI -1 -2 -3 -EOO - -: empty -: -$* <>EOO -for i: 1 2 3 -{ - for j: + - - { - print $j$i - } -} -EOI -+1 --1 -+2 --2 -+3 --3 -EOO - -: diag-line -: -$* <>EOE != 0 -for i: true false -{ - assert $i -} -EOI -:3:3: error: assertion failed -EOE - -: var-attribute -: -$* <>EOO -for [uint64] i: 0 1 2 -{ - i += 1 - print $i -} -EOI -1 -2 -3 -EOO - -: val-attribute -: -$* <>EOO -for i: [uint64s] 0 1 2 -{ - i += 1 - print $i -} -EOI -1 -2 -3 -EOO - -: pairs -: -$* <>EOO -for i: a@1 b@2 c@3 - print $i -EOI -a@1 -b@2 -c@3 -EOO diff --git a/tests/loop/for.testscript b/tests/loop/for.testscript new file mode 100644 index 0000000..6aec1b2 --- /dev/null +++ b/tests/loop/for.testscript @@ -0,0 +1,112 @@ +# file : tests/loop/for.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test for-loop. + +.include ../common.testscript + +: line +: +$* <>EOO +for i: 1 2 3 + print $i +EOI +1 +2 +3 +EOO + +: block +: +$* <>EOO +for i: 1 2 3 +{ + # This is a block if you haven't noticed. + j = $i + print $j +} +EOI +1 +2 +3 +EOO + +: empty +: +$* <>EOO +for i: 1 2 3 +{ + for j: + - + { + print $j$i + } +} +EOI ++1 +-1 ++2 +-2 ++3 +-3 +EOO + +: diag-line +: +$* <>EOE != 0 +for i: true false +{ + assert $i +} +EOI +:3:3: error: assertion failed +EOE + +: var-attribute +: +$* <>EOO +for [uint64] i: 0 1 2 +{ + i += 1 + print $i +} +EOI +1 +2 +3 +EOO + +: val-attribute +: +$* <>EOO +for i: [uint64s] 0 1 2 +{ + i += 1 + print $i +} +EOI +1 +2 +3 +EOO + +: pairs +: +$* <>EOO +for i: a@1 b@2 c@3 + print $i +EOI +a@1 +b@2 +c@3 +EOO diff --git a/tests/name/buildfile b/tests/name/buildfile index 4449a1f..1253202 100644 --- a/tests/name/buildfile +++ b/tests/name/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/name/cross.test b/tests/name/cross.test deleted file mode 100644 index 009b851..0000000 --- a/tests/name/cross.test +++ /dev/null @@ -1,115 +0,0 @@ -# file : tests/name/cross.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define foo: file -define bar: file - -foo{*}: extension = foo -bar{*}: extension = bar -EOI - -: separation -: -{ - $* <'print fox/ {bar baz}' >'fox/ bar baz' : dir - $* <'print foo {bar baz}' >'foo bar baz' : type - $* <'print fox/foo {bar baz}' >'fox/foo bar baz' : dir-type -} - -: type -: -{ - $* <'print {}{bar}' >'bar' - $* <'print {foo}{}' >'foo{}' - $* <'print {foo}{bar}' >'foo{bar}' - $* <'print {foo}{bar baz}' >'foo{bar} foo{baz}' - $* <'print {foo fox}{bar}' >'foo{bar} fox{bar}' - $* <'print {foo fox}{bar baz}' >'foo{bar} foo{baz} fox{bar} fox{baz}' -} - -: dir -: -{ - $* <'print dir/{}{bar}' >'dir/bar' - $* <'print dir/{foo}{}' >'foo{dir/}' - $* <'print dir/{foo}{bar}' >'dir/foo{bar}' - $* <'print dir/{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print dir/{foo fox}{bar}' >'dir/foo{bar} dir/fox{bar}' - $* <'print dir/{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz}' - - $* <'print {dir/}{bar}' >'dir/bar' - $* <'print {dir/}{bar baz}' >'dir/bar dir/baz' - $* <'print {dir/ dor/}{bar}' >'dir/bar dor/bar' - $* <'print {dir/ dor/}{bar baz}' >'dir/bar dir/baz dor/bar dor/baz' -} - -: dir-type -: -{ - $* <'print {dir/foo}{bar}' >'dir/foo{bar}' - $* <'print {dir/foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print {dir/foo dor/fox}{bar}' >'dir/foo{bar} dor/fox{bar}' - $* <'print {dir/foo dor/fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dor/fox{bar} dor/fox{baz}' - - $* <'print {dir/}{foo}{bar}' >'dir/foo{bar}' - $* <'print {dir/}{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' - $* <'print {dir/ dor/}{foo}{bar}' >'dir/foo{bar} dor/foo{bar}' - $* <'print {dir/ dor/}{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz} dor/foo{bar} dor/foo{baz} dor/fox{bar} dor/fox{baz}' -} - -: proj -: -{ - $* <'print {prj%foo}{bar baz}' >'prj%foo{bar} prj%foo{baz}' - $* <'print {foo}{bar prj%baz}' >'foo{bar} prj%foo{baz}' - - $* <'print {prj%foo}{bar prk%baz}' 2>>EOE != 0 - :1:21: error: nested project name prk - EOE -} - -: merge -: -{ - $* <'print {foo}{bar dir/{baz}}' >'foo{bar} dir/foo{baz}' - $* <'print dir/{foo}{bar dor/{baz}}' >'dir/foo{bar} dir/dor/foo{baz}' - - $* <'print {dir/foo{}}{bar}' >'dir/foo{bar}' - $* <'print {dir/{foo}}{bar}' >'dir/foo{bar}' - $* <'print {dir/}{foo{bar}}' >'dir/foo{bar}' - - $* <'print {dir/foo{fox}}{bar}' 2>>EOE != 0 - :1:22: error: nested type name fox - EOE - - $* <'print {dir/foo}{fox{bar}}' 2>>EOE != 0 - :1:20: error: nested type name fox - EOE -} - -: pair -: -{ - $* <'print x@{dir/ dor/}{foo fox}{bar baz}' >'x@dir/foo{bar} x@dir/foo{baz} x@dir/fox{bar} x@dir/fox{baz} x@dor/foo{bar} x@dor/foo{baz} x@dor/fox{bar} x@dor/fox{baz}' -} - -: pattern -: -{ - touch x.foo y.bar; - $* <'print {foo bar}{*}' >'foo{x} bar{y}' - - mkdir dir && touch dir/x.foo; - $* <'print {*/}{*.foo}' >/'dir/x.foo' - - mkdir dir && touch dir/x.foo; - $* <'print {*/}{foo}{*}' >/'dir/foo{x}' -} - -# @@ TODO: nested replay. -# -#file{foo} file{bar}: x = {foo fox}{bar baz} diff --git a/tests/name/cross.testscript b/tests/name/cross.testscript new file mode 100644 index 0000000..d625a2c --- /dev/null +++ b/tests/name/cross.testscript @@ -0,0 +1,115 @@ +# file : tests/name/cross.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define foo: file +define bar: file + +foo{*}: extension = foo +bar{*}: extension = bar +EOI + +: separation +: +{ + $* <'print fox/ {bar baz}' >'fox/ bar baz' : dir + $* <'print foo {bar baz}' >'foo bar baz' : type + $* <'print fox/foo {bar baz}' >'fox/foo bar baz' : dir-type +} + +: type +: +{ + $* <'print {}{bar}' >'bar' + $* <'print {foo}{}' >'foo{}' + $* <'print {foo}{bar}' >'foo{bar}' + $* <'print {foo}{bar baz}' >'foo{bar} foo{baz}' + $* <'print {foo fox}{bar}' >'foo{bar} fox{bar}' + $* <'print {foo fox}{bar baz}' >'foo{bar} foo{baz} fox{bar} fox{baz}' +} + +: dir +: +{ + $* <'print dir/{}{bar}' >'dir/bar' + $* <'print dir/{foo}{}' >'foo{dir/}' + $* <'print dir/{foo}{bar}' >'dir/foo{bar}' + $* <'print dir/{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print dir/{foo fox}{bar}' >'dir/foo{bar} dir/fox{bar}' + $* <'print dir/{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz}' + + $* <'print {dir/}{bar}' >'dir/bar' + $* <'print {dir/}{bar baz}' >'dir/bar dir/baz' + $* <'print {dir/ dor/}{bar}' >'dir/bar dor/bar' + $* <'print {dir/ dor/}{bar baz}' >'dir/bar dir/baz dor/bar dor/baz' +} + +: dir-type +: +{ + $* <'print {dir/foo}{bar}' >'dir/foo{bar}' + $* <'print {dir/foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print {dir/foo dor/fox}{bar}' >'dir/foo{bar} dor/fox{bar}' + $* <'print {dir/foo dor/fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dor/fox{bar} dor/fox{baz}' + + $* <'print {dir/}{foo}{bar}' >'dir/foo{bar}' + $* <'print {dir/}{foo}{bar baz}' >'dir/foo{bar} dir/foo{baz}' + $* <'print {dir/ dor/}{foo}{bar}' >'dir/foo{bar} dor/foo{bar}' + $* <'print {dir/ dor/}{foo fox}{bar baz}' >'dir/foo{bar} dir/foo{baz} dir/fox{bar} dir/fox{baz} dor/foo{bar} dor/foo{baz} dor/fox{bar} dor/fox{baz}' +} + +: proj +: +{ + $* <'print {prj%foo}{bar baz}' >'prj%foo{bar} prj%foo{baz}' + $* <'print {foo}{bar prj%baz}' >'foo{bar} prj%foo{baz}' + + $* <'print {prj%foo}{bar prk%baz}' 2>>EOE != 0 + :1:21: error: nested project name prk + EOE +} + +: merge +: +{ + $* <'print {foo}{bar dir/{baz}}' >'foo{bar} dir/foo{baz}' + $* <'print dir/{foo}{bar dor/{baz}}' >'dir/foo{bar} dir/dor/foo{baz}' + + $* <'print {dir/foo{}}{bar}' >'dir/foo{bar}' + $* <'print {dir/{foo}}{bar}' >'dir/foo{bar}' + $* <'print {dir/}{foo{bar}}' >'dir/foo{bar}' + + $* <'print {dir/foo{fox}}{bar}' 2>>EOE != 0 + :1:22: error: nested type name fox + EOE + + $* <'print {dir/foo}{fox{bar}}' 2>>EOE != 0 + :1:20: error: nested type name fox + EOE +} + +: pair +: +{ + $* <'print x@{dir/ dor/}{foo fox}{bar baz}' >'x@dir/foo{bar} x@dir/foo{baz} x@dir/fox{bar} x@dir/fox{baz} x@dor/foo{bar} x@dor/foo{baz} x@dor/fox{bar} x@dor/fox{baz}' +} + +: pattern +: +{ + touch x.foo y.bar; + $* <'print {foo bar}{*}' >'foo{x} bar{y}' + + mkdir dir && touch dir/x.foo; + $* <'print {*/}{*.foo}' >/'dir/x.foo' + + mkdir dir && touch dir/x.foo; + $* <'print {*/}{foo}{*}' >/'dir/foo{x}' +} + +# @@ TODO: nested replay. +# +#file{foo} file{bar}: x = {foo fox}{bar baz} diff --git a/tests/name/extension.test b/tests/name/extension.test deleted file mode 100644 index 160c427..0000000 --- a/tests/name/extension.test +++ /dev/null @@ -1,86 +0,0 @@ -# file : tests/name/extension.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define txt: file -txt{*}: extension = txt -EOI - -: name -: -{ - test.arguments = --match-only update - - : unspecified - : - touch foo.txt; - $* <'./: txt{foo}' - - : specified - : - touch foo.text; - $* <'./: txt{foo.text}' - - : specified-none - : - touch foo; - $* <'./: txt{foo.}' - - : specified-default - : - touch foo.test.txt; - $* <'./: txt{foo.test...}' - - # Trailing dots are not allowed on Windows. - # - - : specified-escape-one - : - if ($cxx.target.class != 'windows') - { - touch foo.; - $* <'./: txt{foo..}' - } - - : specified-escape-two - : - if ($cxx.target.class != 'windows') - { - touch foo..; - $* <'./: txt{foo....}' - } - - : specified-invalid - : - $* <'./: txt{foo.....}' 2>>EOE != 0 - :1:5: error: invalid trailing dot sequence in target name 'foo.....' - EOE -} - -: pattern -: -{ - : specified-none - : - touch foo; - $* <'print txt{fo?.}' >'txt{foo.}' - - : specified-default - : - touch foo.test.txt; - $* <'print txt{fo?.test...}' >'txt{foo.test...}' - - # Trailing dots are not allowed on Windows. - # - - : specified-escape - : - if ($cxx.target.class != 'windows') - { - touch foo.; - $* <'print txt{fo?..}' >'txt{foo..}' - } -} diff --git a/tests/name/extension.testscript b/tests/name/extension.testscript new file mode 100644 index 0000000..f9df173 --- /dev/null +++ b/tests/name/extension.testscript @@ -0,0 +1,86 @@ +# file : tests/name/extension.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define txt: file +txt{*}: extension = txt +EOI + +: name +: +{ + test.arguments = --match-only update + + : unspecified + : + touch foo.txt; + $* <'./: txt{foo}' + + : specified + : + touch foo.text; + $* <'./: txt{foo.text}' + + : specified-none + : + touch foo; + $* <'./: txt{foo.}' + + : specified-default + : + touch foo.testscript.txt; + $* <'./: txt{foo.testscript...}' + + # Trailing dots are not allowed on Windows. + # + + : specified-escape-one + : + if ($cxx.target.class != 'windows') + { + touch foo.; + $* <'./: txt{foo..}' + } + + : specified-escape-two + : + if ($cxx.target.class != 'windows') + { + touch foo..; + $* <'./: txt{foo....}' + } + + : specified-invalid + : + $* <'./: txt{foo.....}' 2>>EOE != 0 + :1:5: error: invalid trailing dot sequence in target name 'foo.....' + EOE +} + +: pattern +: +{ + : specified-none + : + touch foo; + $* <'print txt{fo?.}' >'txt{foo.}' + + : specified-default + : + touch foo.testscript.txt; + $* <'print txt{fo?.testscript...}' >'txt{foo.testscript...}' + + # Trailing dots are not allowed on Windows. + # + + : specified-escape + : + if ($cxx.target.class != 'windows') + { + touch foo.; + $* <'print txt{fo?..}' >'txt{foo..}' + } +} diff --git a/tests/name/pattern.test b/tests/name/pattern.test deleted file mode 100644 index 8d8840c..0000000 --- a/tests/name/pattern.test +++ /dev/null @@ -1,332 +0,0 @@ -# file : tests/name/pattern.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -+cat <=build/root.build -define txt: file -txt{*}: extension = txt -EOI - -$* <'print pp%*.txt' >'pp%*.txt' : project-simple -$* <'print pp%{*.txt -x*}' >'pp%*.txt pp%-x*' : project-group - -$* <"print '*.txt'" >'*.txt' : quoted-single -$* <'print "*.txt"' >'*.txt' : quoted-double -$* <'*.txt' : quoted-expansion -pat = '*' -print "$(pat).txt" -EOI - -: detect -: -: Test pattern_mode parsing logic. -{ - : second-pattern - : - touch foo.txt; - $* <'print {foo *.txt}' >'foo foo.txt' - - : independent-patterns - : - touch foo.txt -bar; - $* <'print {*.txt foo* -b*}' >'foo.txt foo.txt -bar' - - : second-inclusion - : - touch foo.txt bar.txt; - $* <'print {f*.txt +b*.txt}' >'foo.txt bar.txt' -} - -: diagnostics -: -{ - : simple - : - $* <'print {*.txt +foo file{bar}}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : inclusion-exclusion-sign - : - $* <'print {*.txt -foo bar}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : inclusion-quoted - : - $* <'print {*.txt -foo "+bar"}' 2>>EOE != 0 - :1:19: error: name pattern inclusion or exclusion expected - EOE - - : empty-inclusion-exclusion - : - $* <'print {*.txt -}' 2>>EOE != 0 - :1:8: error: empty name pattern - EOE - - : inconsistent-result - : - $* <'print {*.txt +foo/}' 2>>EOE != 0 - :1:8: error: inconsistent file/directory result in name pattern - EOE -} - -: basics -: -{ - touch foo.txt; - $* <'print *.txt' >'foo.txt' : simple-file - - mkdir foo; - $* <'print */' >/'foo/' : simple-dir - - touch foo.txt; - $* <'print {*.txt}' >'foo.txt' : group - - touch foo.txt; - $* <'print {+*.txt}' >'foo.txt' : plus-prefixed - - mkdir dir && touch dir/foo.txt; - $* <'print dir/{*.txt}' >'dir/foo.txt' : dir - - touch foo.txt; - $* <'print file{*.txt}' >'file{foo.txt}' : type - - touch foo.txt; - $* <'print x@{*.txt}' >'x@foo.txt' : pair - - touch bar.txt; - $* <'print x@dir/file{f*.txt}' >'' : empty - - mkdir dir && touch dir/foo.txt; - $* <'print **.txt' >/'dir/foo.txt' : recursive - - mkdir dir && touch dir/foo.txt; - $* <'print d*/*.txt' >/'dir/foo.txt' : multi-pattern - - touch foo.txt bar.txt; - $* <'print {*.txt -bar.txt}' >'foo.txt' : exclude-non-pattern - - mkdir baz; - touch foo.txt bar.txt baz/fox.txt baz/box.txt; - $* <'print {**.txt -b*.txt -b*/*}' >'foo.txt' : exclude-pattern - - touch foo.txt bar.txt baz.txt; - $* <'print {*.txt -{*z.txt bar.txt}}' >'foo.txt' : exclude-group - - touch bar.txt; - $* <'print {f*.txt +bar.txt}' >'bar.txt' : include-non-wildcard - - touch bar.txt; - $* <'print {f*.txt +b*.txt}' >'bar.txt' : include-pattern - - mkdir bar; - $* <'print {f*/ +{b*/}}' >/'bar/' : include-group - - touch foo.txt fox.txt; - $* <'print {*.txt -f*.txt +*x.txt}' >'fox.txt' : include-exclude-order - - touch foo.txt; - $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard -} - -: target-type -: -: Test target type-specific pattern amendment logic. -{ - : append-extension - : - touch foo.txt bar.txt; - $* <'print txt{* -bar}' >'txt{foo}' - - : existing-extension - : - touch foo.txt bar.txt; - $* <'print txt{*.txt -bar.txt}' >'txt{foo.txt}' - - : append-slash - : - mkdir foo bar; - $* <'print dir{* -bar}' >/'dir{foo/}' - - : existing-slash - : - mkdir foo bar; - $* <'print dir{*/ -bar/}' >/'dir{foo/}' -} - -: dot -: -: Test filtering of hidden files/directories. -{ - touch foo.txt .foo.txt; - $* <'print *.txt' >'foo.txt' : file-excl - - touch foo.txt .foo.txt; - $* <'print .*.txt' >'.foo.txt' : file-incl - - mkdir dir .dir; - $* <'print */' >/'dir/' : dir-excl - - mkdir dir .dir; - $* <'print .*/' >/'.dir/' : dir-incl - - mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; - $* <'print */*.txt' >/'dir/foo.txt'; - $* <'print **.txt' >/'dir/foo.txt' : dir-interm-excl - - mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; - $* <'print .*/*.txt' >/'.dir/foo.txt' : dir-interm-incl -} - -: expansion -: -: Test interaction with expansion/concatenation/re-parse. -{ - # Do we want to recognize patterns in non-concatenating expansion? - # - # pat = '*.txt' - # print $pat - # - # While this case is probably better rewritten as (i.e., move pattern search - # to variable assignment): - # - # pat = *.txt - # print $pat - # - # One may also want to do something like this: - # - # pat = '*.txt' - # print dir1/{$pat} - # print dir2/{$pat} - # - # Instead, he should write it as follows: - # - # pat = '*.txt' - # print dir1/{+$pat} - # print dir2/{+$pat} - # - # Note that if we make it work, escaping this case will be pretty hairy: - # - # filters = --include '*.txt' --exclude '*.obj' - # options += $filters - - : prefixed-pattern-via-expansion - : - : Pattern is prefixed with the literal unquoted plus character, that is - : stripped. - : - touch foo.txt; - $* <foo.txt - pat = '*.txt' - print {+$pat} - EOI - - : non-prefixed-pattern-via-concat-expansion - : - : Plus character is a part of the pattern and so is not stripped. - : - touch +foo.txt; - $* <'+foo.txt' - pat = '+*' - ext = 'txt' - print {$pat.$ext} - EOI - - : not-pattern-expansion - : - $* <'+*.txt' - pat = '+*.txt' - print {$pat} - EOI - - : not-pattern-quoted - : - $* <'+*.txt' - print {'+*.txt'} - EOI - - : pattern-via-expansion-list - : - touch foo.txt bar.hxx; - $* <'bar.hxx foo.txt' - pats = '*.hxx' '*.txt' - print {+{$pats}} - EOI - - : pattern-via-expansion-type - : - touch foo.txt; - $* <'txt{foo}' - pat = '*' - print txt{+$pat} - EOI - - : pattern-via-expansion-dir - : - mkdir dir; - touch dir/foo.txt; - $* <dir/foo.txt - pat = '*.txt' - print dir/{+$pat} - EOI - - : pattern-via-expansion-dir-type - : - mkdir dir; - touch dir/foo.txt; - $* <dir/txt{foo} - pat = '*' - print dir/txt{+$pat} - EOI - - : pattern-via-concat - : - touch foo.txt; - $* <'foo.txt' - ext = txt - print *.$ext - EOI - - : pattern-via-concat-expansion - : - touch foo.txt; - $* <'foo.txt' - pat = 'f*' - ext = txt - print $pat.$ext - EOI -} - -: command-line -: -: Test pattern expansion on the command line. -{ - : variable - : - { - mkdir dir; - $* <'print $d' 'd=*/' >/'dir/' : dir - - mkdir dir; - $* <'print $d' 'd=dir{*}' >/'dir{dir/}' : dir-type - - touch foo.txt; - $* <'print $f' 'f=*.txt' >'foo.txt' : feil - } - - : buildspec - : - { - test.arguments = - test.options += --buildfile buildfile - - mkdir dir && cat <'./:' >=dir/buildfile; - $* '*/' : dir - - mkdir dir dir1 && cat <'./:' >=dir/buildfile; - $* 'update(dir{* -dir1})' : dir-type - } -} diff --git a/tests/name/pattern.testscript b/tests/name/pattern.testscript new file mode 100644 index 0000000..d40e3a4 --- /dev/null +++ b/tests/name/pattern.testscript @@ -0,0 +1,332 @@ +# file : tests/name/pattern.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + ++cat <=build/root.build +define txt: file +txt{*}: extension = txt +EOI + +$* <'print pp%*.txt' >'pp%*.txt' : project-simple +$* <'print pp%{*.txt -x*}' >'pp%*.txt pp%-x*' : project-group + +$* <"print '*.txt'" >'*.txt' : quoted-single +$* <'print "*.txt"' >'*.txt' : quoted-double +$* <'*.txt' : quoted-expansion +pat = '*' +print "$(pat).txt" +EOI + +: detect +: +: Test pattern_mode parsing logic. +{ + : second-pattern + : + touch foo.txt; + $* <'print {foo *.txt}' >'foo foo.txt' + + : independent-patterns + : + touch foo.txt -bar; + $* <'print {*.txt foo* -b*}' >'foo.txt foo.txt -bar' + + : second-inclusion + : + touch foo.txt bar.txt; + $* <'print {f*.txt +b*.txt}' >'foo.txt bar.txt' +} + +: diagnostics +: +{ + : simple + : + $* <'print {*.txt +foo file{bar}}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : inclusion-exclusion-sign + : + $* <'print {*.txt -foo bar}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : inclusion-quoted + : + $* <'print {*.txt -foo "+bar"}' 2>>EOE != 0 + :1:19: error: name pattern inclusion or exclusion expected + EOE + + : empty-inclusion-exclusion + : + $* <'print {*.txt -}' 2>>EOE != 0 + :1:8: error: empty name pattern + EOE + + : inconsistent-result + : + $* <'print {*.txt +foo/}' 2>>EOE != 0 + :1:8: error: inconsistent file/directory result in name pattern + EOE +} + +: basics +: +{ + touch foo.txt; + $* <'print *.txt' >'foo.txt' : simple-file + + mkdir foo; + $* <'print */' >/'foo/' : simple-dir + + touch foo.txt; + $* <'print {*.txt}' >'foo.txt' : group + + touch foo.txt; + $* <'print {+*.txt}' >'foo.txt' : plus-prefixed + + mkdir dir && touch dir/foo.txt; + $* <'print dir/{*.txt}' >'dir/foo.txt' : dir + + touch foo.txt; + $* <'print file{*.txt}' >'file{foo.txt}' : type + + touch foo.txt; + $* <'print x@{*.txt}' >'x@foo.txt' : pair + + touch bar.txt; + $* <'print x@dir/file{f*.txt}' >'' : empty + + mkdir dir && touch dir/foo.txt; + $* <'print **.txt' >/'dir/foo.txt' : recursive + + mkdir dir && touch dir/foo.txt; + $* <'print d*/*.txt' >/'dir/foo.txt' : multi-pattern + + touch foo.txt bar.txt; + $* <'print {*.txt -bar.txt}' >'foo.txt' : exclude-non-pattern + + mkdir baz; + touch foo.txt bar.txt baz/fox.txt baz/box.txt; + $* <'print {**.txt -b*.txt -b*/*}' >'foo.txt' : exclude-pattern + + touch foo.txt bar.txt baz.txt; + $* <'print {*.txt -{*z.txt bar.txt}}' >'foo.txt' : exclude-group + + touch bar.txt; + $* <'print {f*.txt +bar.txt}' >'bar.txt' : include-non-wildcard + + touch bar.txt; + $* <'print {f*.txt +b*.txt}' >'bar.txt' : include-pattern + + mkdir bar; + $* <'print {f*/ +{b*/}}' >/'bar/' : include-group + + touch foo.txt fox.txt; + $* <'print {*.txt -f*.txt +*x.txt}' >'fox.txt' : include-exclude-order + + touch foo.txt; + $* <'print {+foo.txt} {+bar.txt}' >'foo.txt' : non-wildcard +} + +: target-type +: +: Test target type-specific pattern amendment logic. +{ + : append-extension + : + touch foo.txt bar.txt; + $* <'print txt{* -bar}' >'txt{foo}' + + : existing-extension + : + touch foo.txt bar.txt; + $* <'print txt{*.txt -bar.txt}' >'txt{foo.txt}' + + : append-slash + : + mkdir foo bar; + $* <'print dir{* -bar}' >/'dir{foo/}' + + : existing-slash + : + mkdir foo bar; + $* <'print dir{*/ -bar/}' >/'dir{foo/}' +} + +: dot +: +: Test filtering of hidden files/directories. +{ + touch foo.txt .foo.txt; + $* <'print *.txt' >'foo.txt' : file-excl + + touch foo.txt .foo.txt; + $* <'print .*.txt' >'.foo.txt' : file-incl + + mkdir dir .dir; + $* <'print */' >/'dir/' : dir-excl + + mkdir dir .dir; + $* <'print .*/' >/'.dir/' : dir-incl + + mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; + $* <'print */*.txt' >/'dir/foo.txt'; + $* <'print **.txt' >/'dir/foo.txt' : dir-interm-excl + + mkdir dir .dir && touch dir/foo.txt .dir/foo.txt; + $* <'print .*/*.txt' >/'.dir/foo.txt' : dir-interm-incl +} + +: expansion +: +: Test interaction with expansion/concatenation/re-parse. +{ + # Do we want to recognize patterns in non-concatenating expansion? + # + # pat = '*.txt' + # print $pat + # + # While this case is probably better rewritten as (i.e., move pattern search + # to variable assignment): + # + # pat = *.txt + # print $pat + # + # One may also want to do something like this: + # + # pat = '*.txt' + # print dir1/{$pat} + # print dir2/{$pat} + # + # Instead, he should write it as follows: + # + # pat = '*.txt' + # print dir1/{+$pat} + # print dir2/{+$pat} + # + # Note that if we make it work, escaping this case will be pretty hairy: + # + # filters = --include '*.txt' --exclude '*.obj' + # options += $filters + + : prefixed-pattern-via-expansion + : + : Pattern is prefixed with the literal unquoted plus character, that is + : stripped. + : + touch foo.txt; + $* <foo.txt + pat = '*.txt' + print {+$pat} + EOI + + : non-prefixed-pattern-via-concat-expansion + : + : Plus character is a part of the pattern and so is not stripped. + : + touch +foo.txt; + $* <'+foo.txt' + pat = '+*' + ext = 'txt' + print {$pat.$ext} + EOI + + : not-pattern-expansion + : + $* <'+*.txt' + pat = '+*.txt' + print {$pat} + EOI + + : not-pattern-quoted + : + $* <'+*.txt' + print {'+*.txt'} + EOI + + : pattern-via-expansion-list + : + touch foo.txt bar.hxx; + $* <'bar.hxx foo.txt' + pats = '*.hxx' '*.txt' + print {+{$pats}} + EOI + + : pattern-via-expansion-type + : + touch foo.txt; + $* <'txt{foo}' + pat = '*' + print txt{+$pat} + EOI + + : pattern-via-expansion-dir + : + mkdir dir; + touch dir/foo.txt; + $* <dir/foo.txt + pat = '*.txt' + print dir/{+$pat} + EOI + + : pattern-via-expansion-dir-type + : + mkdir dir; + touch dir/foo.txt; + $* <dir/txt{foo} + pat = '*' + print dir/txt{+$pat} + EOI + + : pattern-via-concat + : + touch foo.txt; + $* <'foo.txt' + ext = txt + print *.$ext + EOI + + : pattern-via-concat-expansion + : + touch foo.txt; + $* <'foo.txt' + pat = 'f*' + ext = txt + print $pat.$ext + EOI +} + +: command-line +: +: Test pattern expansion on the command line. +{ + : variable + : + { + mkdir dir; + $* <'print $d' 'd=*/' >/'dir/' : dir + + mkdir dir; + $* <'print $d' 'd=dir{*}' >/'dir{dir/}' : dir-type + + touch foo.txt; + $* <'print $f' 'f=*.txt' >'foo.txt' : feil + } + + : buildspec + : + { + test.arguments = + test.options += --buildfile buildfile + + mkdir dir && cat <'./:' >=dir/buildfile; + $* '*/' : dir + + mkdir dir dir1 && cat <'./:' >=dir/buildfile; + $* 'update(dir{* -dir1})' : dir-type + } +} diff --git a/tests/search/dir/testscript b/tests/search/dir/testscript index 24162d7..dc4b3a5 100644 --- a/tests/search/dir/testscript +++ b/tests/search/dir/testscript @@ -4,7 +4,7 @@ test.arguments = 'update(../)' -.include ../../common.test +.include ../../common.testscript # foo/ has no buildfile # bar/ has valid buildfile diff --git a/tests/test/buildfile b/tests/test/buildfile index ae792ed..699dab9 100644 --- a/tests/test/buildfile +++ b/tests/test/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: */ file{common.test} +./: */ file{common.testscript} diff --git a/tests/test/common.test b/tests/test/common.test deleted file mode 100644 index ed87424..0000000 --- a/tests/test/common.test +++ /dev/null @@ -1,29 +0,0 @@ -# file : tests/test/common.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Commonly-used build system test project setup and driver command line -# (test module tests). -# - -+mkdir build -+cat <=build/bootstrap.build -project = test -amalgamation = - -using test -EOI - -# By default read buildfile from stdin. -# -if ($null($test.options)) - test.options = --buildfile - -end - -test.options += --serial-stop --quiet - -# By default perform test. -# -if ($null($test.arguments)) - test.arguments = test -end diff --git a/tests/test/common.testscript b/tests/test/common.testscript new file mode 100644 index 0000000..e659187 --- /dev/null +++ b/tests/test/common.testscript @@ -0,0 +1,29 @@ +# file : tests/test/common.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Commonly-used build system test project setup and driver command line +# (test module tests). +# + ++mkdir build ++cat <=build/bootstrap.build +project = test +amalgamation = + +using test +EOI + +# By default read buildfile from stdin. +# +if ($null($test.options)) + test.options = --buildfile - +end + +test.options += --serial-stop --quiet + +# By default perform test. +# +if ($null($test.arguments)) + test.arguments = test +end diff --git a/tests/test/config-test/testscript b/tests/test/config-test/testscript index 7aadaf2..a9fba83 100644 --- a/tests/test/config-test/testscript +++ b/tests/test/config-test/testscript @@ -1,4 +1,4 @@ -# file : tests/test/config-build/testscript +# file : tests/test/config-test/testscript # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file @@ -44,9 +44,9 @@ EOI # +mkdir proj/tests/script +cat <=proj/tests/script/buildfile -./: test{basics.test} +./: testscript{basics.testscript} EOI -+cat <=proj/tests/script/basics.test ++cat <=proj/tests/script/basics.testscript echo 'tests/script/basics/foo' >| : foo echo 'tests/script/basics/bar' >| : bar diff --git a/tests/test/script/buildfile b/tests/test/script/buildfile index 4adc9d0..8878415 100644 --- a/tests/test/script/buildfile +++ b/tests/test/script/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: */ file{common.test} +./: */ file{common.testscript} diff --git a/tests/test/script/builtin/buildfile b/tests/test/script/builtin/buildfile index 7338d4c..83ecfd2 100644 --- a/tests/test/script/builtin/buildfile +++ b/tests/test/script/builtin/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} file{cp-dir/cp-file} $b +./: testscript{*} file{cp-dir/cp-file} $b diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test deleted file mode 100644 index 69ff578..0000000 --- a/tests/test/script/builtin/cat.test +++ /dev/null @@ -1,84 +0,0 @@ -# file : tests/test/script/builtin/cat.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: in -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: dash -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: file -: -$c <=out; -foo -bar -EOF -cat out >>EOO -foo -bar -EOO -EOI - -: in-repeat -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI - -: non-existent -: -$c <>/~%EOE% != 0 -%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+% -EOE -EOI - -: empty-path -: -: Cat an empty path. -: -$c <"cat: invalid path ''" == 1 -EOI - -: big -: -: Cat a big file (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/cat.testscript b/tests/test/script/builtin/cat.testscript new file mode 100644 index 0000000..b72edb4 --- /dev/null +++ b/tests/test/script/builtin/cat.testscript @@ -0,0 +1,84 @@ +# file : tests/test/script/builtin/cat.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: in +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: dash +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: file +: +$c <=out; +foo +bar +EOF +cat out >>EOO +foo +bar +EOO +EOI + +: in-repeat +: +$c <>EOO +foo +bar +EOF +foo +bar +EOO +EOI + +: non-existent +: +$c <>/~%EOE% != 0 +%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+% +EOE +EOI + +: empty-path +: +: Cat an empty path. +: +$c <"cat: invalid path ''" == 1 +EOI + +: big +: +: Cat a big file (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/cp.test b/tests/test/script/builtin/cp.test deleted file mode 100644 index e81b395..0000000 --- a/tests/test/script/builtin/cp.test +++ /dev/null @@ -1,376 +0,0 @@ -# file : tests/test/script/builtin/cp.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : none - : - $c <'cp 2>"cp: missing arguments" == 1' && $b - - : no-source - : - $c <'cp -R a 2>"cp: missing source path" == 1' && $b - - : no-trailing-sep - : - $c <"cp: multiple source paths without trailing separator for destination directory" == 1 - EOI - - : empty - : - { - : dest - : - $c <"cp: invalid path ''" == 1 - EOI - - : src1 - : - $c <"cp: invalid path ''" == 1 - EOI - - : src2 - : - $c <"cp: invalid path ''" == 1 - EOI - } -} - -: file -: -: Test synopsis 1: make a file copy at the specified path. -: -{ - : existing - : - { - : to-non-existing - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-existing - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b': .+% - EOE - EOI - } - - : cleanup - : - { - : existing - : - : Test that copy over an existing file does not register cleanup. If it - : does then the file would be removed while leaving the embedded scope, - : and so the cleanup registered by the outer touch would fail. - : - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - - : to-file - : - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - - : recursively - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - } - - : non-dir - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b': .+% - EOE - EOI - } -} - -: files -: -: Test synopsis 3: copy files into the specified directory. -: -{ - : existing - : - { - : into-dir - : - { - : over-non-existing - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - - : multiple - : - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - - : into-non-dir - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - } - - : non-existing - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } - - : non-file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy file '.+/a' to '.+/b/a': .+% - EOE - EOI - } -} - -: filesystem-entries -: -: Test synopsis 4: copy filesystem entries into the specified directory. -: -{ - : file - : - { - $c <>/~%EOE% != 0 - %cp: unable to copy directory '.+/a' to '.+/b/a': .+% - EOE - EOI - } -} - -: attrs -: -if ($cxx.target.class != 'windows') -{ - fs = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-file/\1/p' - ds = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-dir/\1/p' - - : copy - : - { - : file - : - { - $c <<"EOI" && $b - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp -p $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - } - - : dir - : - { - $c <<"EOI" && $b - ls -l $src_base | sed -n -e '$ds' | \ - set t; - - cp -p -r $src_base/cp-dir ./; - ls -l | sed -n -e '$ds' >"\$t" - EOI - } - } - - : no-copy - : - { - : file - : - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l $src_base/cp-dir | sed -n -e '$fs' | \ - set t; - - cp $src_base/cp-dir/cp-file ./; - ls -l | sed -n -e '$fs' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - - : dir - : - { - $c <<"EOI" && $b 2>>~%EOE% != 0 - ls -l $src_base | sed -n -e '$ds' | \ - set t; - - cp -r $src_base/cp-dir ./; - ls -l | sed -n -e '$ds' >"\$t" - EOI - %.+ error: sed stdout doesn't match expected% - %.+ - EOE - } - } -} diff --git a/tests/test/script/builtin/cp.testscript b/tests/test/script/builtin/cp.testscript new file mode 100644 index 0000000..e1b654f --- /dev/null +++ b/tests/test/script/builtin/cp.testscript @@ -0,0 +1,376 @@ +# file : tests/test/script/builtin/cp.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: args +: +{ + : none + : + $c <'cp 2>"cp: missing arguments" == 1' && $b + + : no-source + : + $c <'cp -R a 2>"cp: missing source path" == 1' && $b + + : no-trailing-sep + : + $c <"cp: multiple source paths without trailing separator for destination directory" == 1 + EOI + + : empty + : + { + : dest + : + $c <"cp: invalid path ''" == 1 + EOI + + : src1 + : + $c <"cp: invalid path ''" == 1 + EOI + + : src2 + : + $c <"cp: invalid path ''" == 1 + EOI + } +} + +: file +: +: Test synopsis 1: make a file copy at the specified path. +: +{ + : existing + : + { + : to-non-existing + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-existing + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b': .+% + EOE + EOI + } + + : cleanup + : + { + : existing + : + : Test that copy over an existing file does not register cleanup. If it + : does then the file would be removed while leaving the embedded scope, + : and so the cleanup registered by the outer touch would fail. + : + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + + : to-file + : + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + + : recursively + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + } + + : non-dir + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b': .+% + EOE + EOI + } +} + +: files +: +: Test synopsis 3: copy files into the specified directory. +: +{ + : existing + : + { + : into-dir + : + { + : over-non-existing + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + + : multiple + : + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + + : into-non-dir + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + } + + : non-existing + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } + + : non-file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy file '.+/a' to '.+/b/a': .+% + EOE + EOI + } +} + +: filesystem-entries +: +: Test synopsis 4: copy filesystem entries into the specified directory. +: +{ + : file + : + { + $c <>/~%EOE% != 0 + %cp: unable to copy directory '.+/a' to '.+/b/a': .+% + EOE + EOI + } +} + +: attrs +: +if ($cxx.target.class != 'windows') +{ + fs = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-file/\1/p' + ds = 's/.+ (\S+\s+\S+\s+\S+)\s+cp-dir/\1/p' + + : copy + : + { + : file + : + { + $c <<"EOI" && $b + ls -l $src_base/cp-dir | sed -n -e '$fs' | \ + set t; + + cp -p $src_base/cp-dir/cp-file ./; + ls -l | sed -n -e '$fs' >"\$t" + EOI + } + + : dir + : + { + $c <<"EOI" && $b + ls -l $src_base | sed -n -e '$ds' | \ + set t; + + cp -p -r $src_base/cp-dir ./; + ls -l | sed -n -e '$ds' >"\$t" + EOI + } + } + + : no-copy + : + { + : file + : + { + $c <<"EOI" && $b 2>>~%EOE% != 0 + ls -l $src_base/cp-dir | sed -n -e '$fs' | \ + set t; + + cp $src_base/cp-dir/cp-file ./; + ls -l | sed -n -e '$fs' >"\$t" + EOI + %.+ error: sed stdout doesn't match expected% + %.+ + EOE + } + + : dir + : + { + $c <<"EOI" && $b 2>>~%EOE% != 0 + ls -l $src_base | sed -n -e '$ds' | \ + set t; + + cp -r $src_base/cp-dir ./; + ls -l | sed -n -e '$ds' >"\$t" + EOI + %.+ error: sed stdout doesn't match expected% + %.+ + EOE + } + } +} diff --git a/tests/test/script/builtin/echo.test b/tests/test/script/builtin/echo.test deleted file mode 100644 index 28647f4..0000000 --- a/tests/test/script/builtin/echo.test +++ /dev/null @@ -1,27 +0,0 @@ -# file : tests/test/script/builtin/echo.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: string -: -$c <'echo foo >foo' && $b - -: strings -: -$c <'echo foo bar >"foo bar"' && $b - -: big -: -: Echo a big string (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/echo.testscript b/tests/test/script/builtin/echo.testscript new file mode 100644 index 0000000..235a9f7 --- /dev/null +++ b/tests/test/script/builtin/echo.testscript @@ -0,0 +1,27 @@ +# file : tests/test/script/builtin/echo.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: string +: +$c <'echo foo >foo' && $b + +: strings +: +$c <'echo foo bar >"foo bar"' && $b + +: big +: +: Echo a big string (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/ln.test b/tests/test/script/builtin/ln.test deleted file mode 100644 index 8b4c30e..0000000 --- a/tests/test/script/builtin/ln.test +++ /dev/null @@ -1,184 +0,0 @@ -# file : tests/test/script/builtin/ln.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : -s-option - : - $c <'ln 2>"ln: missing -s option" == 1' && $b - - : none - : - $c <'ln -s 2>"ln: missing arguments" == 1' && $b - - : no-target - : - $c <'ln -s a 2>"ln: missing target path" == 1' && $b - - : no-trailing-sep - : - $c <"ln: multiple target paths with non-directory link path" == 1 - EOI - - : empty - : - { - : link - : - $c <"ln: invalid path ''" == 1 - EOI - - : target1 - : - $c <"ln: invalid path ''" == 1 - EOI - - : target2 - : - $c <"ln: invalid path ''" == 1 - EOI - } -} - -: file -: -: Test creating a file symlink. -: -{ - : non-existing-link-path - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b': .+% - %) - EOE - EOI - - : dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b': .+% - %) - EOE - EOI - } - - : non-existing - { - : target - : - $c <>/~%EOE% != 0 - %ln: unable to create symlink to '.+/a': no such file or directory% - EOE - EOI - - : link-dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| - %ln: unable to copy file '.+/a' to '.+/b/c': .+% - %) - EOE - EOI - } -} - -: dir -: -: Test creating a directory symlink. -: -{ - : non-existing-link-path - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b': .+% - %) - EOE - EOI - - : file - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b': .+% - %) - EOE - EOI - } - - : non-existing - { - : link-dir - : - $c <>/~%EOE% != 0 - %( - %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| - %ln: unable to copy directory '.+/a' to '.+/b/c': .+% - %) - EOE - EOI - } -} - -: multiple-targets -: -: Test creating links for multiple targets in the specified directory. -: -{ - $c <"ln: missing -s option" == 1' && $b + + : none + : + $c <'ln -s 2>"ln: missing arguments" == 1' && $b + + : no-target + : + $c <'ln -s a 2>"ln: missing target path" == 1' && $b + + : no-trailing-sep + : + $c <"ln: multiple target paths with non-directory link path" == 1 + EOI + + : empty + : + { + : link + : + $c <"ln: invalid path ''" == 1 + EOI + + : target1 + : + $c <"ln: invalid path ''" == 1 + EOI + + : target2 + : + $c <"ln: invalid path ''" == 1 + EOI + } +} + +: file +: +: Test creating a file symlink. +: +{ + : non-existing-link-path + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b': .+% + %) + EOE + EOI + + : dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b': .+% + %) + EOE + EOI + } + + : non-existing + { + : target + : + $c <>/~%EOE% != 0 + %ln: unable to create symlink to '.+/a': no such file or directory% + EOE + EOI + + : link-dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| + %ln: unable to copy file '.+/a' to '.+/b/c': .+% + %) + EOE + EOI + } +} + +: dir +: +: Test creating a directory symlink. +: +{ + : non-existing-link-path + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b': .+% + %) + EOE + EOI + + : file + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b': .+% + %) + EOE + EOI + } + + : non-existing + { + : link-dir + : + $c <>/~%EOE% != 0 + %( + %ln: unable to create .+link '.+/b/c' to '.+/a': .+%| + %ln: unable to copy directory '.+/a' to '.+/b/c': .+% + %) + EOE + EOI + } +} + +: multiple-targets +: +: Test creating links for multiple targets in the specified directory. +: +{ + $c <"mkdir: missing directory" == 1' && $b - -: empty-path -: -: Test creation of empty directory path. -: -$c <"mkdir: invalid path ''" == 1 -EOI - -: already-exists -: -: Test creation of an existing directory. -: -$c <>/~%EOE% == 1 -%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+% -EOE -EOI - -: not-exists -: -: Test creation of a directory with non-existent parent. -: -$c <>/~%EOE% == 1 -%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+% -EOE -EOI diff --git a/tests/test/script/builtin/mkdir.testscript b/tests/test/script/builtin/mkdir.testscript new file mode 100644 index 0000000..6b082bd --- /dev/null +++ b/tests/test/script/builtin/mkdir.testscript @@ -0,0 +1,66 @@ +# file : tests/test/script/builtin/mkdir.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: dirs +: +$c <"mkdir: missing directory" == 1' && $b + +: empty-path +: +: Test creation of empty directory path. +: +$c <"mkdir: invalid path ''" == 1 +EOI + +: already-exists +: +: Test creation of an existing directory. +: +$c <>/~%EOE% == 1 +%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+% +EOE +EOI + +: not-exists +: +: Test creation of a directory with non-existent parent. +: +$c <>/~%EOE% == 1 +%mkdir: unable to create directory '.+/test/mkdir/not-exists/test/1/a/b': .+% +EOE +EOI diff --git a/tests/test/script/builtin/mv.test b/tests/test/script/builtin/mv.test deleted file mode 100644 index 291832e..0000000 --- a/tests/test/script/builtin/mv.test +++ /dev/null @@ -1,252 +0,0 @@ -# file : tests/test/script/builtin/mv.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: args -: -{ - : none - : - $c <'mv 2>"mv: missing arguments" == 1' && $b - - : no-source - : - $c <'mv a 2>"mv: missing source path" == 1' && $b - - : no-trailing-sep - : - $c <"mv: multiple source paths without trailing separator for destination directory" == 1 - EOI - - : empty - : - { - : dest - : - $c <"mv: invalid path ''" == 1 - EOI - - : src1 - : - $c <"mv: invalid path ''" == 1 - EOI - - : src2 - : - $c <"mv: invalid path ''" == 1 - EOI - } -} - -: synopsis-1 -: -: Move an entity to the specified path. -: -{ - : file - : - { - : existing - : - { - : to-non-existing - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to itself% - EOE - EOI - - : to-dir - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Moving path outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'% - EOE - EOI - - : force - : - : Moving path outside the testscript working directory is allowed with -f - : option. We fail after this check succeeds as the source path does not - : exist. - : - $c <>/~%EOE% == 1 - %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% - EOE - EOI - } - - : cleanup - : - { - : existing - : - : Test that moving over an existing file does not move the cleanup. If - : it does, then the file would be removed while leaving the embedded - : scope, and so the cleanup registered by the outer touch would fail. We - : also test that the source path cleanup is removed, otherwise it would - : fail. - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - - : to-non-dir - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } - - : working-dir - : - { - : src - : - { - $c <"mv: '([string] $~)' contains test working directory '$~'" != 0 - EOI - } - - : dst - : - { - $c <"mv: '$~' contains test working directory '$~'" != 0 - EOI - } - } - - : overlap - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/a/b': .+% - EOE - EOI - - : cleanup - : - { - : sub-entry - : - { - mkdir a; - touch a/b; - mv a c - } - - : reorder - : - : Test that a/, that is created before b/ and so should be removed after - : it, get removed before b/ after being renamed to b/c. - : - $c <>/~%EOE% != 0 - %mv: unable to move entity '.+/a' to '.+/b': .+% - EOE - EOI - } -} - -: synopsis-2 -: -: Move entities into the specified directory. -: -{ - $c <"mv: missing arguments" == 1' && $b + + : no-source + : + $c <'mv a 2>"mv: missing source path" == 1' && $b + + : no-trailing-sep + : + $c <"mv: multiple source paths without trailing separator for destination directory" == 1 + EOI + + : empty + : + { + : dest + : + $c <"mv: invalid path ''" == 1 + EOI + + : src1 + : + $c <"mv: invalid path ''" == 1 + EOI + + : src2 + : + $c <"mv: invalid path ''" == 1 + EOI + } +} + +: synopsis-1 +: +: Move an entity to the specified path. +: +{ + : file + : + { + : existing + : + { + : to-non-existing + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to itself% + EOE + EOI + + : to-dir + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Moving path outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %mv: '.+/fail/a/b/c' is out of working directory '.+/fail/test'% + EOE + EOI + + : force + : + : Moving path outside the testscript working directory is allowed with -f + : option. We fail after this check succeeds as the source path does not + : exist. + : + $c <>/~%EOE% == 1 + %mv: unable to move entity '.+/force/a/b/c' to '.+/c': .+% + EOE + EOI + } + + : cleanup + : + { + : existing + : + : Test that moving over an existing file does not move the cleanup. If + : it does, then the file would be removed while leaving the embedded + : scope, and so the cleanup registered by the outer touch would fail. We + : also test that the source path cleanup is removed, otherwise it would + : fail. + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + + : to-non-dir + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } + + : working-dir + : + { + : src + : + { + $c <"mv: '([string] $~)' contains test working directory '$~'" != 0 + EOI + } + + : dst + : + { + $c <"mv: '$~' contains test working directory '$~'" != 0 + EOI + } + } + + : overlap + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/a/b': .+% + EOE + EOI + + : cleanup + : + { + : sub-entry + : + { + mkdir a; + touch a/b; + mv a c + } + + : reorder + : + : Test that a/, that is created before b/ and so should be removed after + : it, get removed before b/ after being renamed to b/c. + : + $c <>/~%EOE% != 0 + %mv: unable to move entity '.+/a' to '.+/b': .+% + EOE + EOI + } +} + +: synopsis-2 +: +: Move entities into the specified directory. +: +{ + $c <"rm: missing file" == 1' && $b - - : force - : - : Removing with no arguments succeeds with -f option. - : - $c <'rm -f' && $b -} - -: file -: -{ - : exists - : - : Removing existing file succeeds. - : - $c <>/~%EOE% == 1 - %rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+% - EOE - EOI - - : force - : - : Removing non-existing file succeeds with -f option. - : - $c <'rm -f a' && $b - } -} - -: dir -: -{ - : default - : - : Removing directory fails by default. - : - $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 - EOI - - : recursive - : - : Removing directory succeeds with -r option. - : - $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 - EOI -} - -: path -: -{ - : empty - : - : Removing an empty path fails. - : - $c <"rm: invalid path ''" == 1 - EOI - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Removing path outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% - EOE - EOI - - : force - : - : Removing path outside the testscript working directory succeeds with -f - : option. - : - $c <'rm -f ../../a/b/c' && $b - } -} diff --git a/tests/test/script/builtin/rm.testscript b/tests/test/script/builtin/rm.testscript new file mode 100644 index 0000000..3dd2674 --- /dev/null +++ b/tests/test/script/builtin/rm.testscript @@ -0,0 +1,119 @@ +# file : tests/test/script/builtin/rm.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: no-args +: +{ + : fail + : + : Removing with no arguments fails. + : + $c <'rm 2>"rm: missing file" == 1' && $b + + : force + : + : Removing with no arguments succeeds with -f option. + : + $c <'rm -f' && $b +} + +: file +: +{ + : exists + : + : Removing existing file succeeds. + : + $c <>/~%EOE% == 1 + %rm: unable to remove '.+/file/not-exists/fail/test/1/a': .+% + EOE + EOI + + : force + : + : Removing non-existing file succeeds with -f option. + : + $c <'rm -f a' && $b + } +} + +: dir +: +{ + : default + : + : Removing directory fails by default. + : + $c <"rm: '$normalize([path] $~/a)' is a directory" == 1 + EOI + + : recursive + : + : Removing directory succeeds with -r option. + : + $c <"rm: '([string] $~)' contains test working directory '$~'" == 1 + EOI +} + +: path +: +{ + : empty + : + : Removing an empty path fails. + : + $c <"rm: invalid path ''" == 1 + EOI + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Removing path outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %rm: '.+/path/outside-scope/fail/a/b/c' is out of working directory '.+/path/outside-scope/fail/test'% + EOE + EOI + + : force + : + : Removing path outside the testscript working directory succeeds with -f + : option. + : + $c <'rm -f ../../a/b/c' && $b + } +} diff --git a/tests/test/script/builtin/rmdir.test b/tests/test/script/builtin/rmdir.test deleted file mode 100644 index 0e53bde..0000000 --- a/tests/test/script/builtin/rmdir.test +++ /dev/null @@ -1,114 +0,0 @@ -# file : tests/test/script/builtin/rmdir.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: no-args -: -{ - : fail - : - : Removing with no arguments fails. - : - $c <'rmdir 2>"rmdir: missing directory" == 1' && $b - - : force - : - : Removing with no arguments succeeds with -f option. - : - $c <'rmdir -f' && $b -} - -: dir -: -{ - : empty-path - : - : Removing an empty path fails. - : - $c <"rmdir: invalid path ''" == 1 - EOI - - : test-scope - : - : Removing scope directory fails. - : - $c <"rmdir: '$~' contains test working directory '$~'" == 1 - EOI - - : outside-scope - : - : Need to use a path that unlikely exists (not to remove something useful). - : - { - : fail - : - : Removing directory outside the testscript working directory fails. - : - $c <>/~%EOE% == 1 - %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% - EOE - EOI - - : force - : - : Removing path outside the testscript working directory succeeds with -f - : option. - : - $c <'rmdir -f ../../a/b/c' && $b - } - - : exists - : - : Removing existing directory succeeds. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+% - EOE - EOI - - : force - : - : Removing non-existing directory succeeds with -f option. - : - $c <'rmdir -f a' && $b - } - - : not-empty - : - : Removing non-empty directory fails. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+% - EOE - EOI - - : not-dir - : - : Removing not a directory path fails. - : - $c <>/~%EOE% == 1 - %rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+% - EOE - EOI -} diff --git a/tests/test/script/builtin/rmdir.testscript b/tests/test/script/builtin/rmdir.testscript new file mode 100644 index 0000000..99dcaf1 --- /dev/null +++ b/tests/test/script/builtin/rmdir.testscript @@ -0,0 +1,114 @@ +# file : tests/test/script/builtin/rmdir.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: no-args +: +{ + : fail + : + : Removing with no arguments fails. + : + $c <'rmdir 2>"rmdir: missing directory" == 1' && $b + + : force + : + : Removing with no arguments succeeds with -f option. + : + $c <'rmdir -f' && $b +} + +: dir +: +{ + : empty-path + : + : Removing an empty path fails. + : + $c <"rmdir: invalid path ''" == 1 + EOI + + : test-scope + : + : Removing scope directory fails. + : + $c <"rmdir: '$~' contains test working directory '$~'" == 1 + EOI + + : outside-scope + : + : Need to use a path that unlikely exists (not to remove something useful). + : + { + : fail + : + : Removing directory outside the testscript working directory fails. + : + $c <>/~%EOE% == 1 + %rmdir: '.+/dir/outside-scope/fail/a/b/c' is out of working directory '.+/dir/outside-scope/fail/test'% + EOE + EOI + + : force + : + : Removing path outside the testscript working directory succeeds with -f + : option. + : + $c <'rmdir -f ../../a/b/c' && $b + } + + : exists + : + : Removing existing directory succeeds. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-exists/fail/test/1/a': .+% + EOE + EOI + + : force + : + : Removing non-existing directory succeeds with -f option. + : + $c <'rmdir -f a' && $b + } + + : not-empty + : + : Removing non-empty directory fails. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-empty/test/1/a': .+% + EOE + EOI + + : not-dir + : + : Removing not a directory path fails. + : + $c <>/~%EOE% == 1 + %rmdir: unable to remove '.+/dir/not-dir/test/1/a': .+% + EOE + EOI +} diff --git a/tests/test/script/builtin/sed.test b/tests/test/script/builtin/sed.test deleted file mode 100644 index 71824a1..0000000 --- a/tests/test/script/builtin/sed.test +++ /dev/null @@ -1,333 +0,0 @@ -# file : tests/test/script/builtin/sed.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: arg -: -{ - : auto-prn - : - { - $c <"sed -n -e 's/fox/bar/' <'foo' " && $b : on - $c <"sed -e 's/fox/bar/' <'foo' >'foo'" && $b : off - } - - : script - : - { - : missed - : - $c <'sed' && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: missing script - EOE - - : missed-val - : - $c <'sed -e' && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: missing script - EOE - - : empty - : - $c <"sed -e ''" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: empty script - EOE - - : multiple - : - $c <"sed -e 's/a//' -e 's/a//'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: multiple scripts - EOE - - : invalid - : - $c <"sed -e 'z'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: only 's' command supported - EOE - } - - : file - : - { - : exist - : - $c <=f; - sed -e 's/foo/bar/' f >'bar' - EOI - - : none - : - $c <'bar' - EOI - - : dash - : - $c <'bar' - EOI - - : not-exist - : - $c <"sed -e 's/foo/bar/' f" && $b 2>>/~%EOE% != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - %sed: unable to edit '.+/1/f': .+% - EOE - - : empty - : - $c <"sed -e 's/foo/bar/' ''" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid path '' - EOE - } - - : unexpected - : - $c <"sed -e 's/a//' a b" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unexpected argument - EOE -} - -: command -: -{ - : subst - : - { - : parsing - : - { - : delim - : - { - : none - : - $c <"sed -e 's'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: no delimiter for 's' command - EOE - - : invalid - : - $c <"sed -e 's\\'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid delimiter for 's' command - EOE - } - - : regex - : - { - : unterminated - : - $c <"sed -e 's/foo'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unterminated 's' command regex - EOE - - : empty - : - $c <"sed -e 's///'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: empty regex in 's' command - EOE - - : invalid - : - : Note that old versions of libc++ (for example 1.1) do not detect some - : regex errors. For example '*' is parsed successfully. - : - $c <"sed -e 's/foo[/bar/'" && $b 2>>/~%EOE% != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - %sed: invalid regex.*% - EOE - } - - : unterminated-replacement - : - $c <"sed -e 's/foo/bar'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: unterminated 's' command replacement - EOE - - : invalid-flags - : - $c <"sed -e 's/foo/bar/a'" && $b 2>>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: invalid 's' command flag 'a' - EOE - } - - : exec - : - { - : flags - : - { - : global - : - { - $c <"sed -e 's/o/a/g' <'foo' >'faa'" && $b : on - $c <"sed -e 's/o/a/' <'foo' >'fao'" && $b : off - } - - : icase - : - { - $c <"sed -e 's/O/a/i' <'foo' >'fao'" && $b : on - $c <"sed -e 's/O/a/' <'foo' >'foo'" && $b : off - } - - : print - : - { - $c <"sed -n -e 's/o/a/p' <'foo' >'fao'" && $b : on-match - $c <"sed -n -e 's/o/a/' <'foo' " && $b : off-match - $c <"sed -n -e 's/u/a/p' <'foo' " && $b : on-no-match - } - } - - : search - { - : anchor - : - { - $c <"sed -n -e 's/^o/a/gp' <'oof' >'aof'" && $b : begin - $c <"sed -n -e 's/o\$/a/gp' <'foo' >'foa'" && $b : end - } - - : match - : Match corner cases - : - { - $c <"sed -n -e 's/a/b/p' <'a' >'b' " && $b : full - $c <"sed -n -e 's/a/b/p' <'ac' >'bc' " && $b : left - $c <"sed -n -e 's/a/b/p' <'ca' >'cb' " && $b : right - $c <"sed -n -e 's/a/b/pg' <'xaax' >'xbbx'" && $b : adjacent - } - } - - : replacement - : - { - : ecma-escape - : - { - $c <"sed <'xay' -e 's/a/\$b/' >'x\$by'" && $b : none - $c <"sed <'xay' -e 's/a/\$/' >'x\$y' " && $b : none-term - $c <"sed <'xay' -e 's/a/\$\$/' >'x\$y' " && $b : self - $c <"sed <'xay' -e 's/a/b\$&c/' >'xbacy'" && $b : match - $c <"sed <'xay' -e 's/a/b\$`c/' >'xbxcy'" && $b : match-precede - $c <"sed <'xay' -e \"s/a/b\\\$'c/\" >'xbycy'" && $b : match-follow - - : capture - : - $c <'aj' - EOI - } - - : perl-escape - : - { - $c <"sed <'xay' -e 's/a/\\b/' >'xby' " && $b : none - $c <"sed <'xay' -e 's/a/\\/' >'xy' " && $b : none-term - $c <"sed <'xay' -e 's/a/\\\\/' >'x\\y'" && $b : self - - : capture - : - $c <'aa0' - EOI - - : upper - : - { - $c <"sed <'xay' -e 's/a/\\U/' >'xy' " && $b : none - $c <"sed <'xay' -e 's/a/\\Uvz/' >'xVZy'" && $b : repl - $c <"sed <'xay' -e 's/a/\\Uv\\Ez/' >'xVzy'" && $b : end - $c <"sed <'aa' -e 's/a/v\\Uz/g' >'vZvZ'" && $b : locality - $c <"sed <'xay' -e 's/\(a\)/\\U\\1/' >'xAy' " && $b : capt - $c <"sed <'x-y' -e 's/\(a?\)-/\\U\\1z/' >'xZy' " && $b : capt-empty - $c <"sed <'xay' -e 's/a/\\uvz/' >'xVzy'" && $b : once - } - - : lower - : - { - $c <"sed <'xay' -e 's/a/\\lVZ/' >'xvZy'" && $b : once - } - } - } - - $c <"sed -e 's/a//' <:'b' >'b'" && $b : no-newline - $c <"sed -e 's/a//' <:'' " && $b : empty-stdin - - : empty-file - : - $c <>/EOE != 0 - testscript:1:1: error: sed exit code 1 != 0 - info: stderr: test/1/stderr - sed: -i option specified while reading from stdin - EOE - - : edit - : - $c <=f; - sed -i -e 's/foo/bar/' f; - cat f >'bar' - EOI -} - -: big -: -: Sed a big file (about 100K) to test that the builtin is asynchronous. -: -{ - $c <"$s" - EOI -} diff --git a/tests/test/script/builtin/sed.testscript b/tests/test/script/builtin/sed.testscript new file mode 100644 index 0000000..9db7cb4 --- /dev/null +++ b/tests/test/script/builtin/sed.testscript @@ -0,0 +1,333 @@ +# file : tests/test/script/builtin/sed.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: arg +: +{ + : auto-prn + : + { + $c <"sed -n -e 's/fox/bar/' <'foo' " && $b : on + $c <"sed -e 's/fox/bar/' <'foo' >'foo'" && $b : off + } + + : script + : + { + : missed + : + $c <'sed' && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: missing script + EOE + + : missed-val + : + $c <'sed -e' && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: missing script + EOE + + : empty + : + $c <"sed -e ''" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: empty script + EOE + + : multiple + : + $c <"sed -e 's/a//' -e 's/a//'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: multiple scripts + EOE + + : invalid + : + $c <"sed -e 'z'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: only 's' command supported + EOE + } + + : file + : + { + : exist + : + $c <=f; + sed -e 's/foo/bar/' f >'bar' + EOI + + : none + : + $c <'bar' + EOI + + : dash + : + $c <'bar' + EOI + + : not-exist + : + $c <"sed -e 's/foo/bar/' f" && $b 2>>/~%EOE% != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + %sed: unable to edit '.+/1/f': .+% + EOE + + : empty + : + $c <"sed -e 's/foo/bar/' ''" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid path '' + EOE + } + + : unexpected + : + $c <"sed -e 's/a//' a b" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unexpected argument + EOE +} + +: command +: +{ + : subst + : + { + : parsing + : + { + : delim + : + { + : none + : + $c <"sed -e 's'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: no delimiter for 's' command + EOE + + : invalid + : + $c <"sed -e 's\\'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid delimiter for 's' command + EOE + } + + : regex + : + { + : unterminated + : + $c <"sed -e 's/foo'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unterminated 's' command regex + EOE + + : empty + : + $c <"sed -e 's///'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: empty regex in 's' command + EOE + + : invalid + : + : Note that old versions of libc++ (for example 1.1) do not detect some + : regex errors. For example '*' is parsed successfully. + : + $c <"sed -e 's/foo[/bar/'" && $b 2>>/~%EOE% != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + %sed: invalid regex.*% + EOE + } + + : unterminated-replacement + : + $c <"sed -e 's/foo/bar'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: unterminated 's' command replacement + EOE + + : invalid-flags + : + $c <"sed -e 's/foo/bar/a'" && $b 2>>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: invalid 's' command flag 'a' + EOE + } + + : exec + : + { + : flags + : + { + : global + : + { + $c <"sed -e 's/o/a/g' <'foo' >'faa'" && $b : on + $c <"sed -e 's/o/a/' <'foo' >'fao'" && $b : off + } + + : icase + : + { + $c <"sed -e 's/O/a/i' <'foo' >'fao'" && $b : on + $c <"sed -e 's/O/a/' <'foo' >'foo'" && $b : off + } + + : print + : + { + $c <"sed -n -e 's/o/a/p' <'foo' >'fao'" && $b : on-match + $c <"sed -n -e 's/o/a/' <'foo' " && $b : off-match + $c <"sed -n -e 's/u/a/p' <'foo' " && $b : on-no-match + } + } + + : search + { + : anchor + : + { + $c <"sed -n -e 's/^o/a/gp' <'oof' >'aof'" && $b : begin + $c <"sed -n -e 's/o\$/a/gp' <'foo' >'foa'" && $b : end + } + + : match + : Match corner cases + : + { + $c <"sed -n -e 's/a/b/p' <'a' >'b' " && $b : full + $c <"sed -n -e 's/a/b/p' <'ac' >'bc' " && $b : left + $c <"sed -n -e 's/a/b/p' <'ca' >'cb' " && $b : right + $c <"sed -n -e 's/a/b/pg' <'xaax' >'xbbx'" && $b : adjacent + } + } + + : replacement + : + { + : ecma-escape + : + { + $c <"sed <'xay' -e 's/a/\$b/' >'x\$by'" && $b : none + $c <"sed <'xay' -e 's/a/\$/' >'x\$y' " && $b : none-term + $c <"sed <'xay' -e 's/a/\$\$/' >'x\$y' " && $b : self + $c <"sed <'xay' -e 's/a/b\$&c/' >'xbacy'" && $b : match + $c <"sed <'xay' -e 's/a/b\$`c/' >'xbxcy'" && $b : match-precede + $c <"sed <'xay' -e \"s/a/b\\\$'c/\" >'xbycy'" && $b : match-follow + + : capture + : + $c <'aj' + EOI + } + + : perl-escape + : + { + $c <"sed <'xay' -e 's/a/\\b/' >'xby' " && $b : none + $c <"sed <'xay' -e 's/a/\\/' >'xy' " && $b : none-term + $c <"sed <'xay' -e 's/a/\\\\/' >'x\\y'" && $b : self + + : capture + : + $c <'aa0' + EOI + + : upper + : + { + $c <"sed <'xay' -e 's/a/\\U/' >'xy' " && $b : none + $c <"sed <'xay' -e 's/a/\\Uvz/' >'xVZy'" && $b : repl + $c <"sed <'xay' -e 's/a/\\Uv\\Ez/' >'xVzy'" && $b : end + $c <"sed <'aa' -e 's/a/v\\Uz/g' >'vZvZ'" && $b : locality + $c <"sed <'xay' -e 's/\(a\)/\\U\\1/' >'xAy' " && $b : capt + $c <"sed <'x-y' -e 's/\(a?\)-/\\U\\1z/' >'xZy' " && $b : capt-empty + $c <"sed <'xay' -e 's/a/\\uvz/' >'xVzy'" && $b : once + } + + : lower + : + { + $c <"sed <'xay' -e 's/a/\\lVZ/' >'xvZy'" && $b : once + } + } + } + + $c <"sed -e 's/a//' <:'b' >'b'" && $b : no-newline + $c <"sed -e 's/a//' <:'' " && $b : empty-stdin + + : empty-file + : + $c <>/EOE != 0 + testscript:1:1: error: sed exit code 1 != 0 + info: stderr: test/1/stderr + sed: -i option specified while reading from stdin + EOE + + : edit + : + $c <=f; + sed -i -e 's/foo/bar/' f; + cat f >'bar' + EOI +} + +: big +: +: Sed a big file (about 100K) to test that the builtin is asynchronous. +: +{ + $c <"$s" + EOI +} diff --git a/tests/test/script/builtin/test.test b/tests/test/script/builtin/test.test deleted file mode 100644 index 73d89bc..0000000 --- a/tests/test/script/builtin/test.test +++ /dev/null @@ -1,69 +0,0 @@ -# file : tests/test/script/builtin/test.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: file -: -{ - : exists - : - $c <"test: missing path" == 2' && $b - -: invalid-option -: -: Test passing invalid option. -: -$c <'test -c a 2>"test: invalid option" == 2' && $b - -: unexpected-arg -: -: Test passing extra argument. -: -$c <'test -f a b 2>"test: unexpected argument" == 2' && $b - -: empty-path -: -: Test testing an empty path. -: -$c <"test: invalid path ''" == 2 -EOI diff --git a/tests/test/script/builtin/test.testscript b/tests/test/script/builtin/test.testscript new file mode 100644 index 0000000..f49b92b --- /dev/null +++ b/tests/test/script/builtin/test.testscript @@ -0,0 +1,69 @@ +# file : tests/test/script/builtin/test.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: file +: +{ + : exists + : + $c <"test: missing path" == 2' && $b + +: invalid-option +: +: Test passing invalid option. +: +$c <'test -c a 2>"test: invalid option" == 2' && $b + +: unexpected-arg +: +: Test passing extra argument. +: +$c <'test -f a b 2>"test: unexpected argument" == 2' && $b + +: empty-path +: +: Test testing an empty path. +: +$c <"test: invalid path ''" == 2 +EOI diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test deleted file mode 100644 index 04391bd..0000000 --- a/tests/test/script/builtin/touch.test +++ /dev/null @@ -1,88 +0,0 @@ -# file : tests/test/script/builtin/touch.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: file -: -$c <'touch a' && $b - -: file-create -: -: Test that file is created. If it didn't then 'rm' would fail. -: -$c <=a; -touch a -EOI - -: no-cleanup -: -: Test that touching an existing file does not register cleanup. If it does -: then the file would be removed while leaving the embedded scope, and so the -: cleanup registered by the first touch would fail. -: -$c <"touch: missing file" != 0' && $b - -: empty-path -: -: Test touching an empty path. -: -$c <"touch: invalid path ''" != 0 -EOI - -: dir-update -: -: Test touching an existing directory. -: -$c <~'%touch: cannot create/update .+: .+%' != 0 -EOI - -: after -: -{ - : success - : - $c <'touch: missing --after option value' != 0 - EOI - - : not-exists - : - $c <~"%touch: cannot obtain file '.+a' modification time: .+%" != 0 - EOI -} diff --git a/tests/test/script/builtin/touch.testscript b/tests/test/script/builtin/touch.testscript new file mode 100644 index 0000000..d58ed7f --- /dev/null +++ b/tests/test/script/builtin/touch.testscript @@ -0,0 +1,88 @@ +# file : tests/test/script/builtin/touch.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: file +: +$c <'touch a' && $b + +: file-create +: +: Test that file is created. If it didn't then 'rm' would fail. +: +$c <=a; +touch a +EOI + +: no-cleanup +: +: Test that touching an existing file does not register cleanup. If it does +: then the file would be removed while leaving the embedded scope, and so the +: cleanup registered by the first touch would fail. +: +$c <"touch: missing file" != 0' && $b + +: empty-path +: +: Test touching an empty path. +: +$c <"touch: invalid path ''" != 0 +EOI + +: dir-update +: +: Test touching an existing directory. +: +$c <~'%touch: cannot create/update .+: .+%' != 0 +EOI + +: after +: +{ + : success + : + $c <'touch: missing --after option value' != 0 + EOI + + : not-exists + : + $c <~"%touch: cannot obtain file '.+a' modification time: .+%" != 0 + EOI +} diff --git a/tests/test/script/common.test b/tests/test/script/common.test deleted file mode 100644 index bf9ebba..0000000 --- a/tests/test/script/common.test +++ /dev/null @@ -1,36 +0,0 @@ -# file : tests/test/script/common.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Commonly-used build system test project setup and driver command line -# (test module using testscript tests). -# - -+mkdir build -+cat <<"EOI" >=build/bootstrap.build -project = test -amalgamation = - -using test -EOI - -# We assume the specified target if any is in out_base which would be two -# levels up from our working directory. -# -+if! $empty($target) - cat <<"EOI" >=build/root.build - target = \$src_root/../../$string([name] $target) - test{*}: test = \$target - EOI -end - -# The "cat & build" setup: first cat ($c) the testscript, then run build ($b) -# which will execute the testscript. We have to quote stdin because of the -# command line re-expansion. -# -# Note that the buildfile is clever hack that relies on the first target -# automatically becoming dir{./}'s prerequisite. -# -c = cat >=testscript -b = $0 --serial-stop --quiet --buildfile - test <"'test{testscript}: \$target'" \ -&?test/*** diff --git a/tests/test/script/common.testscript b/tests/test/script/common.testscript new file mode 100644 index 0000000..b509818 --- /dev/null +++ b/tests/test/script/common.testscript @@ -0,0 +1,37 @@ +# file : tests/test/script/common.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Commonly-used build system test project setup and driver command line +# (test module using testscript tests). +# + ++mkdir build ++cat <<"EOI" >=build/bootstrap.build +project = test +amalgamation = + +using test +EOI + +# We assume the specified target if any is in out_base which would be two +# levels up from our working directory. +# ++if! $empty($target) + cat <<"EOI" >=build/root.build + target = \$src_root/../../$string([name] $target) + testscript{*}: test = \$target + EOI +end + +# The "cat & build" setup: first cat ($c) the testscript, then run build ($b) +# which will execute the testscript. We have to quote stdin because of the +# command line re-expansion. +# +# Note that the buildfile is clever hack that relies on the first target +# automatically becoming dir{./}'s prerequisite. +# +c = cat >=testscript +b = $0 --serial-stop --quiet --buildfile - test \ +<"'testscript{testscript}: \$target'" \ +&?test/*** diff --git a/tests/test/script/generated/testscript b/tests/test/script/generated/testscript index 6f19fb1..0a28aa0 100644 --- a/tests/test/script/generated/testscript +++ b/tests/test/script/generated/testscript @@ -4,9 +4,9 @@ test.arguments = test clean -# Note: using common.test from test/, not script/. +# Note: using common.testscript from test/, not script/. # -.include ../../common.test +.include ../../common.testscript # @@ in module # diff --git a/tests/test/script/integration/testscript b/tests/test/script/integration/testscript index 7176e0e..7bdad54 100644 --- a/tests/test/script/integration/testscript +++ b/tests/test/script/integration/testscript @@ -2,19 +2,19 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# Note: using common.test from test/, not script/. +# Note: using common.testscript from test/, not script/. # -.include ../../common.test +.include ../../common.testscript : script-files : { - +touch testscript foo.test bar.test + +touch testscript foo.testscript bar.testscript : testscript-and-other : $* <>/EOE != 0 - ./: ../testscript test{../foo} + ./: ../testscript testscript{../foo} EOI error: both 'testscript' and other names specified for dir{./} EOE @@ -22,7 +22,7 @@ : other-and-testscript : $* <>/EOE != 0 - ./: test{../foo} ../testscript + ./: testscript{../foo} ../testscript EOI error: both 'testscript' and other names specified for dir{./} EOE @@ -30,7 +30,7 @@ : others : $* <>~%EOE% != 0 -./: test{foo} +./: testscript{foo} EOI %error: working directory test[/\\] is a file/symlink% EOE : wd-exists-before : -touch foo.test; +touch foo.testscript; mkdir test &!test/; $* <>/EOE -./: test{foo} +./: testscript{foo} EOI warning: working directory test/ exists at the beginning of the test EOE : wd-not-empty-before : -touch foo.test; +touch foo.testscript; mkdir test &!test/; touch test/dummy &!test/dummy; $* <>/EOE -./: test{foo} +./: testscript{foo} EOI warning: working directory test/ exists and is not empty at the beginning of the test EOE @@ -76,11 +76,11 @@ EOE : scope. Also note that we still have to remove everything after detecting the : failure. : -cat <=foo.test; +cat <=foo.testscript; touch ../../dummy EOI $* <>/EOE &test/*** != 0 -./: test{foo} +./: testscript{foo} EOI error: working directory test/ is not empty at the end of the test EOE diff --git a/tests/test/script/runner/buildfile b/tests/test/script/runner/buildfile index 0067ec1..6e8bdd3 100644 --- a/tests/test/script/runner/buildfile +++ b/tests/test/script/runner/buildfile @@ -2,9 +2,9 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} exe{driver} $b +./: testscript{*} exe{driver} $b -test{*}: target = exe{driver} +testscript{*}: target = exe{driver} import libs = libbutl%lib{butl} exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test deleted file mode 100644 index 2d99215..0000000 --- a/tests/test/script/runner/cleanup.test +++ /dev/null @@ -1,346 +0,0 @@ -# file : tests/test/script/runner/cleanup.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -b += --no-column - -: file -: -{ - : always - : - $c <'$* -f a &a' && $b - - : maybe - : - $c <'$* &?a' && $b - - : never - : - $c <'$* &!a' && $b - - : implicit - : - : Test that a file created out of the testscript working directory is not - : implicitly registered for cleanup. If it were, the test would fail due to - : the file absence at the cleanup time. - : - $c <+a; - rm a - EOI - - : not-exists - : - : Test cleanup of non-existing file. - : - $c <'$* &a' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup file test/1/a does not exist - EOE - - : out-wd - : - : Test explicit cleanup of a file out of the testscript working directory. - : - $c <'$* &../../a' && $b 2>>/EOE != 0 - testscript:1: error: file cleanup ../../a is out of working directory test/ - EOE - - : in-wd - : - : Test cleanup explicit registration of a file being outside the test working - : directory but inside the script working directory. - : - $c <'$* &../a' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup file test/a does not exist - EOE - - : not-file - : - : Test cleanup of a directory as a file. - : - $c <'$* -d a &a' && $b 2>>/~%EOE% != 0 - %error: unable to remove file test/1/a: .+% - EOE -} - -: dir -: -{ - : always - : - $c <'$* -d a &a/' && $b - - : maybe - : - $c <'$* &?a/' && $b - - : implicit - : - : Test that a directory created out of the testscript working directory is - : not implicitly registered for cleanup. If it were, the test would fail due - : to the directory absence at the cleanup time. - : - $c <>/EOE != 0 - testscript:1: error: registered for cleanup directory test/1/a/ does not exist - EOE - - : out-wd - : - : Test cleanup of a directory out of the testscript working directory. - : - $c <'$* &../../a/' && $b 2>>/EOE != 0 - testscript:1: error: directory cleanup ../../a/ is out of working directory test/ - EOE - - : in-wd - : - : Test cleanup explicit registration of a directory being outside the test - : working directory but inside the testscript working directory. - : - $c <'$* &../a/' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/a/ does not exist - EOE - - : not-empty - : - : Test cleanup of a non-empty directory. - : - { - : files - : - $c <>/~%EOE% != 0 - $* -d a -f a/0 -f a/1 -f a/2 -f a/3 -f a/4 -f a/5 -f a/6 -f a/7 -f a/8 \ - -f a/9 -f a/a -f a/b &a/ - EOI - testscript:2: error: registered for cleanup directory test/1/a/ is not empty - %.%{10} - and 2 more file(s) - EOE - - : dir - : - $c <'$* -d a/b' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/1/ is not empty - a/ - EOE - } - - : not-dir - : - : Test cleanup of a file as a directory. - : - $c <'$* -f a &a/' && $b 2>>/~%EOE% != 0 - %error: unable to remove directory test/1/a/: .+% - EOE -} - -: wildcard -: -{ - : self - : - { - : dirs - : - { - : always - : - $c <'$* -d a/b -d a/b/c &a/***/' && $b - - : maybe - : - $c <'$* &?a/***/' && $b - - : not-empty - : - $c <'$* -d a/b -d a/b/c -f a/c &a/***/' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/1/a/ is not empty - c - info: wildcard: 'test/1/a/***/' - EOE - } - - : all-entries - : - : Test the trailing triple-star special case. - : - { - : always - : - $c <'$* -d a1/b -f a1/b/c -d a2/b -f a2/b/c &a?/***' && $b - - : maybe - : - $c <'$* &?a/***' && $b - - : not-exists - : - : Test cleanup of a wildcard not matching any directory. - : - $c <'$* &a/***' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/1/a/ does not exist - EOE - - : out-wd - : - : Test cleanup of a wildcard out of the testscript working directory. - : - $c <'$* &../../a/***' && $b 2>>/EOE != 0 - testscript:1: error: wildcard cleanup ../../a/*** is out of working directory test/ - EOE - - : in-wd - : - : Test cleanup registration of a wildcard matching the directory that being - : outside the test working directory is inside the testscript working - : directory. - : - $c <'$* &../a/***' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/a/ does not exist - EOE - - : not-dir - : - : Test cleanup of a file as a wildcard. - : - $c <'$* -f a &a/***' && $b 2>>/~%EOE% != 0 - %error: unable to remove directory test/1/a/: .*% - EOE - } - } - - : dir - : - { - : always - : - { - : immediate - : - $c <'$* -d aa/b &aa/ &a*/*/' && $b - - : recursive - : - $c <'$* -d aa/b/c &aa/ &a?/**/' && $b - } - - : maybe - : - $c <'$* &?a/**/' && $b - - : not-exists - : - : Test cleanup of a wildcard that doesn't match any directory. - : - $c <'$* &a/**/' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup wildcard test/1/a/**/ doesn't match any directory - EOE - - : not-dir - : - : Test cleanup of a file as a directory wildcard. - : - $c <'$* -f a &a/**/' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup wildcard test/1/a/**/ doesn't match any directory - EOE - - : not-empty - : - : Test cleanup of a non-empty directory as a wildcard. - : - $c <'$* -d a/b/c -f a/b/d &a/**/' && $b 2>>/EOE != 0 - testscript:1: error: registered for cleanup directory test/1/a/b/ is not empty - d - info: wildcard: 'test/1/a/**/' - EOE - } - - : file - : - { - : always - : - { - : immediate - : - $c <'$* -d aa -f aa/c &aa/ &a?/*' && $b - - : recursive - : - $c <'$* -d aa/b -f aa/c -f aa/b/e &aa/ &aa/b/ &a*/**' && $b - } - - : maybe - : - $c <'$* &?a/**' && $b - } -} - -: order -: -: Test that cleanup is performed in registration reversed order. -: -$c <'$* -d a/b &a/ &a/b/' && $b - -: special-order -: -: Test that special files are cleaned before others, and there is no attempt -: to remove them twice (normally and with wildcard cleanup). -: -$c <'foo'; -$* -f bar &* -EOI - -: wd-wildcard -: -: Test that there is no attempt to remove working directory twice (normally and -: with wildcard cleanup). -: -$c <=a &!a' && $b 2>>/EOE != 0 -testscript:1: error: registered for cleanup directory test/1/ is not empty -a -EOE - -: explicit-overwrite -: -: Test an explicit cleanup not being overwritten with the implicit one. -: -$c <>/EOE != 0 -$* &!a; -$* -o foo >=a -EOO -testscript:2: error: registered for cleanup directory test/1/ is not empty -a -EOE diff --git a/tests/test/script/runner/cleanup.testscript b/tests/test/script/runner/cleanup.testscript new file mode 100644 index 0000000..7ea1acd --- /dev/null +++ b/tests/test/script/runner/cleanup.testscript @@ -0,0 +1,346 @@ +# file : tests/test/script/runner/cleanup.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +b += --no-column + +: file +: +{ + : always + : + $c <'$* -f a &a' && $b + + : maybe + : + $c <'$* &?a' && $b + + : never + : + $c <'$* &!a' && $b + + : implicit + : + : Test that a file created out of the testscript working directory is not + : implicitly registered for cleanup. If it were, the test would fail due to + : the file absence at the cleanup time. + : + $c <+a; + rm a + EOI + + : not-exists + : + : Test cleanup of non-existing file. + : + $c <'$* &a' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup file test/1/a does not exist + EOE + + : out-wd + : + : Test explicit cleanup of a file out of the testscript working directory. + : + $c <'$* &../../a' && $b 2>>/EOE != 0 + testscript:1: error: file cleanup ../../a is out of working directory test/ + EOE + + : in-wd + : + : Test cleanup explicit registration of a file being outside the test working + : directory but inside the script working directory. + : + $c <'$* &../a' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup file test/a does not exist + EOE + + : not-file + : + : Test cleanup of a directory as a file. + : + $c <'$* -d a &a' && $b 2>>/~%EOE% != 0 + %error: unable to remove file test/1/a: .+% + EOE +} + +: dir +: +{ + : always + : + $c <'$* -d a &a/' && $b + + : maybe + : + $c <'$* &?a/' && $b + + : implicit + : + : Test that a directory created out of the testscript working directory is + : not implicitly registered for cleanup. If it were, the test would fail due + : to the directory absence at the cleanup time. + : + $c <>/EOE != 0 + testscript:1: error: registered for cleanup directory test/1/a/ does not exist + EOE + + : out-wd + : + : Test cleanup of a directory out of the testscript working directory. + : + $c <'$* &../../a/' && $b 2>>/EOE != 0 + testscript:1: error: directory cleanup ../../a/ is out of working directory test/ + EOE + + : in-wd + : + : Test cleanup explicit registration of a directory being outside the test + : working directory but inside the testscript working directory. + : + $c <'$* &../a/' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/a/ does not exist + EOE + + : not-empty + : + : Test cleanup of a non-empty directory. + : + { + : files + : + $c <>/~%EOE% != 0 + $* -d a -f a/0 -f a/1 -f a/2 -f a/3 -f a/4 -f a/5 -f a/6 -f a/7 -f a/8 \ + -f a/9 -f a/a -f a/b &a/ + EOI + testscript:2: error: registered for cleanup directory test/1/a/ is not empty + %.%{10} + and 2 more file(s) + EOE + + : dir + : + $c <'$* -d a/b' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/1/ is not empty + a/ + EOE + } + + : not-dir + : + : Test cleanup of a file as a directory. + : + $c <'$* -f a &a/' && $b 2>>/~%EOE% != 0 + %error: unable to remove directory test/1/a/: .+% + EOE +} + +: wildcard +: +{ + : self + : + { + : dirs + : + { + : always + : + $c <'$* -d a/b -d a/b/c &a/***/' && $b + + : maybe + : + $c <'$* &?a/***/' && $b + + : not-empty + : + $c <'$* -d a/b -d a/b/c -f a/c &a/***/' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/1/a/ is not empty + c + info: wildcard: 'test/1/a/***/' + EOE + } + + : all-entries + : + : Test the trailing triple-star special case. + : + { + : always + : + $c <'$* -d a1/b -f a1/b/c -d a2/b -f a2/b/c &a?/***' && $b + + : maybe + : + $c <'$* &?a/***' && $b + + : not-exists + : + : Test cleanup of a wildcard not matching any directory. + : + $c <'$* &a/***' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/1/a/ does not exist + EOE + + : out-wd + : + : Test cleanup of a wildcard out of the testscript working directory. + : + $c <'$* &../../a/***' && $b 2>>/EOE != 0 + testscript:1: error: wildcard cleanup ../../a/*** is out of working directory test/ + EOE + + : in-wd + : + : Test cleanup registration of a wildcard matching the directory that being + : outside the test working directory is inside the testscript working + : directory. + : + $c <'$* &../a/***' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/a/ does not exist + EOE + + : not-dir + : + : Test cleanup of a file as a wildcard. + : + $c <'$* -f a &a/***' && $b 2>>/~%EOE% != 0 + %error: unable to remove directory test/1/a/: .*% + EOE + } + } + + : dir + : + { + : always + : + { + : immediate + : + $c <'$* -d aa/b &aa/ &a*/*/' && $b + + : recursive + : + $c <'$* -d aa/b/c &aa/ &a?/**/' && $b + } + + : maybe + : + $c <'$* &?a/**/' && $b + + : not-exists + : + : Test cleanup of a wildcard that doesn't match any directory. + : + $c <'$* &a/**/' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup wildcard test/1/a/**/ doesn't match any directory + EOE + + : not-dir + : + : Test cleanup of a file as a directory wildcard. + : + $c <'$* -f a &a/**/' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup wildcard test/1/a/**/ doesn't match any directory + EOE + + : not-empty + : + : Test cleanup of a non-empty directory as a wildcard. + : + $c <'$* -d a/b/c -f a/b/d &a/**/' && $b 2>>/EOE != 0 + testscript:1: error: registered for cleanup directory test/1/a/b/ is not empty + d + info: wildcard: 'test/1/a/**/' + EOE + } + + : file + : + { + : always + : + { + : immediate + : + $c <'$* -d aa -f aa/c &aa/ &a?/*' && $b + + : recursive + : + $c <'$* -d aa/b -f aa/c -f aa/b/e &aa/ &aa/b/ &a*/**' && $b + } + + : maybe + : + $c <'$* &?a/**' && $b + } +} + +: order +: +: Test that cleanup is performed in registration reversed order. +: +$c <'$* -d a/b &a/ &a/b/' && $b + +: special-order +: +: Test that special files are cleaned before others, and there is no attempt +: to remove them twice (normally and with wildcard cleanup). +: +$c <'foo'; +$* -f bar &* +EOI + +: wd-wildcard +: +: Test that there is no attempt to remove working directory twice (normally and +: with wildcard cleanup). +: +$c <=a &!a' && $b 2>>/EOE != 0 +testscript:1: error: registered for cleanup directory test/1/ is not empty +a +EOE + +: explicit-overwrite +: +: Test an explicit cleanup not being overwritten with the implicit one. +: +$c <>/EOE != 0 +$* &!a; +$* -o foo >=a +EOO +testscript:2: error: registered for cleanup directory test/1/ is not empty +a +EOE diff --git a/tests/test/script/runner/exit.test b/tests/test/script/runner/exit.test deleted file mode 100644 index 7933203..0000000 --- a/tests/test/script/runner/exit.test +++ /dev/null @@ -1,400 +0,0 @@ -# file : tests/test/script/runner/exit.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: special -: -{ - : pipelining - : - { - : to - : - $c <'exit | cat' && $b 2>>EOE != 0 - testscript:1:1: error: exit builtin must be the only pipe command - EOE - - : from - : - $c <'echo "foo" | exit' && $b 2>>EOE != 0 - testscript:1:1: error: exit builtin must be the only pipe command - EOE - } - - : redirecting - : - { - : stdin - : - $c <'exit >EOE != 0 - testscript:1:1: error: exit builtin stdin cannot be redirected - EOE - - : stdout - : - $c <'exit >foo' && $b 2>>EOE != 0 - testscript:1:1: error: exit builtin stdout cannot be redirected - EOE - - : stderr - : - $c <'exit 2>foo' && $b 2>>EOE != 0 - testscript:1:1: error: exit builtin stderr cannot be redirected - EOE - } - - : exit-code - : - $c <'exit != 0' && $b 2>>EOE != 0 - testscript:1:1: error: exit builtin exit code cannot be non-zero - EOE -} - -: arguments -: -{ - : none - : - $c <'exit' && $b - - : diagnostics - : - $c <'exit "foo"' && $b 2>>EOE != 0 - testscript:1:1: error: foo - EOE - - : unexpected - : - $c <'exit "foo" "bar"' && $b 2>>EOE != 0 - testscript:1:1: error: unexpected argument - EOE -} - -: execution -: -: Test that only expected commands are executed. Note that we rely on the fact -: that their execution is performed serially (see ../common.test for details). -: -{ - : test-scope - : - { - : success - : - : Note that we also test that cleanups are executed. - : - $c <>EOO - touch -f a; - echo foo >| && exit && echo bar >|; - echo baz >| - echo box >| - EOI - foo - box - EOO - - : failure - : - : Note that we also register fake cleanup, and test that cleanups are - : not executed. If they were, there would be a diagnostics printed to - : stderr regarding non-existent file. - : - $c <>EOO 2>'testscript:1:1: error: message' != 0 - echo foo >| &b && exit 'message' && echo bar >| - echo baz >|; - echo boz >| - EOI - foo - EOO - } - - : command-if - : - { - : if-clause - : - { - : success - : - $c <| - else - echo bar >| - end; - echo baz >| - EOI - - : failure - : - $c <'testscript:2:3: error: message' != 0 - if true - exit 'message' - echo foo >| - else - echo bar >| - end - echo baz >| - EOI - } - - : else-clause - : - { - : success - : - $c <| - else - exit - echo bar >| - end; - echo baz >| - EOI - - : failure - : - $c <'testscript:4:3: error: message' != 0 - if false - echo foo >| - else - exit 'message' - echo bar >| - end - echo baz >| - EOI - } - } - - : command-if-condition - : - { - : if - : - { - : success - : - $c <| - else - echo bar >| - end; - echo baz >| - EOI - - : failure - : - $c <'testscript:1:1: error: message' != 0 - if exit 'message' - echo foo >| - else - echo bar >| - end; - echo baz >| - EOI - } - - : elif - : - { - : success - : - $c <| - else - echo bar >| - end; - echo baz >| - EOI - - : failure - : - $c <'testscript:2:1: error: message' != 0 - if false - elif exit 'message' - echo foo >| - else - echo bar >| - end; - echo baz >| - EOI - } - } - - : scope-if-condition - : - { - : if - : - { - : success - : - $c <| - } - else - { - echo bar >| - } - EOI - - : failure - : - $c <'testscript:1:1: error: message' != 0 - if exit 'message' - { - echo foo >| - } - else - { - echo bar >| - } - EOI - } - - : elif - : - { - : success - : - $c <| - } - else - { - echo bar >| - } - EOI - - : failure - : - $c <'testscript:4:1: error: message' != 0 - if false - { - } - elif exit 'message' - { - echo foo >| - } - else - { - echo bar >| - } - EOI - } - } - - : group-scope - : - { - : setup - : - { - : success - : - : Test that teardown commands are executed (the 'a' file is removed), and - : cleanups are executed as well (the 'b' file is removed). - : - $c <| - - -rm a - EOI - - : failure - : - : Test that teardown commands are not executed (the touch would fail), - : and cleanups are also not executed (they would fail due to non-existent - : file 'a'). - : - $c <'testscript:2:2: error: message' != 0 - +true &a - +exit 'message' - - echo foo >| - - -touch b/c - EOI - } - - : inner-scope - : - { - : success - : - : Test that teardown commands and cleanups are executed (see above), and - : also that the independent inner scope is still executed. - : - $c <>EOO - +touch --no-cleanup a - +touch b - - exit - - echo foo >| - - -rm a - EOI - foo - EOO - - : failure - : - : Test that teardown commands and cleanups are not executed (see above), - : as well as the independent inner scope (remember the sequential - : execution). - : - $c <'testscript:3:1: error: message' != 0 - +true &a - - exit 'message' - - echo foo >| - - -touch b/c - EOI - } - - : teardown - : - { - : success - : - : Test that cleanups are executed. - : - $c <| - EOI - - : failure - : - : Test that cleanups are not executed. - : - $c <'testscript:2:2: error: message' != 0 - -true &a - -exit 'message' - -echo foo >| - EOI - } - } -} diff --git a/tests/test/script/runner/exit.testscript b/tests/test/script/runner/exit.testscript new file mode 100644 index 0000000..9329ae4 --- /dev/null +++ b/tests/test/script/runner/exit.testscript @@ -0,0 +1,400 @@ +# file : tests/test/script/runner/exit.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: special +: +{ + : pipelining + : + { + : to + : + $c <'exit | cat' && $b 2>>EOE != 0 + testscript:1:1: error: exit builtin must be the only pipe command + EOE + + : from + : + $c <'echo "foo" | exit' && $b 2>>EOE != 0 + testscript:1:1: error: exit builtin must be the only pipe command + EOE + } + + : redirecting + : + { + : stdin + : + $c <'exit >EOE != 0 + testscript:1:1: error: exit builtin stdin cannot be redirected + EOE + + : stdout + : + $c <'exit >foo' && $b 2>>EOE != 0 + testscript:1:1: error: exit builtin stdout cannot be redirected + EOE + + : stderr + : + $c <'exit 2>foo' && $b 2>>EOE != 0 + testscript:1:1: error: exit builtin stderr cannot be redirected + EOE + } + + : exit-code + : + $c <'exit != 0' && $b 2>>EOE != 0 + testscript:1:1: error: exit builtin exit code cannot be non-zero + EOE +} + +: arguments +: +{ + : none + : + $c <'exit' && $b + + : diagnostics + : + $c <'exit "foo"' && $b 2>>EOE != 0 + testscript:1:1: error: foo + EOE + + : unexpected + : + $c <'exit "foo" "bar"' && $b 2>>EOE != 0 + testscript:1:1: error: unexpected argument + EOE +} + +: execution +: +: Test that only expected commands are executed. Note that we rely on the fact +: that their execution is performed serially (see ../common.testscript for details). +: +{ + : test-scope + : + { + : success + : + : Note that we also test that cleanups are executed. + : + $c <>EOO + touch -f a; + echo foo >| && exit && echo bar >|; + echo baz >| + echo box >| + EOI + foo + box + EOO + + : failure + : + : Note that we also register fake cleanup, and test that cleanups are + : not executed. If they were, there would be a diagnostics printed to + : stderr regarding non-existent file. + : + $c <>EOO 2>'testscript:1:1: error: message' != 0 + echo foo >| &b && exit 'message' && echo bar >| + echo baz >|; + echo boz >| + EOI + foo + EOO + } + + : command-if + : + { + : if-clause + : + { + : success + : + $c <| + else + echo bar >| + end; + echo baz >| + EOI + + : failure + : + $c <'testscript:2:3: error: message' != 0 + if true + exit 'message' + echo foo >| + else + echo bar >| + end + echo baz >| + EOI + } + + : else-clause + : + { + : success + : + $c <| + else + exit + echo bar >| + end; + echo baz >| + EOI + + : failure + : + $c <'testscript:4:3: error: message' != 0 + if false + echo foo >| + else + exit 'message' + echo bar >| + end + echo baz >| + EOI + } + } + + : command-if-condition + : + { + : if + : + { + : success + : + $c <| + else + echo bar >| + end; + echo baz >| + EOI + + : failure + : + $c <'testscript:1:1: error: message' != 0 + if exit 'message' + echo foo >| + else + echo bar >| + end; + echo baz >| + EOI + } + + : elif + : + { + : success + : + $c <| + else + echo bar >| + end; + echo baz >| + EOI + + : failure + : + $c <'testscript:2:1: error: message' != 0 + if false + elif exit 'message' + echo foo >| + else + echo bar >| + end; + echo baz >| + EOI + } + } + + : scope-if-condition + : + { + : if + : + { + : success + : + $c <| + } + else + { + echo bar >| + } + EOI + + : failure + : + $c <'testscript:1:1: error: message' != 0 + if exit 'message' + { + echo foo >| + } + else + { + echo bar >| + } + EOI + } + + : elif + : + { + : success + : + $c <| + } + else + { + echo bar >| + } + EOI + + : failure + : + $c <'testscript:4:1: error: message' != 0 + if false + { + } + elif exit 'message' + { + echo foo >| + } + else + { + echo bar >| + } + EOI + } + } + + : group-scope + : + { + : setup + : + { + : success + : + : Test that teardown commands are executed (the 'a' file is removed), and + : cleanups are executed as well (the 'b' file is removed). + : + $c <| + + -rm a + EOI + + : failure + : + : Test that teardown commands are not executed (the touch would fail), + : and cleanups are also not executed (they would fail due to non-existent + : file 'a'). + : + $c <'testscript:2:2: error: message' != 0 + +true &a + +exit 'message' + + echo foo >| + + -touch b/c + EOI + } + + : inner-scope + : + { + : success + : + : Test that teardown commands and cleanups are executed (see above), and + : also that the independent inner scope is still executed. + : + $c <>EOO + +touch --no-cleanup a + +touch b + + exit + + echo foo >| + + -rm a + EOI + foo + EOO + + : failure + : + : Test that teardown commands and cleanups are not executed (see above), + : as well as the independent inner scope (remember the sequential + : execution). + : + $c <'testscript:3:1: error: message' != 0 + +true &a + + exit 'message' + + echo foo >| + + -touch b/c + EOI + } + + : teardown + : + { + : success + : + : Test that cleanups are executed. + : + $c <| + EOI + + : failure + : + : Test that cleanups are not executed. + : + $c <'testscript:2:2: error: message' != 0 + -true &a + -exit 'message' + -echo foo >| + EOI + } + } +} diff --git a/tests/test/script/runner/expr.test b/tests/test/script/runner/expr.test deleted file mode 100644 index cfc5277..0000000 --- a/tests/test/script/runner/expr.test +++ /dev/null @@ -1,522 +0,0 @@ -# file : tests/test/script/runner/expr.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: short-circuit -: -: Test expression result calculation and short-circuiting. We verify the -: correctness of the above for all possible expressions of a length up to 3 -: operands. While some of tests may look redundant the full expression tree is -: easier to maintain than the one with gaps (also much less chances that we -: have missed something useful). Each pipe-operand has a label which is printed -: to stdout when the pipe is executed. Pipes stdouts are pass-redirected, so we -: just check that build2 output matches expectations. -: -: Note that expression evaluation goes left-to-right with AND and OR having the -: same precedence. -: -{ - true = '$* >| -o' - false = '$* -s 1 >| -o' - - bf = $b 2>/~'%.+/driver(\.exe)? exit code 1 != 0%' - - : true - : - { - : TERM - : - $c <"$true 1" && $b >>EOO - 1 - EOO - - : OR - : - { - : true - : - { - : TERM - : - $c <"$true 1 || $true 2" && $b >>EOO - 1 - EOO - - : OR - : - { - : true - : - { - $c <"$true 1 || $true 2 || $true 3" && $b >>EOO - 1 - EOO - } - - : false - : - { - $c <"$true 1 || $true 2 || $false 3" && $b >>EOO - 1 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$true 1 || $true 2 && $true 3" && $b >>EOO - 1 - 3 - EOO - } - - : false - : - { - $c <"$true 1 || $true 2 && $false 3" && $bf >>EOO != 0 - 1 - 3 - EOO - } - } - } - - : false - : - { - : TERM - : - $c <"$true 1 || $false 2" && $b >>EOO - 1 - EOO - - : OR - : - { - : true - : - { - $c <"$true 1 || $false 2 || $true 3" && $b >>EOO - 1 - EOO - } - - : false - : - { - $c <"$true 1 || $false 2 || $false 3" && $b >>EOO - 1 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$true 1 || $false 2 && $true 3" && $b >>EOO - 1 - 3 - EOO - } - - : false - : - { - $c <"$true 1 || $false 2 && $false 3" && $bf >>EOO != 0 - 1 - 3 - EOO - } - } - } - } - - : AND - : - { - : true - : - { - : TERM - : - $c <"$true 1 && $true 2" && $b >>EOO - 1 - 2 - EOO - - : OR - : - { - : true - : - { - $c <"$true 1 && $true 2 || $true 3" && $b >>EOO - 1 - 2 - EOO - } - - : false - : - { - $c <"$true 1 && $true 2 || $false 3" && $b >>EOO - 1 - 2 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$true 1 && $true 2 && $true 3" && $b >>EOO - 1 - 2 - 3 - EOO - } - - : false - : - { - $c <"$true 1 && $true 2 && $false 3" && $bf >>EOO != 0 - 1 - 2 - 3 - EOO - } - } - } - - : false - : - { - : TERM - : - $c <"$true 1 && $false 2" && $bf >>EOO != 0 - 1 - 2 - EOO - - : OR - : - { - : true - : - { - $c <"$true 1 && $false 2 || $true 3" && $b >>EOO - 1 - 2 - 3 - EOO - } - - : false - : - { - $c <"$true 1 && $false 2 || $false 3" && $bf >>EOO != 0 - 1 - 2 - 3 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$true 1 && $false 2 && $true 3" && $bf >>EOO != 0 - 1 - 2 - EOO - } - - : false - : - { - $c <"$true 1 && $false 2 && $false 3" && $bf >>EOO != 0 - 1 - 2 - EOO - } - } - } - } - } - - : false - : - { - : TERM - : - $c <"$false 1" && $bf >>EOO != 0 - 1 - EOO - - : OR - : - { - : true - : - { - : TERM - : - $c <"$false 1 || $true 2" && $b >>EOO - 1 - 2 - EOO - - : OR - : - { - : true - : - { - $c <"$false 1 || $true 2 || $true 3" && $b >>EOO - 1 - 2 - EOO - } - - : false - : - { - $c <"$false 1 || $true 2 || $false 3" && $b >>EOO - 1 - 2 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$false 1 || $true 2 && $true 3" && $b >>EOO - 1 - 2 - 3 - EOO - } - - : false - : - { - $c <"$false 1 || $true 2 && $false 3" && $bf >>EOO != 0 - 1 - 2 - 3 - EOO - } - } - } - - : false - : - { - : TERM - : - $c <"$false 1 || $false 2" && $bf >>EOO != 0 - 1 - 2 - EOO - - : OR - : - { - : true - : - { - $c <"$false 1 || $false 2 || $true 3" && $b >>EOO - 1 - 2 - 3 - EOO - } - - : false - : - { - $c <"$false 1 || $false 2 || $false 3" && $bf >>EOO != 0 - 1 - 2 - 3 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$false 1 || $false 2 && $true 3" && $bf >>EOO != 0 - 1 - 2 - EOO - } - - : false - : - { - $c <"$false 1 || $false 2 && $false 3" && $bf >>EOO != 0 - 1 - 2 - EOO - } - } - } - } - - : AND - : - { - : true - : - { - : TERM - : - $c <"$false 1 && $true 2" && $bf >>EOO != 0 - 1 - EOO - - : OR - : - { - : true - : - { - $c <"$false 1 && $true 2 || $true 3" && $b >>EOO - 1 - 3 - EOO - } - - : false - : - { - $c <"$false 1 && $true 2 || $false 3" && $bf >>EOO != 0 - 1 - 3 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$false 1 && $true 2 && $true 3" && $bf >>EOO != 0 - 1 - EOO - } - - : false - : - { - $c <"$false 1 && $true 2 && $false 3" && $bf >>EOO != 0 - 1 - EOO - } - } - } - - : false - : - { - : TERM - : - $c <"$false 1 && $false 2" && $bf >>EOO != 0 - 1 - EOO - - : OR - : - { - : true - : - { - $c <"$false 1 && $false 2 || $true 3" && $b >>EOO - 1 - 3 - EOO - } - - : false - : - { - $c <"$false 1 && $false 2 || $false 3" && $bf >>EOO != 0 - 1 - 3 - EOO - } - } - - : AND - : - { - : true - : - { - $c <"$false 1 && $false 2 && $true 3" && $bf >>EOO != 0 - 1 - EOO - } - - : false - : - { - $c <"$false 1 && $false 2 && $false 3" && $bf >>EOO != 0 - 1 - EOO - } - } - } - } - } -} - -: diagnostics -: -: Check that the diagnostics is printed for only the last faulty pipe. -: -{ - true = '$*' - false = '$* -s 1 2>'X' -e' # Compares stderr to value that never matches. - - : trailing - : - $c <"$false 1 != 0 || $true && $false 2 != 0" && $b 2>>~/EOE/ != 0 - /.{7} - -X - +2 - EOE - - : non-trailing - : - $c <"$false 1 != 0 || $true && $false 2 != 0 && $true" && $b 2>>~/EOE/ != 0 - /.{7} - -X - +2 - EOE -} diff --git a/tests/test/script/runner/expr.testscript b/tests/test/script/runner/expr.testscript new file mode 100644 index 0000000..36c15fd --- /dev/null +++ b/tests/test/script/runner/expr.testscript @@ -0,0 +1,522 @@ +# file : tests/test/script/runner/expr.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: short-circuit +: +: Test expression result calculation and short-circuiting. We verify the +: correctness of the above for all possible expressions of a length up to 3 +: operands. While some of tests may look redundant the full expression tree is +: easier to maintain than the one with gaps (also much less chances that we +: have missed something useful). Each pipe-operand has a label which is printed +: to stdout when the pipe is executed. Pipes stdouts are pass-redirected, so we +: just check that build2 output matches expectations. +: +: Note that expression evaluation goes left-to-right with AND and OR having the +: same precedence. +: +{ + true = '$* >| -o' + false = '$* -s 1 >| -o' + + bf = $b 2>/~'%.+/driver(\.exe)? exit code 1 != 0%' + + : true + : + { + : TERM + : + $c <"$true 1" && $b >>EOO + 1 + EOO + + : OR + : + { + : true + : + { + : TERM + : + $c <"$true 1 || $true 2" && $b >>EOO + 1 + EOO + + : OR + : + { + : true + : + { + $c <"$true 1 || $true 2 || $true 3" && $b >>EOO + 1 + EOO + } + + : false + : + { + $c <"$true 1 || $true 2 || $false 3" && $b >>EOO + 1 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$true 1 || $true 2 && $true 3" && $b >>EOO + 1 + 3 + EOO + } + + : false + : + { + $c <"$true 1 || $true 2 && $false 3" && $bf >>EOO != 0 + 1 + 3 + EOO + } + } + } + + : false + : + { + : TERM + : + $c <"$true 1 || $false 2" && $b >>EOO + 1 + EOO + + : OR + : + { + : true + : + { + $c <"$true 1 || $false 2 || $true 3" && $b >>EOO + 1 + EOO + } + + : false + : + { + $c <"$true 1 || $false 2 || $false 3" && $b >>EOO + 1 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$true 1 || $false 2 && $true 3" && $b >>EOO + 1 + 3 + EOO + } + + : false + : + { + $c <"$true 1 || $false 2 && $false 3" && $bf >>EOO != 0 + 1 + 3 + EOO + } + } + } + } + + : AND + : + { + : true + : + { + : TERM + : + $c <"$true 1 && $true 2" && $b >>EOO + 1 + 2 + EOO + + : OR + : + { + : true + : + { + $c <"$true 1 && $true 2 || $true 3" && $b >>EOO + 1 + 2 + EOO + } + + : false + : + { + $c <"$true 1 && $true 2 || $false 3" && $b >>EOO + 1 + 2 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$true 1 && $true 2 && $true 3" && $b >>EOO + 1 + 2 + 3 + EOO + } + + : false + : + { + $c <"$true 1 && $true 2 && $false 3" && $bf >>EOO != 0 + 1 + 2 + 3 + EOO + } + } + } + + : false + : + { + : TERM + : + $c <"$true 1 && $false 2" && $bf >>EOO != 0 + 1 + 2 + EOO + + : OR + : + { + : true + : + { + $c <"$true 1 && $false 2 || $true 3" && $b >>EOO + 1 + 2 + 3 + EOO + } + + : false + : + { + $c <"$true 1 && $false 2 || $false 3" && $bf >>EOO != 0 + 1 + 2 + 3 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$true 1 && $false 2 && $true 3" && $bf >>EOO != 0 + 1 + 2 + EOO + } + + : false + : + { + $c <"$true 1 && $false 2 && $false 3" && $bf >>EOO != 0 + 1 + 2 + EOO + } + } + } + } + } + + : false + : + { + : TERM + : + $c <"$false 1" && $bf >>EOO != 0 + 1 + EOO + + : OR + : + { + : true + : + { + : TERM + : + $c <"$false 1 || $true 2" && $b >>EOO + 1 + 2 + EOO + + : OR + : + { + : true + : + { + $c <"$false 1 || $true 2 || $true 3" && $b >>EOO + 1 + 2 + EOO + } + + : false + : + { + $c <"$false 1 || $true 2 || $false 3" && $b >>EOO + 1 + 2 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$false 1 || $true 2 && $true 3" && $b >>EOO + 1 + 2 + 3 + EOO + } + + : false + : + { + $c <"$false 1 || $true 2 && $false 3" && $bf >>EOO != 0 + 1 + 2 + 3 + EOO + } + } + } + + : false + : + { + : TERM + : + $c <"$false 1 || $false 2" && $bf >>EOO != 0 + 1 + 2 + EOO + + : OR + : + { + : true + : + { + $c <"$false 1 || $false 2 || $true 3" && $b >>EOO + 1 + 2 + 3 + EOO + } + + : false + : + { + $c <"$false 1 || $false 2 || $false 3" && $bf >>EOO != 0 + 1 + 2 + 3 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$false 1 || $false 2 && $true 3" && $bf >>EOO != 0 + 1 + 2 + EOO + } + + : false + : + { + $c <"$false 1 || $false 2 && $false 3" && $bf >>EOO != 0 + 1 + 2 + EOO + } + } + } + } + + : AND + : + { + : true + : + { + : TERM + : + $c <"$false 1 && $true 2" && $bf >>EOO != 0 + 1 + EOO + + : OR + : + { + : true + : + { + $c <"$false 1 && $true 2 || $true 3" && $b >>EOO + 1 + 3 + EOO + } + + : false + : + { + $c <"$false 1 && $true 2 || $false 3" && $bf >>EOO != 0 + 1 + 3 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$false 1 && $true 2 && $true 3" && $bf >>EOO != 0 + 1 + EOO + } + + : false + : + { + $c <"$false 1 && $true 2 && $false 3" && $bf >>EOO != 0 + 1 + EOO + } + } + } + + : false + : + { + : TERM + : + $c <"$false 1 && $false 2" && $bf >>EOO != 0 + 1 + EOO + + : OR + : + { + : true + : + { + $c <"$false 1 && $false 2 || $true 3" && $b >>EOO + 1 + 3 + EOO + } + + : false + : + { + $c <"$false 1 && $false 2 || $false 3" && $bf >>EOO != 0 + 1 + 3 + EOO + } + } + + : AND + : + { + : true + : + { + $c <"$false 1 && $false 2 && $true 3" && $bf >>EOO != 0 + 1 + EOO + } + + : false + : + { + $c <"$false 1 && $false 2 && $false 3" && $bf >>EOO != 0 + 1 + EOO + } + } + } + } + } +} + +: diagnostics +: +: Check that the diagnostics is printed for only the last faulty pipe. +: +{ + true = '$*' + false = '$* -s 1 2>'X' -e' # Compares stderr to value that never matches. + + : trailing + : + $c <"$false 1 != 0 || $true && $false 2 != 0" && $b 2>>~/EOE/ != 0 + /.{7} + -X + +2 + EOE + + : non-trailing + : + $c <"$false 1 != 0 || $true && $false 2 != 0 && $true" && $b 2>>~/EOE/ != 0 + /.{7} + -X + +2 + EOE +} diff --git a/tests/test/script/runner/if.test b/tests/test/script/runner/if.test deleted file mode 100644 index f22f761..0000000 --- a/tests/test/script/runner/if.test +++ /dev/null @@ -1,25 +0,0 @@ -# file : tests/test/script/runner/if.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: if-branch -: -$c <'if' -if cat <'foo' >'foo' - echo 'if' >| -else - echo 'else' >| -end -EOI - -: else-branch -: -$c <'else' -if cat <'foo' >'bar' - echo 'if' >| -else - echo 'else' >| -end -EOI diff --git a/tests/test/script/runner/if.testscript b/tests/test/script/runner/if.testscript new file mode 100644 index 0000000..a625c34 --- /dev/null +++ b/tests/test/script/runner/if.testscript @@ -0,0 +1,25 @@ +# file : tests/test/script/runner/if.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: if-branch +: +$c <'if' +if cat <'foo' >'foo' + echo 'if' >| +else + echo 'else' >| +end +EOI + +: else-branch +: +$c <'else' +if cat <'foo' >'bar' + echo 'if' >| +else + echo 'else' >| +end +EOI diff --git a/tests/test/script/runner/output.test b/tests/test/script/runner/output.test deleted file mode 100644 index a83c092..0000000 --- a/tests/test/script/runner/output.test +++ /dev/null @@ -1,87 +0,0 @@ -# file : tests/test/script/runner/output.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Some of the tests below (*/script-wd, before/*) are probably more appropriate -# for tests/test/script/script-integration/testscript. Nevertheless let's not -# spread the feature tests among several places. -# - -.include ../common.test - -: after -: -{ - : keep - : - { - : cleanup - : - $c <'touch a' && $b config.test.output=keep; - test -f test/1/a - - : teardown - : - $c <>/EOE != 0 - error: working directory test/ exists at the beginning of the test - EOE - - : warn - : - mkdir test &!test/; - $c <'true' && $b config.test.output=warn@clean 2>>/EOE - warning: working directory test/ exists at the beginning of the test - EOE - - : clean - : - mkdir test &!test/; - $c <'true' && $b config.test.output=clean@clean -} diff --git a/tests/test/script/runner/output.testscript b/tests/test/script/runner/output.testscript new file mode 100644 index 0000000..ec9ff92 --- /dev/null +++ b/tests/test/script/runner/output.testscript @@ -0,0 +1,87 @@ +# file : tests/test/script/runner/output.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Some of the tests below (*/script-wd, before/*) are probably more appropriate +# for tests/test/script/script-integration/testscript. Nevertheless let's not +# spread the feature tests among several places. +# + +.include ../common.testscript + +: after +: +{ + : keep + : + { + : cleanup + : + $c <'touch a' && $b config.test.output=keep; + test -f test/1/a + + : teardown + : + $c <>/EOE != 0 + error: working directory test/ exists at the beginning of the test + EOE + + : warn + : + mkdir test &!test/; + $c <'true' && $b config.test.output=warn@clean 2>>/EOE + warning: working directory test/ exists at the beginning of the test + EOE + + : clean + : + mkdir test &!test/; + $c <'true' && $b config.test.output=clean@clean +} diff --git a/tests/test/script/runner/pipe.test b/tests/test/script/runner/pipe.test deleted file mode 100644 index 03d8b2a..0000000 --- a/tests/test/script/runner/pipe.test +++ /dev/null @@ -1,35 +0,0 @@ -# file : tests/test/script/runner/pipe.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -$c <'cat foo' && $b : builtin-to-process -$c <'$* -o foo | cat >foo' && $b : process-to-builtin - - -: failure -: -: Note that while both commands for the pipe are faulty the diagnostics for -: only the last one is printed. -: -{ - : exit-code - : - $c <'$* -o foo -s 1 | $* -i 1 >foo -s 2' && $b 2>>/~%EOE% != 0 - %testscript:1:1: error: .+ exit code 2 != 0% - info: stdout: test/1/stdout-2 - EOE - - : stderr - : - $c <'$* -o foo -e foo 2>bar | $* -i 2 2>baz' && $b 2>>/~%EOE% != 0 - %testscript:1:1: error: .+ stderr doesn't match expected% - info: stderr: test/1/stderr-2 - info: expected stderr: test/1/stderr-2.orig - info: stderr diff: test/1/stderr-2.diff - %.{3} - -baz - +foo - EOE -} diff --git a/tests/test/script/runner/pipe.testscript b/tests/test/script/runner/pipe.testscript new file mode 100644 index 0000000..7ef5893 --- /dev/null +++ b/tests/test/script/runner/pipe.testscript @@ -0,0 +1,35 @@ +# file : tests/test/script/runner/pipe.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +$c <'cat foo' && $b : builtin-to-process +$c <'$* -o foo | cat >foo' && $b : process-to-builtin + + +: failure +: +: Note that while both commands for the pipe are faulty the diagnostics for +: only the last one is printed. +: +{ + : exit-code + : + $c <'$* -o foo -s 1 | $* -i 1 >foo -s 2' && $b 2>>/~%EOE% != 0 + %testscript:1:1: error: .+ exit code 2 != 0% + info: stdout: test/1/stdout-2 + EOE + + : stderr + : + $c <'$* -o foo -e foo 2>bar | $* -i 2 2>baz' && $b 2>>/~%EOE% != 0 + %testscript:1:1: error: .+ stderr doesn't match expected% + info: stderr: test/1/stderr-2 + info: expected stderr: test/1/stderr-2.orig + info: stderr diff: test/1/stderr-2.diff + %.{3} + -baz + +foo + EOE +} diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test deleted file mode 100644 index 13d7219..0000000 --- a/tests/test/script/runner/redirect.test +++ /dev/null @@ -1,515 +0,0 @@ -# file : tests/test/script/runner/redirect.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -b += --no-column - -ps = ($cxx.target.class != 'windows' ? '/' : '\') # Path separator. -psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. - -: pass -: -{ - cat <'$* -i 1 -e bar <| >| 2>|' >=testscript; - cat <=buildfile; - test{testscript}: $target - EOI - $0 --serial-stop --quiet test foo 2>bar -} - -: null -: -{ - $c <'$* -o foo >-' && $b : out - $c <'$* -e foo 2>-' && $b : err -} - -: trace -: -{ - : default - : - $c <'$* -o foo -e bar >! 2>!' && $b - - : verbose - : - { - b += -v - - : out - : - $c <'$* -o foo >!' && $b >foo 2>>/~%EOE% - %test .+% - mkdir test/ - cd test/ - mkdir test/1/ - cd test/1/ - %.*/driver(.exe)? -o foo% - rmdir test/1/ - cd test/ - rmdir test/ - cd ./ - EOE - - : err - : - $c <'$* -e foo 2>!' && $b 2>>/~%EOE% - %test .+% - mkdir test/ - cd test/ - mkdir test/1/ - cd test/1/ - %.*/driver(.exe)? -e foo% - foo - rmdir test/1/ - cd test/ - rmdir test/ - cd ./ - EOE - } -} - -: str -: -{ - : literal - : - { - $c <'$* -i 0 foo' && $b : out - $c <'$* -e foo 2>foo' && $b : err - $c <'$* -i 1 foo' && $b : inout - - : inout-fail - : - $c <'$* -i 1 bar' && $b 2>>/~%EOE%d != 0 - %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match expected% - info: stdout: test/1/stdout - info: expected stdout: test/1/stdout.orig - info: stdout diff: test/1/stdout.diff - info: stdin: test/1/stdin - %--- \.*% - %\+\+\+ \.*% - %@@ \.*% - -bar - +foo - EOE - - $c <'$* -i 2 foo' && $b : inerr - $c <'$* -i 1 -e bar foo 2>bar' && $b : inout-err - $c <'$* -o "" >""' && $b : empty - $c <'$* -i 1 <:"foo" >:"foo"' && $b : no-newline - $c <'$* -i 1 <:"" >:""' && $b : no-newline-empty - - : no-newline-fail1 - : - $c <'$* -i 1 <:"foo" >"foo"' && $b 2>>~/EOE/ != 0 - /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ - /.{7} - -foo - +foo - \ No newline at end of file - EOE - - : no-newline-fail2 - : - $c <'$* -i 1 <"foo" >:"foo"' && $b 2>>~/EOE/ != 0 - /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ - /.{7} - -foo - \ No newline at end of file - +foo - EOE - - : merge - : - $c <>EOE 1>&2 - foo - bar - EOE - EOI - - : portable-path - : - { - $c <"\$* -i 1 'foo$ps'" && $b : in - $c <"\$* -i 1 <'foo$ps' >/'foo/'" && $b : out - $c <"\$* -i 2 <'foo$ps' 2>/'foo/'" && $b : err - } - } - - : regex - : - : Test regex matching. Note that tests that check regex parsing are located - : in regex.test testscript. - : - { - : match - : - $c <'$* -o foo >~/Foo?/i' && $b - - : mismatch - : - $c <'$* -o fooo >~/Foo?/i' && $b 2>>/~%EOE%d != 0 - %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - fooo - EOE - - : portable-path-failure - : - : Note that we check not only build2 diagnostics being produced, but also - : the correctness of regex being saved to file (for troubleshooting). - : - { - : newline - : - $c <"\$* -i 1 <'foo' >/~%bar/%" && $b 2>>/~%EOE%d != 0; - %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - info: stdin: test/1/stdin - foo - EOE - cat test/1/stdout.regex >"%bar$psr%" - - : no-newline - : - $c <"\$* -i 1 <'foo' >:/~%bar/%" && $b 2>>/~%EOE%d != 0; - %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - info: stdin: test/1/stdin - foo - EOE - cat test/1/stdout.regex >:"%bar$psr%" - } - } -} - -: doc -: -{ - : literal - : - { - : in - : - $c <>EOO - foo - bar - EOO - EOI - - : err - : - $c <>EOO - foo - bar - EOO - EOI - - : inout - : - $c <>EOO - foo - bar - EOF - foo - bar - EOO - EOI - - : inerr - : - $c <>EOE - foo - bar - EOF - foo - bar - EOE - EOI - - : empty - : - $c <>EOO - EOF - EOO - EOI - - : shared - : - $c <>EOF - foo - bar - EOF - EOI - - : extra-newline - : - $c <>EOO - - EOF - - EOO - EOI - - : no-newline - : - $c <>:EOO - foo - EOF - foo - EOO - EOI - - : no-newline-fail1 - : - $c <>~/EOE/ != 0 - $* -i 1 <<:EOF >>EOO - foo - EOF - foo - EOO - EOI - /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ - /.{7} - -foo - +foo - \ No newline at end of file - EOE - - : no-newline-fail2 - : - $c <>~/EOE/ != 0 - $* -i 1 <>:EOO - foo - EOF - foo - EOO - EOI - /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ - /.{7} - -foo - \ No newline at end of file - +foo - EOE - - : no-newline-empty - : - $c <>:EOO - EOF - EOO - EOI - - : no-newline-extra-newline - : - $c <>:EOO - - EOF - - EOO - EOI - - : merge - : - $c <>EOO 2>&1 - foo - bar - EOF - foo - bar - baz - EOO - EOI - - : large-diff - : - : Make sure that the large (>4KB) expected/real output difference is not - : printed as a part of the diagnostics. - : - $c <>/~%EOE%d != 0 - s="----------------------------------------------------------------------"; - s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"; - $* -i 1 <<"EOF" >>"EOO" - $s - EOF - x$s - EOO - EOI - %testscript:3: error: ../../../../../driver(.exe)? stdout doesn't match expected% - info: stdout: test/1/stdout - info: expected stdout: test/1/stdout.orig - info: stdout diff: test/1/stdout.diff - info: stdin: test/1/stdin - EOE - - : portable-path - : - { - : in - : - $c <<"EOI" && $b - \$* -i 1 <'foo$ps' - foo/ - EOF - EOI - - : out - : - $c <<"EOI" && $b - \$* -i 1 <'foo$ps' >>/EOO - foo/ - EOO - EOI - - : err - : - $c <<"EOI" && $b - \$* -i 2 <'foo$ps' 2>>/EOE - foo/ - EOE - EOI - } - } - - : regex - : - : Test regex matching. Note that tests that check regex parsing are located - : in regex.test testscript. - : - { - : match - : - $c <>~/EOO/i - /FO*/* - bar - /* - EOO - EOI - - : match-empty - : - $c <>:~/EOO/ - /.{0} - EOO - EOI - - : shared - : - $c <>~/EOF/ 2>>~/EOF/ - foo - EOF - EOI - - : mismatch - : - $c <>/~%EOE%d != 0 - $* -o foo >>~/EOO/ - bar - EOO - EOI - %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - foo - EOE - - : mismatch-icase - : - $c <>/~%EOE%d != 0 - $* -o foo >>~/EOO/i - bar - EOO - EOI - %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex-i - foo - EOE - } -} - -: file -: -{ - : in - : - $c <=out; - $* -i 1 <<foo - EOI - - : out - : - { - : match - : - $c <=out; - $* -e bar 2>+out; - $* -i 1 <>>out - foo - bar - EOF - EOI - - : mismatch - : - $c <>/~%EOE%d != 0 - $* -o foo >=out; - $* -o bar >>>out - EOI - %testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match expected% - info: stdout: test/1/stdout-2 - info: expected stdout: test/1/out - info: stdout diff: test/1/stdout-2.diff - %--- \.*% - %\+\+\+ \.*% - %@@ \.*% - -foo - +bar - EOE - } - - : merge - : - $c <&1 >=out; - $* -e baz -o biz 1>&2 2>+out; - $* -i 1 <<>EOO - foo - bar - baz - biz - EOO - EOI -} diff --git a/tests/test/script/runner/redirect.testscript b/tests/test/script/runner/redirect.testscript new file mode 100644 index 0000000..21e9d07 --- /dev/null +++ b/tests/test/script/runner/redirect.testscript @@ -0,0 +1,515 @@ +# file : tests/test/script/runner/redirect.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +b += --no-column + +ps = ($cxx.target.class != 'windows' ? '/' : '\') # Path separator. +psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. + +: pass +: +{ + cat <'$* -i 1 -e bar <| >| 2>|' >=testscript; + cat <=buildfile; + testscript{testscript}: $target + EOI + $0 --serial-stop --quiet test foo 2>bar +} + +: null +: +{ + $c <'$* -o foo >-' && $b : out + $c <'$* -e foo 2>-' && $b : err +} + +: trace +: +{ + : default + : + $c <'$* -o foo -e bar >! 2>!' && $b + + : verbose + : + { + b += -v + + : out + : + $c <'$* -o foo >!' && $b >foo 2>>/~%EOE% + %test .+% + mkdir test/ + cd test/ + mkdir test/1/ + cd test/1/ + %.*/driver(.exe)? -o foo% + rmdir test/1/ + cd test/ + rmdir test/ + cd ./ + EOE + + : err + : + $c <'$* -e foo 2>!' && $b 2>>/~%EOE% + %test .+% + mkdir test/ + cd test/ + mkdir test/1/ + cd test/1/ + %.*/driver(.exe)? -e foo% + foo + rmdir test/1/ + cd test/ + rmdir test/ + cd ./ + EOE + } +} + +: str +: +{ + : literal + : + { + $c <'$* -i 0 foo' && $b : out + $c <'$* -e foo 2>foo' && $b : err + $c <'$* -i 1 foo' && $b : inout + + : inout-fail + : + $c <'$* -i 1 bar' && $b 2>>/~%EOE%d != 0 + %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match expected% + info: stdout: test/1/stdout + info: expected stdout: test/1/stdout.orig + info: stdout diff: test/1/stdout.diff + info: stdin: test/1/stdin + %--- \.*% + %\+\+\+ \.*% + %@@ \.*% + -bar + +foo + EOE + + $c <'$* -i 2 foo' && $b : inerr + $c <'$* -i 1 -e bar foo 2>bar' && $b : inout-err + $c <'$* -o "" >""' && $b : empty + $c <'$* -i 1 <:"foo" >:"foo"' && $b : no-newline + $c <'$* -i 1 <:"" >:""' && $b : no-newline-empty + + : no-newline-fail1 + : + $c <'$* -i 1 <:"foo" >"foo"' && $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ + /.{7} + -foo + +foo + \ No newline at end of file + EOE + + : no-newline-fail2 + : + $c <'$* -i 1 <"foo" >:"foo"' && $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ + /.{7} + -foo + \ No newline at end of file + +foo + EOE + + : merge + : + $c <>EOE 1>&2 + foo + bar + EOE + EOI + + : portable-path + : + { + $c <"\$* -i 1 'foo$ps'" && $b : in + $c <"\$* -i 1 <'foo$ps' >/'foo/'" && $b : out + $c <"\$* -i 2 <'foo$ps' 2>/'foo/'" && $b : err + } + } + + : regex + : + : Test regex matching. Note that tests that check regex parsing are located + : in regex.testscript. + : + { + : match + : + $c <'$* -o foo >~/Foo?/i' && $b + + : mismatch + : + $c <'$* -o fooo >~/Foo?/i' && $b 2>>/~%EOE%d != 0 + %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + fooo + EOE + + : portable-path-failure + : + : Note that we check not only build2 diagnostics being produced, but also + : the correctness of regex being saved to file (for troubleshooting). + : + { + : newline + : + $c <"\$* -i 1 <'foo' >/~%bar/%" && $b 2>>/~%EOE%d != 0; + %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + foo + EOE + cat test/1/stdout.regex >"%bar$psr%" + + : no-newline + : + $c <"\$* -i 1 <'foo' >:/~%bar/%" && $b 2>>/~%EOE%d != 0; + %testscript:1: error: ../../../../../../driver(.exe)? stdout doesn't match regex% + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + foo + EOE + cat test/1/stdout.regex >:"%bar$psr%" + } + } +} + +: doc +: +{ + : literal + : + { + : in + : + $c <>EOO + foo + bar + EOO + EOI + + : err + : + $c <>EOO + foo + bar + EOO + EOI + + : inout + : + $c <>EOO + foo + bar + EOF + foo + bar + EOO + EOI + + : inerr + : + $c <>EOE + foo + bar + EOF + foo + bar + EOE + EOI + + : empty + : + $c <>EOO + EOF + EOO + EOI + + : shared + : + $c <>EOF + foo + bar + EOF + EOI + + : extra-newline + : + $c <>EOO + + EOF + + EOO + EOI + + : no-newline + : + $c <>:EOO + foo + EOF + foo + EOO + EOI + + : no-newline-fail1 + : + $c <>~/EOE/ != 0 + $* -i 1 <<:EOF >>EOO + foo + EOF + foo + EOO + EOI + /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ + /.{7} + -foo + +foo + \ No newline at end of file + EOE + + : no-newline-fail2 + : + $c <>~/EOE/ != 0 + $* -i 1 <>:EOO + foo + EOF + foo + EOO + EOI + /testscript:1: error: .+driver(\.exe)? stdout doesn't match expected/ + /.{7} + -foo + \ No newline at end of file + +foo + EOE + + : no-newline-empty + : + $c <>:EOO + EOF + EOO + EOI + + : no-newline-extra-newline + : + $c <>:EOO + + EOF + + EOO + EOI + + : merge + : + $c <>EOO 2>&1 + foo + bar + EOF + foo + bar + baz + EOO + EOI + + : large-diff + : + : Make sure that the large (>4KB) expected/real output difference is not + : printed as a part of the diagnostics. + : + $c <>/~%EOE%d != 0 + s="----------------------------------------------------------------------"; + s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"; + $* -i 1 <<"EOF" >>"EOO" + $s + EOF + x$s + EOO + EOI + %testscript:3: error: ../../../../../driver(.exe)? stdout doesn't match expected% + info: stdout: test/1/stdout + info: expected stdout: test/1/stdout.orig + info: stdout diff: test/1/stdout.diff + info: stdin: test/1/stdin + EOE + + : portable-path + : + { + : in + : + $c <<"EOI" && $b + \$* -i 1 <'foo$ps' + foo/ + EOF + EOI + + : out + : + $c <<"EOI" && $b + \$* -i 1 <'foo$ps' >>/EOO + foo/ + EOO + EOI + + : err + : + $c <<"EOI" && $b + \$* -i 2 <'foo$ps' 2>>/EOE + foo/ + EOE + EOI + } + } + + : regex + : + : Test regex matching. Note that tests that check regex parsing are located + : in regex.testscript. + : + { + : match + : + $c <>~/EOO/i + /FO*/* + bar + /* + EOO + EOI + + : match-empty + : + $c <>:~/EOO/ + /.{0} + EOO + EOI + + : shared + : + $c <>~/EOF/ 2>>~/EOF/ + foo + EOF + EOI + + : mismatch + : + $c <>/~%EOE%d != 0 + $* -o foo >>~/EOO/ + bar + EOO + EOI + %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + foo + EOE + + : mismatch-icase + : + $c <>/~%EOE%d != 0 + $* -o foo >>~/EOO/i + bar + EOO + EOI + %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match regex% + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex-i + foo + EOE + } +} + +: file +: +{ + : in + : + $c <=out; + $* -i 1 <<foo + EOI + + : out + : + { + : match + : + $c <=out; + $* -e bar 2>+out; + $* -i 1 <>>out + foo + bar + EOF + EOI + + : mismatch + : + $c <>/~%EOE%d != 0 + $* -o foo >=out; + $* -o bar >>>out + EOI + %testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match expected% + info: stdout: test/1/stdout-2 + info: expected stdout: test/1/out + info: stdout diff: test/1/stdout-2.diff + %--- \.*% + %\+\+\+ \.*% + %@@ \.*% + -foo + +bar + EOE + } + + : merge + : + $c <&1 >=out; + $* -e baz -o biz 1>&2 2>+out; + $* -i 1 <<>EOO + foo + bar + baz + biz + EOO + EOI +} diff --git a/tests/test/script/runner/regex.test b/tests/test/script/runner/regex.test deleted file mode 100644 index 018976c..0000000 --- a/tests/test/script/runner/regex.test +++ /dev/null @@ -1,312 +0,0 @@ -# file : tests/test/script/runner/regex.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Here we test that regex objects are properly created by the parser/runner -# venture. The unit test approach is not of much use as regex object is not -# serializable back to string. The only way we can test their proper creation -# is via matching. -# -# Note that such a tests are separated from ones that check regex matching -# specifically (in particular matching failures), The latest ones are located -# in redirect.test testscript. -# -# Also note that the following tests are grouped by features: basic -# functionality, flags, portable-path modifier. -# - -.include ../common.test - -: basic -: -{ - : str - : - { - $c <'cat ~/fo./' && $b : out - $c <'cat &2 2>~/fo./' && $b : err - $c <'cat <:foo >:~/fo./' && $b : no-newline - - : malformed - : - : Note that old versions of libc++ (for example 1.1) do not detect some - : regex errors. For example '*' is parsed successfully. - : - $c <'cat ~/foo[/' && $b 2>>~/EOE/ != 0 - /testscript:1:12: error: invalid stdout regex redirect.*/ - info: regex: '/foo[/' - EOE - - : no-match - : - $c <'cat ~/bar/' && $b 2>>/EOE != 0 - testscript:1:1: error: cat stdout doesn't match regex - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - info: stdin: test/1/stdin - foo - EOE - } - - : doc - : - { - : out - : - $c <>~/EOO/ - /foo/ - EOO - EOI - - : err - : - $c <&2 2>>~/EOO/ - /fo./ - EOO - EOI - - : no-newline - : - $c <>:~/EOO/ - /fo./ - EOO - EOI - - : line-char - : - $c <>~/EOO/ - foo - bar - baz - baz - Biz - Fox - fox - - - - - EOF - foo - /? - /bar/ - /baz/+ - /biz/i - /fox/i+ - - // - //{2} - EOO - EOI - - : expansion - : - $c <>~"/EOO/" - foo - bar - - baz - EOF - /f$(s) - baz - EOO - EOI - - : invalid-syntax-char - : - $c <>EOE != 0 - cat >~/EOO/ - /x - EOO - EOI - testscript:2:1: error: invalid syntax character 'x' in stdout regex redirect - info: regex line: '/x' - EOE - - : invalid-char-regex - : - $c <>~/EOE/ != 0 - cat >~/EOO/ - /foo[/ - EOO - EOI - /testscript:2:1: error: invalid char-regex in stdout regex redirect.*/ - info: regex line: '/foo[/' - EOE - - : invalid-line-regex - : - $c <>/~%EOE% != 0 - cat >~/EOO/ - a - /{ - EOO - EOI - %testscript:4:1: error: invalid stdout regex redirect.*% - info: stdout regex: test/1/stdout.regex - EOE - - : no-match - : - { - : leading-blank - : - $c <>/EOE != 0 - cat >~/EOO/ - - foo - EOO - EOI - testscript:1:1: error: cat stdout doesn't match regex - info: stdout: test/1/stdout - info: stdout regex: test/1/stdout.regex - info: stdin: test/1/stdin - foo - EOE - } - } -} - -:flags -: -{ - : str - : - { - : i - : - $c <'cat ~/foo/i' && $b - - : d - : - { - : escaped-dot - : - : Escaped dot becomes syntax dot and matches any character ('i' in our - : case). - : - $c <'cat ~/f\\.o/d' && $b - - : syntax-dot - : - : Syntax dot becomes escaped dot and matches only '.' and so we fail. - : - $c <'cat ~/f.o/d' && $b 2>>~/EOE/ != 0 - testscript:1:1: error: cat stdout doesn't match regex - /.+ - EOE - } - } - - : doc - { - : i - : - $c <>~/EOO/ - /foo/i - EOO - EOI - - : d - : - : All the reasonings for the /flags/str/d test group are valid for the - : current one. - : - { - : escaped-dot - : - $c <>~/EOO/ - /f\.o/d - EOO - EOI - - : syntax-dot - : - $c <>~/EOE/ != 0 - cat >~/EOO/ - /f.o/d - EOO - EOI - testscript:1:1: error: cat stdout doesn't match regex - /.+ - EOE - } - - : global - : - { - : i - : - $c <>~/EOO/i - /foo/ - EOO - EOI - - : d - : - { - : escaped-dot - : - $c <>~/EOO/d - /f\.o/ - EOO - EOI - - : syntax-dot - : - $c <>~/EOE/ != 0 - cat >~/EOO/d - /f.o/ - EOO - EOI - testscript:1:1: error: cat stdout doesn't match regex - /.+ - EOE - } - } - } -} - -: portable-path -: -{ - ps = ($cxx.target.class != 'windows' ? '/' : '\') - - : str - : - { - $c <"cat <'foo$ps' >/~%foo/%" && $b : out - $c <"cat <'foo$ps' 1>&2 2>/~%foo/%" && $b : err - } - - : doc - { - : out - : - $c <<"EOI" && $b - cat <'foo$ps' >>/~%EOO% - foo/ - EOO - EOI - - : err - : - $c <<"EOI" && $b - cat <'foo$ps' 1>&2 2>>/~%EOO% - foo/ - EOO - EOI - } -} diff --git a/tests/test/script/runner/regex.testscript b/tests/test/script/runner/regex.testscript new file mode 100644 index 0000000..46b1872 --- /dev/null +++ b/tests/test/script/runner/regex.testscript @@ -0,0 +1,312 @@ +# file : tests/test/script/runner/regex.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Here we test that regex objects are properly created by the parser/runner +# venture. The unit test approach is not of much use as regex object is not +# serializable back to string. The only way we can test their proper creation +# is via matching. +# +# Note that such a tests are separated from ones that check regex matching +# specifically (in particular matching failures), The latest ones are located +# in redirect.testscript. +# +# Also note that the following tests are grouped by features: basic +# functionality, flags, portable-path modifier. +# + +.include ../common.testscript + +: basic +: +{ + : str + : + { + $c <'cat ~/fo./' && $b : out + $c <'cat &2 2>~/fo./' && $b : err + $c <'cat <:foo >:~/fo./' && $b : no-newline + + : malformed + : + : Note that old versions of libc++ (for example 1.1) do not detect some + : regex errors. For example '*' is parsed successfully. + : + $c <'cat ~/foo[/' && $b 2>>~/EOE/ != 0 + /testscript:1:12: error: invalid stdout regex redirect.*/ + info: regex: '/foo[/' + EOE + + : no-match + : + $c <'cat ~/bar/' && $b 2>>/EOE != 0 + testscript:1:1: error: cat stdout doesn't match regex + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + foo + EOE + } + + : doc + : + { + : out + : + $c <>~/EOO/ + /foo/ + EOO + EOI + + : err + : + $c <&2 2>>~/EOO/ + /fo./ + EOO + EOI + + : no-newline + : + $c <>:~/EOO/ + /fo./ + EOO + EOI + + : line-char + : + $c <>~/EOO/ + foo + bar + baz + baz + Biz + Fox + fox + + + + + EOF + foo + /? + /bar/ + /baz/+ + /biz/i + /fox/i+ + + // + //{2} + EOO + EOI + + : expansion + : + $c <>~"/EOO/" + foo + bar + + baz + EOF + /f$(s) + baz + EOO + EOI + + : invalid-syntax-char + : + $c <>EOE != 0 + cat >~/EOO/ + /x + EOO + EOI + testscript:2:1: error: invalid syntax character 'x' in stdout regex redirect + info: regex line: '/x' + EOE + + : invalid-char-regex + : + $c <>~/EOE/ != 0 + cat >~/EOO/ + /foo[/ + EOO + EOI + /testscript:2:1: error: invalid char-regex in stdout regex redirect.*/ + info: regex line: '/foo[/' + EOE + + : invalid-line-regex + : + $c <>/~%EOE% != 0 + cat >~/EOO/ + a + /{ + EOO + EOI + %testscript:4:1: error: invalid stdout regex redirect.*% + info: stdout regex: test/1/stdout.regex + EOE + + : no-match + : + { + : leading-blank + : + $c <>/EOE != 0 + cat >~/EOO/ + + foo + EOO + EOI + testscript:1:1: error: cat stdout doesn't match regex + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + foo + EOE + } + } +} + +:flags +: +{ + : str + : + { + : i + : + $c <'cat ~/foo/i' && $b + + : d + : + { + : escaped-dot + : + : Escaped dot becomes syntax dot and matches any character ('i' in our + : case). + : + $c <'cat ~/f\\.o/d' && $b + + : syntax-dot + : + : Syntax dot becomes escaped dot and matches only '.' and so we fail. + : + $c <'cat ~/f.o/d' && $b 2>>~/EOE/ != 0 + testscript:1:1: error: cat stdout doesn't match regex + /.+ + EOE + } + } + + : doc + { + : i + : + $c <>~/EOO/ + /foo/i + EOO + EOI + + : d + : + : All the reasonings for the /flags/str/d test group are valid for the + : current one. + : + { + : escaped-dot + : + $c <>~/EOO/ + /f\.o/d + EOO + EOI + + : syntax-dot + : + $c <>~/EOE/ != 0 + cat >~/EOO/ + /f.o/d + EOO + EOI + testscript:1:1: error: cat stdout doesn't match regex + /.+ + EOE + } + + : global + : + { + : i + : + $c <>~/EOO/i + /foo/ + EOO + EOI + + : d + : + { + : escaped-dot + : + $c <>~/EOO/d + /f\.o/ + EOO + EOI + + : syntax-dot + : + $c <>~/EOE/ != 0 + cat >~/EOO/d + /f.o/ + EOO + EOI + testscript:1:1: error: cat stdout doesn't match regex + /.+ + EOE + } + } + } +} + +: portable-path +: +{ + ps = ($cxx.target.class != 'windows' ? '/' : '\') + + : str + : + { + $c <"cat <'foo$ps' >/~%foo/%" && $b : out + $c <"cat <'foo$ps' 1>&2 2>/~%foo/%" && $b : err + } + + : doc + { + : out + : + $c <<"EOI" && $b + cat <'foo$ps' >>/~%EOO% + foo/ + EOO + EOI + + : err + : + $c <<"EOI" && $b + cat <'foo$ps' 1>&2 2>>/~%EOO% + foo/ + EOO + EOI + } +} diff --git a/tests/test/script/runner/set.test b/tests/test/script/runner/set.test deleted file mode 100644 index 2266ae9..0000000 --- a/tests/test/script/runner/set.test +++ /dev/null @@ -1,278 +0,0 @@ -# file : tests/test/script/runner/set.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: special -: -{ - : pipelining - : - $c <'set foo | cat >bar' && $b 2>>EOE != 0 - testscript:1:1: error: set builtin must be the last pipe command - EOE - - : redirecting - : - { - : stdout - : - $c <'set foo >bar' && $b 2>>EOE != 0 - testscript:1:1: error: set builtin stdout cannot be redirected - EOE - - : stderr - : - $c <'set foo 2>bar' && $b 2>>EOE != 0 - testscript:1:1: error: set builtin stderr cannot be redirected - EOE - } - - : status - : - $c <'set foo == 1' && $b 2>>EOE != 0 - testscript:1:1: error: set builtin exit code cannot be non-zero - EOE -} - -: arguments -: -{ - : none - : - $c <'set -e' && $b 2>>EOE != 0 - testscript:1:1: error: missing variable name - EOE - - : unexpected - : - $c <'set foo bar baz' && $b 2>>EOE != 0 - testscript:1:1: error: unexpected argument - EOE - - : empty-attrs - : - $c <"set '' baz" && $b 2>>EOE != 0 - testscript:1:1: error: empty variable attributes - EOE - - : empty-var - : - $c <"set ''" && $b 2>>EOE != 0 - testscript:1:1: error: empty variable name - EOE -} - -: whitespace-separated-list -: -{ - : non-exact - : - $c <'foo bar' - EOI - - : exact - : - { - : trailing-ws - : - $c <'foo bar ' - EOI - - : no-trailing-ws - : - : Note that we need to strip the default trailing newline as well with the - : ':' modifier. - : - $c <'foo bar' - EOI - } -} - -: newline-separated-list -: -{ - : non-exact - : - $c <' foo bar ' - EOI - - : exact - : - { - : trailing-newline - : - $c <' foo bar ' - EOI - - : no-trailing-newline - : - $c <' foo bar' - EOI - } -} - -: string -: -{ - : non-exact - : - $c <>EOO - - foo - - bar - - EOO - EOI - - : roundtrip - : - echo 'foo' | set bar; - echo "$bar" >'foo' - - : exact - : - : Note that echo adds the trailing newline, so EOF and EOO here-documents - : differ by this newline. - : - { - : trailing-newline - : - $c <>EOO - - foo - - bar - - EOO - EOI - - : no-trailing-newline - : - $c <>EOO - - foo - - bar - EOO - EOI - } -} - -: attributes -: -{ - : dir_path - : - $c </'foo/' - EOI - - : null - : - $c <'' - EOI - - : none - : - $c <>EOE != 0 - set -w baz <'foo bar'; - echo "$baz" - EOI - testscript:2:8: error: concatenating variable expansion contains multiple values - EOE - - # @@ Move the following tests to build2 parser unit tests when created. - # - : empty-brackets - : - $c <>EOE != 0 - set -w '[]' baz <'foo bar'; - echo "$baz" - EOI - testscript:2:8: error: concatenating variable expansion contains multiple values - EOE - - : no-left-bracket - : - $c <>EOE != 0 - set -w x baz - EOI - :1:1: error: expected '[' instead of 'x' - testscript:1:1: info: while parsing attributes 'x' - EOE - - : unknown - : - $c <>EOE != 0 - set -w [x] baz - EOI - :1:1: error: unknown value attribute x - testscript:1:1: info: while parsing attributes '[x]' - EOE - - : junk - : - $c <>EOE != 0 - set -w '[string] x' baz - EOI - :1:10: error: trailing junk after ']' - testscript:1:1: info: while parsing attributes '[string] x' - EOE -} diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript new file mode 100644 index 0000000..b10ce1e --- /dev/null +++ b/tests/test/script/runner/set.testscript @@ -0,0 +1,278 @@ +# file : tests/test/script/runner/set.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: special +: +{ + : pipelining + : + $c <'set foo | cat >bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin must be the last pipe command + EOE + + : redirecting + : + { + : stdout + : + $c <'set foo >bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin stdout cannot be redirected + EOE + + : stderr + : + $c <'set foo 2>bar' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin stderr cannot be redirected + EOE + } + + : status + : + $c <'set foo == 1' && $b 2>>EOE != 0 + testscript:1:1: error: set builtin exit code cannot be non-zero + EOE +} + +: arguments +: +{ + : none + : + $c <'set -e' && $b 2>>EOE != 0 + testscript:1:1: error: missing variable name + EOE + + : unexpected + : + $c <'set foo bar baz' && $b 2>>EOE != 0 + testscript:1:1: error: unexpected argument + EOE + + : empty-attrs + : + $c <"set '' baz" && $b 2>>EOE != 0 + testscript:1:1: error: empty variable attributes + EOE + + : empty-var + : + $c <"set ''" && $b 2>>EOE != 0 + testscript:1:1: error: empty variable name + EOE +} + +: whitespace-separated-list +: +{ + : non-exact + : + $c <'foo bar' + EOI + + : exact + : + { + : trailing-ws + : + $c <'foo bar ' + EOI + + : no-trailing-ws + : + : Note that we need to strip the default trailing newline as well with the + : ':' modifier. + : + $c <'foo bar' + EOI + } +} + +: newline-separated-list +: +{ + : non-exact + : + $c <' foo bar ' + EOI + + : exact + : + { + : trailing-newline + : + $c <' foo bar ' + EOI + + : no-trailing-newline + : + $c <' foo bar' + EOI + } +} + +: string +: +{ + : non-exact + : + $c <>EOO + + foo + + bar + + EOO + EOI + + : roundtrip + : + echo 'foo' | set bar; + echo "$bar" >'foo' + + : exact + : + : Note that echo adds the trailing newline, so EOF and EOO here-documents + : differ by this newline. + : + { + : trailing-newline + : + $c <>EOO + + foo + + bar + + EOO + EOI + + : no-trailing-newline + : + $c <>EOO + + foo + + bar + EOO + EOI + } +} + +: attributes +: +{ + : dir_path + : + $c </'foo/' + EOI + + : null + : + $c <'' + EOI + + : none + : + $c <>EOE != 0 + set -w baz <'foo bar'; + echo "$baz" + EOI + testscript:2:8: error: concatenating variable expansion contains multiple values + EOE + + # @@ Move the following tests to build2 parser unit tests when created. + # + : empty-brackets + : + $c <>EOE != 0 + set -w '[]' baz <'foo bar'; + echo "$baz" + EOI + testscript:2:8: error: concatenating variable expansion contains multiple values + EOE + + : no-left-bracket + : + $c <>EOE != 0 + set -w x baz + EOI + :1:1: error: expected '[' instead of 'x' + testscript:1:1: info: while parsing attributes 'x' + EOE + + : unknown + : + $c <>EOE != 0 + set -w [x] baz + EOI + :1:1: error: unknown value attribute x + testscript:1:1: info: while parsing attributes '[x]' + EOE + + : junk + : + $c <>EOE != 0 + set -w '[string] x' baz + EOI + :1:10: error: trailing junk after ']' + testscript:1:1: info: while parsing attributes '[string] x' + EOE +} diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test deleted file mode 100644 index 86d9ca4..0000000 --- a/tests/test/script/runner/status.test +++ /dev/null @@ -1,57 +0,0 @@ -# file : tests/test/script/runner/status.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -b += --no-column - -: eq -: -{ - : true - : - $c <'$* == 0' && $b - - : false - : - $c <'$* -s 1 == 0' && $b 2>>/~%EOE%d != 0 - %testscript:1: error: ../../../../driver(.exe)? exit code 1 != 0% - EOE -} - -: ne -: -{ - : true - : - $c <'$* -s 1 != 0' && $b - - : false - : - $c <'$* -s 1 != 1' && $b 2>>/~%EOE% != 0 - %testscript:1: error: ../../../../driver(.exe)? exit code 1 == 1% - EOE -} - -: error -: -$c <'$* -s 1 -e "Error"' && $b 2>>/~%EOE% != 0 -%testscript:1: error: ../../../driver(.exe)? exit code 1 != 0% - info: stderr: test/1/stderr -Error -EOE - -#\ -: segmentation-fault -: -: Can pop up dialog boxes on Windows or produce coredump on POSIX. Note that -: under Wine some extra info is printed to STDOUT. -: -$c <'$* -t m' && $b 2>>/~%EOE% != 0 -%wine: .+%? -%testscript:1: error: ../../../driver(.exe)? terminated abnormally%d -% info: .+% -% info: stdout: test\\1\\stdout%? -EOE -#\ diff --git a/tests/test/script/runner/status.testscript b/tests/test/script/runner/status.testscript new file mode 100644 index 0000000..1689a69 --- /dev/null +++ b/tests/test/script/runner/status.testscript @@ -0,0 +1,57 @@ +# file : tests/test/script/runner/status.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +b += --no-column + +: eq +: +{ + : true + : + $c <'$* == 0' && $b + + : false + : + $c <'$* -s 1 == 0' && $b 2>>/~%EOE%d != 0 + %testscript:1: error: ../../../../driver(.exe)? exit code 1 != 0% + EOE +} + +: ne +: +{ + : true + : + $c <'$* -s 1 != 0' && $b + + : false + : + $c <'$* -s 1 != 1' && $b 2>>/~%EOE% != 0 + %testscript:1: error: ../../../../driver(.exe)? exit code 1 == 1% + EOE +} + +: error +: +$c <'$* -s 1 -e "Error"' && $b 2>>/~%EOE% != 0 +%testscript:1: error: ../../../driver(.exe)? exit code 1 != 0% + info: stderr: test/1/stderr +Error +EOE + +#\ +: segmentation-fault +: +: Can pop up dialog boxes on Windows or produce coredump on POSIX. Note that +: under Wine some extra info is printed to STDOUT. +: +$c <'$* -t m' && $b 2>>/~%EOE% != 0 +%wine: .+%? +%testscript:1: error: ../../../driver(.exe)? terminated abnormally%d +% info: .+% +% info: stdout: test\\1\\stdout%? +EOE +#\ diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript index 61258b0..08bd3e3 100644 --- a/tests/test/simple/generated/testscript +++ b/tests/test/simple/generated/testscript @@ -4,7 +4,7 @@ test.arguments = test clean -.include ../../common.test +.include ../../common.testscript # @@ in module # diff --git a/tests/value/buildfile b/tests/value/buildfile index 1ab26d5..a43074c 100644 --- a/tests/value/buildfile +++ b/tests/value/buildfile @@ -2,4 +2,4 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: test{*} $b +./: testscript{*} $b diff --git a/tests/value/concat.test b/tests/value/concat.test deleted file mode 100644 index 79f004c..0000000 --- a/tests/value/concat.test +++ /dev/null @@ -1,73 +0,0 @@ -# file : tests/value/concat.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -.include ../common.test - -: dir_path -: -{ - : name - : - $* <>/EOO - d = [dir_path] foo - f = bar - print $d/$f - EOI - foo/bar - EOO - - : string - : - $* <>/EOO - d = [dir_path] foo - f = [string] bar - print $d/$f - EOI - foo/bar - EOO - - : leading-separator - : - $* <>/EOO - d = [dir_path] foo - f = /bar - print $d/$f - EOI - foo/bar - EOO - - : not-separated - : - $* <>/EOO - d = [dir_path] foo - f = bar - print $d$f - EOI - foo/bar - EOO -} - -: path -: -{ - : separated - : - $* <>/EOO - d = [path] foo - f = bar - print $d/$f - EOI - foo/bar - EOO - - : not-separated - : - $* <>/EOO - d = [path] foo - f = bar - print $d$f - EOI - foobar - EOO -} diff --git a/tests/value/concat.testscript b/tests/value/concat.testscript new file mode 100644 index 0000000..581c3ad --- /dev/null +++ b/tests/value/concat.testscript @@ -0,0 +1,73 @@ +# file : tests/value/concat.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +.include ../common.testscript + +: dir_path +: +{ + : name + : + $* <>/EOO + d = [dir_path] foo + f = bar + print $d/$f + EOI + foo/bar + EOO + + : string + : + $* <>/EOO + d = [dir_path] foo + f = [string] bar + print $d/$f + EOI + foo/bar + EOO + + : leading-separator + : + $* <>/EOO + d = [dir_path] foo + f = /bar + print $d/$f + EOI + foo/bar + EOO + + : not-separated + : + $* <>/EOO + d = [dir_path] foo + f = bar + print $d$f + EOI + foo/bar + EOO +} + +: path +: +{ + : separated + : + $* <>/EOO + d = [path] foo + f = bar + print $d/$f + EOI + foo/bar + EOO + + : not-separated + : + $* <>/EOO + d = [path] foo + f = bar + print $d$f + EOI + foobar + EOO +} diff --git a/tests/value/reverse.test b/tests/value/reverse.test deleted file mode 100644 index 9ea9d09..0000000 --- a/tests/value/reverse.test +++ /dev/null @@ -1,82 +0,0 @@ -# file : tests/value/reverse.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test reversal to canonical/original representation. -# - -.include ../common.test - -: name -: -{ - : dir - : - $* <>EOO - x = s/foo/bar/ - print ([string] $x) - print "$x" - print -e=$x - EOI - s/foo/bar/ - s/foo/bar/ - -e=s/foo/bar/ - EOO - - : proj - : - $* <>EOO - print ([strings] foo%bar foo% %bar) - EOI - foo%bar foo% %bar - EOO - - : pair - : - $* <>EOO - print ([strings] foo@bar foo/@bar/ foo@ @bar @ "@@") - EOI - foo@bar foo/@bar/ foo@ @bar @ @@ - EOO - - : combined - : - $* <>EOO - print ([strings] xx%foo@yy%bar xx%foo/@yy%bar/) - EOI - xx%foo@yy%bar xx%foo/@yy%bar/ - EOO -} - -: dir-path -: -{ - : rel - : - $* <>"EOO" - x = [dir_path] foo/bar/ - print ([string] $x) - print "$x" - print "-I$x" - EOI - foo/bar/ - foo/bar - -Ifoo/bar - EOO - - : root - : - if ($cxx.target.class != 'windows') - { - $* <>EOO - x = [dir_path] / - print ([string] $x) - print "$x" - print "-I$x" - EOI - / - / - -I/ - EOO - } -} diff --git a/tests/value/reverse.testscript b/tests/value/reverse.testscript new file mode 100644 index 0000000..6294d3f --- /dev/null +++ b/tests/value/reverse.testscript @@ -0,0 +1,82 @@ +# file : tests/value/reverse.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test reversal to canonical/original representation. +# + +.include ../common.testscript + +: name +: +{ + : dir + : + $* <>EOO + x = s/foo/bar/ + print ([string] $x) + print "$x" + print -e=$x + EOI + s/foo/bar/ + s/foo/bar/ + -e=s/foo/bar/ + EOO + + : proj + : + $* <>EOO + print ([strings] foo%bar foo% %bar) + EOI + foo%bar foo% %bar + EOO + + : pair + : + $* <>EOO + print ([strings] foo@bar foo/@bar/ foo@ @bar @ "@@") + EOI + foo@bar foo/@bar/ foo@ @bar @ @@ + EOO + + : combined + : + $* <>EOO + print ([strings] xx%foo@yy%bar xx%foo/@yy%bar/) + EOI + xx%foo@yy%bar xx%foo/@yy%bar/ + EOO +} + +: dir-path +: +{ + : rel + : + $* <>"EOO" + x = [dir_path] foo/bar/ + print ([string] $x) + print "$x" + print "-I$x" + EOI + foo/bar/ + foo/bar + -Ifoo/bar + EOO + + : root + : + if ($cxx.target.class != 'windows') + { + $* <>EOO + x = [dir_path] / + print ([string] $x) + print "$x" + print "-I$x" + EOI + / + / + -I/ + EOO + } +} diff --git a/tests/variable/override/testscript b/tests/variable/override/testscript index 591fc19..00ffdb9 100644 --- a/tests/variable/override/testscript +++ b/tests/variable/override/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : cache-invalidation : diff --git a/tests/variable/prerequisite-specific/testscript b/tests/variable/prerequisite-specific/testscript index d0ce5e0..1c7e7bd 100644 --- a/tests/variable/prerequisite-specific/testscript +++ b/tests/variable/prerequisite-specific/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript # There is currently no support for expanding prerequisite-specific variables # (since there is no way to id a prerequisite) so we use dump. diff --git a/tests/variable/scope-specific/testscript b/tests/variable/scope-specific/testscript index 2f519d2..5f9a05d 100644 --- a/tests/variable/scope-specific/testscript +++ b/tests/variable/scope-specific/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : basic-line : diff --git a/tests/variable/target-specific/testscript b/tests/variable/target-specific/testscript index 8d9917c..497c863 100644 --- a/tests/variable/target-specific/testscript +++ b/tests/variable/target-specific/testscript @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -.include ../../common.test +.include ../../common.testscript : basic-line : diff --git a/unit-tests/cc/lexer/buildfile b/unit-tests/cc/lexer/buildfile index bf7c1c5..4aa8b51 100644 --- a/unit-tests/cc/lexer/buildfile +++ b/unit-tests/cc/lexer/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../../build2/ -exe{driver}: {hxx cxx}{*} ../../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../../build2/libu{b} testscript{*} diff --git a/unit-tests/cc/lexer/char-literal.test b/unit-tests/cc/lexer/char-literal.test deleted file mode 100644 index 6253096..0000000 --- a/unit-tests/cc/lexer/char-literal.test +++ /dev/null @@ -1,67 +0,0 @@ -# file : unit-tests/cc/lexer/char-literal.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test character literals. -# - -: normal -: -$* <>EOO -'a' -'aa' -'"' -EOI - - - -EOO - -: prefix -: -$* <>EOO -L'a' -U'a' -u'a' -u8'a' -u8R'a' -EOI - - - - -'u8R' - -EOO - -: suffix -: -$* <>EOO -'a'x -'a'_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -'\'' -'\\' -'\\\'' -'\n' -U'\U0001f34c' -EOI - - - - - -EOO - -: unterminated -: -$* <"'a" 2>>EOE != 0 -stdin:1:1: error: unterminated character literal -EOE diff --git a/unit-tests/cc/lexer/char-literal.testscript b/unit-tests/cc/lexer/char-literal.testscript new file mode 100644 index 0000000..dac66e2 --- /dev/null +++ b/unit-tests/cc/lexer/char-literal.testscript @@ -0,0 +1,67 @@ +# file : unit-tests/cc/lexer/char-literal.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test character literals. +# + +: normal +: +$* <>EOO +'a' +'aa' +'"' +EOI + + + +EOO + +: prefix +: +$* <>EOO +L'a' +U'a' +u'a' +u8'a' +u8R'a' +EOI + + + + +'u8R' + +EOO + +: suffix +: +$* <>EOO +'a'x +'a'_X123 +EOI + + +EOO + +: escape +: +$* <>EOO +'\'' +'\\' +'\\\'' +'\n' +U'\U0001f34c' +EOI + + + + + +EOO + +: unterminated +: +$* <"'a" 2>>EOE != 0 +stdin:1:1: error: unterminated character literal +EOE diff --git a/unit-tests/cc/lexer/comment.test b/unit-tests/cc/lexer/comment.test deleted file mode 100644 index 2b5d81e..0000000 --- a/unit-tests/cc/lexer/comment.test +++ /dev/null @@ -1,88 +0,0 @@ -# file : unit-tests/cc/lexer/comment.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test C and C++ comments. -# - -: c-comment -: -$* <"';'" -// /* -; -// */ -EOI - -: c-unterminated -: -$* <>EOE != 0 -/* -comment -EOI -stdin:1:2: error: unterminated comment -EOE - -: cxx-unterminated -: -$* <<:EOI -// comment -EOI - -: in-char-literal -: -$* <>EOO -'//' -'/*'*/ -EOI - - - - -EOO - -: in-string-literal -: -$* <>EOO -"//foo" -"/*"*/ -EOI - - - - -EOO - -: in-raw-string-literal -: -$* <>EOO -R"X( -// foo -/* bar -)X"*/ -EOI - - - -EOO diff --git a/unit-tests/cc/lexer/comment.testscript b/unit-tests/cc/lexer/comment.testscript new file mode 100644 index 0000000..d4ad675 --- /dev/null +++ b/unit-tests/cc/lexer/comment.testscript @@ -0,0 +1,88 @@ +# file : unit-tests/cc/lexer/comment.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test C and C++ comments. +# + +: c-comment +: +$* <"';'" +// /* +; +// */ +EOI + +: c-unterminated +: +$* <>EOE != 0 +/* +comment +EOI +stdin:1:2: error: unterminated comment +EOE + +: cxx-unterminated +: +$* <<:EOI +// comment +EOI + +: in-char-literal +: +$* <>EOO +'//' +'/*'*/ +EOI + + + + +EOO + +: in-string-literal +: +$* <>EOO +"//foo" +"/*"*/ +EOI + + + + +EOO + +: in-raw-string-literal +: +$* <>EOO +R"X( +// foo +/* bar +)X"*/ +EOI + + + +EOO diff --git a/unit-tests/cc/lexer/line.test b/unit-tests/cc/lexer/line.test deleted file mode 100644 index 83ebbeb..0000000 --- a/unit-tests/cc/lexer/line.test +++ /dev/null @@ -1,67 +0,0 @@ -# file : unit-tests/cc/lexer/line.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test line continuations. -# - -: identifier -: -$* <"'foo123'" -fo\ -o\ -1\ -2\ -3 -EOI - -: punctuation -: -$* <'' -.\ -.\ -. -EOI - -: c-comment -: -$* <>EOO -\abc -EOI - -'abc' -EOO - -: multiple -: -$* <>EOO -\\ -EOI - -EOO - -: unterminated -: -$* <<:EOI >'' -\ -EOI diff --git a/unit-tests/cc/lexer/line.testscript b/unit-tests/cc/lexer/line.testscript new file mode 100644 index 0000000..01961eb --- /dev/null +++ b/unit-tests/cc/lexer/line.testscript @@ -0,0 +1,67 @@ +# file : unit-tests/cc/lexer/line.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test line continuations. +# + +: identifier +: +$* <"'foo123'" +fo\ +o\ +1\ +2\ +3 +EOI + +: punctuation +: +$* <'' +.\ +.\ +. +EOI + +: c-comment +: +$* <>EOO +\abc +EOI + +'abc' +EOO + +: multiple +: +$* <>EOO +\\ +EOI + +EOO + +: unterminated +: +$* <<:EOI >'' +\ +EOI diff --git a/unit-tests/cc/lexer/number.test b/unit-tests/cc/lexer/number.test deleted file mode 100644 index 7336037..0000000 --- a/unit-tests/cc/lexer/number.test +++ /dev/null @@ -1,48 +0,0 @@ -# file : unit-tests/cc/lexer/number.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test numbers. -# - -$* <'1' >'' -$* <'.1' >'' -$* <'1.' >'' - -$* <'0b101' >'' -$* <'0123' >'' -$* <'0X12AB' >'' - -$* <'1e10' >'' -$* <'1E+10' >'' -$* <'0x1.p10' >'' -$* <'0x1.P-10' >'' - -$* <"123'456" >'' -$* <"0xff00'00ff" >'' - -$* <'123f' >'' -$* <'123UL' >'' -$* <'123_X' >'' - -: separate-punctuation -: -$* <'123;' >>EOO - -';' -EOO - -: separate-plus-minus -: -$* <'1.0_a+2.0' >>EOO - - - -EOO - -: separate-whitespace -: -$* <'123 abc' >>EOO - -'abc' -EOO diff --git a/unit-tests/cc/lexer/number.testscript b/unit-tests/cc/lexer/number.testscript new file mode 100644 index 0000000..cb82d5f --- /dev/null +++ b/unit-tests/cc/lexer/number.testscript @@ -0,0 +1,48 @@ +# file : unit-tests/cc/lexer/number.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test numbers. +# + +$* <'1' >'' +$* <'.1' >'' +$* <'1.' >'' + +$* <'0b101' >'' +$* <'0123' >'' +$* <'0X12AB' >'' + +$* <'1e10' >'' +$* <'1E+10' >'' +$* <'0x1.p10' >'' +$* <'0x1.P-10' >'' + +$* <"123'456" >'' +$* <"0xff00'00ff" >'' + +$* <'123f' >'' +$* <'123UL' >'' +$* <'123_X' >'' + +: separate-punctuation +: +$* <'123;' >>EOO + +';' +EOO + +: separate-plus-minus +: +$* <'1.0_a+2.0' >>EOO + + + +EOO + +: separate-whitespace +: +$* <'123 abc' >>EOO + +'abc' +EOO diff --git a/unit-tests/cc/lexer/preprocessor.test b/unit-tests/cc/lexer/preprocessor.test deleted file mode 100644 index fbe578d..0000000 --- a/unit-tests/cc/lexer/preprocessor.test +++ /dev/null @@ -1,73 +0,0 @@ -# file : unit-tests/cc/lexer/preprocessor.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test preprocessor lines. -# - -: normal -: -$* <>EOO -; -# 1 "test.cxx" 2 -; - ; -# 4 -; -#line 8 "z:\\tmp\\test.hxx" -; -#line 10 -; -# 5 "test.cxx" -; -EOI -';' stdin:1:1 -';' test.cxx:1:1 -';' test.cxx:2:3 -';' test.cxx:4:1 -';' z:\tmp\test.hxx:8:1 -';' z:\tmp\test.hxx:10:1 -';' test.cxx:5:1 -EOO - -: include -: -$* <>EOE != 0 -#include -EOI -stdin:1:1: error: unexpected #include directive -EOE - -: nested -: -$* <>EOO -#define FOO(x) #y -; -EOI -';' -EOO diff --git a/unit-tests/cc/lexer/preprocessor.testscript b/unit-tests/cc/lexer/preprocessor.testscript new file mode 100644 index 0000000..1d86115 --- /dev/null +++ b/unit-tests/cc/lexer/preprocessor.testscript @@ -0,0 +1,73 @@ +# file : unit-tests/cc/lexer/preprocessor.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test preprocessor lines. +# + +: normal +: +$* <>EOO +; +# 1 "test.cxx" 2 +; + ; +# 4 +; +#line 8 "z:\\tmp\\test.hxx" +; +#line 10 +; +# 5 "test.cxx" +; +EOI +';' stdin:1:1 +';' test.cxx:1:1 +';' test.cxx:2:3 +';' test.cxx:4:1 +';' z:\tmp\test.hxx:8:1 +';' z:\tmp\test.hxx:10:1 +';' test.cxx:5:1 +EOO + +: include +: +$* <>EOE != 0 +#include +EOI +stdin:1:1: error: unexpected #include directive +EOE + +: nested +: +$* <>EOO +#define FOO(x) #y +; +EOI +';' +EOO diff --git a/unit-tests/cc/lexer/raw-string-literal.test b/unit-tests/cc/lexer/raw-string-literal.test deleted file mode 100644 index 09b54b5..0000000 --- a/unit-tests/cc/lexer/raw-string-literal.test +++ /dev/null @@ -1,90 +0,0 @@ -# file : unit-tests/cc/lexer/raw-string-literal.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test raw string literals. -# - -: normal -: -$* <>EOO -R"()" -R"(ab)" -R"(a"b)" -R"(a)b)" -R"%(a%)b)%" -R"X(a - b)X" -R"X(a\ - b)X" -EOI - - - - - - - -EOO - -: prefix -: -$* <>EOO -LR"(ab)" -UR"(ab)" -uR"(ab)" -u8R"(ab)" -EOI - - - - -EOO - -: suffix -: -$* <>EOO -R"(ab)"x -R"(ab)"_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -R"(\)" -EOI - -EOO - -: invalid-no-paren -: -$* <'R"a"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-paren -: -$* <'R")()("' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-paren -: -$* <'R"(abc"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-delimiter -: -$* <'R"X(abc)"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-quote -: -$* <'R"X(abc)X' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE diff --git a/unit-tests/cc/lexer/raw-string-literal.testscript b/unit-tests/cc/lexer/raw-string-literal.testscript new file mode 100644 index 0000000..df475ef --- /dev/null +++ b/unit-tests/cc/lexer/raw-string-literal.testscript @@ -0,0 +1,90 @@ +# file : unit-tests/cc/lexer/raw-string-literal.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test raw string literals. +# + +: normal +: +$* <>EOO +R"()" +R"(ab)" +R"(a"b)" +R"(a)b)" +R"%(a%)b)%" +R"X(a + b)X" +R"X(a\ + b)X" +EOI + + + + + + + +EOO + +: prefix +: +$* <>EOO +LR"(ab)" +UR"(ab)" +uR"(ab)" +u8R"(ab)" +EOI + + + + +EOO + +: suffix +: +$* <>EOO +R"(ab)"x +R"(ab)"_X123 +EOI + + +EOO + +: escape +: +$* <>EOO +R"(\)" +EOI + +EOO + +: invalid-no-paren +: +$* <'R"a"' 2>>EOE != 0 +stdin:1:2: error: invalid raw string literal +EOE + +: invalid-paren +: +$* <'R")()("' 2>>EOE != 0 +stdin:1:2: error: invalid raw string literal +EOE + +: invalid-unterminated-paren +: +$* <'R"(abc"' 2>>EOE != 0 +stdin:1:2: error: invalid raw string literal +EOE + +: invalid-unterminated-delimiter +: +$* <'R"X(abc)"' 2>>EOE != 0 +stdin:1:2: error: invalid raw string literal +EOE + +: invalid-unterminated-quote +: +$* <'R"X(abc)X' 2>>EOE != 0 +stdin:1:2: error: invalid raw string literal +EOE diff --git a/unit-tests/cc/lexer/string-literal.test b/unit-tests/cc/lexer/string-literal.test deleted file mode 100644 index b21b1d2..0000000 --- a/unit-tests/cc/lexer/string-literal.test +++ /dev/null @@ -1,65 +0,0 @@ -# file : unit-tests/cc/lexer/string-literal.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test string literals (except raw). -# - -: normal -: -$* <>EOO -"aa" -"'" -"a""b" -EOI - - - - -EOO - -: prefix -: -$* <>EOO -L"ab" -U"ab" -u"ab" -u8"ab" -EOI - - - - -EOO - -: suffix -: -$* <>EOO -"ab"x -"ab"_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -"\"\"" -"\\\\" -"\\\"\\" -"\n\t" -U"a\U0001f34c" -EOI - - - - - -EOO - -: unterminated -: -$* <'"ab' 2>>EOE != 0 -stdin:1:1: error: unterminated string literal -EOE diff --git a/unit-tests/cc/lexer/string-literal.testscript b/unit-tests/cc/lexer/string-literal.testscript new file mode 100644 index 0000000..e5eb189 --- /dev/null +++ b/unit-tests/cc/lexer/string-literal.testscript @@ -0,0 +1,65 @@ +# file : unit-tests/cc/lexer/string-literal.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test string literals (except raw). +# + +: normal +: +$* <>EOO +"aa" +"'" +"a""b" +EOI + + + + +EOO + +: prefix +: +$* <>EOO +L"ab" +U"ab" +u"ab" +u8"ab" +EOI + + + + +EOO + +: suffix +: +$* <>EOO +"ab"x +"ab"_X123 +EOI + + +EOO + +: escape +: +$* <>EOO +"\"\"" +"\\\\" +"\\\"\\" +"\n\t" +U"a\U0001f34c" +EOI + + + + + +EOO + +: unterminated +: +$* <'"ab' 2>>EOE != 0 +stdin:1:1: error: unterminated string literal +EOE diff --git a/unit-tests/cc/parser/buildfile b/unit-tests/cc/parser/buildfile index c01c1c0..fce77f4 100644 --- a/unit-tests/cc/parser/buildfile +++ b/unit-tests/cc/parser/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../../build2/ -exe{driver}: {hxx cxx}{*} ../../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../../build2/libu{b} testscript{*} diff --git a/unit-tests/cc/parser/module.test b/unit-tests/cc/parser/module.test deleted file mode 100644 index 65186cd..0000000 --- a/unit-tests/cc/parser/module.test +++ /dev/null @@ -1,149 +0,0 @@ -# file : unit-tests/cc/parser/module.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test C++ module constructs. -# - -: import -: -$* <>EOI -import foo; -import foo.bar; -import foo.bar.baz; -EOI - -: module-implementation -: -$* <>EOI -module foo; -EOI - -: module-interface -: -$* <>EOI -export module foo; -EOI - -: export-imported -: -$* <>EOO -export import foo; -EOI -export import foo; -EOO - -: export-imported-block -: -$* <>EOO -import bar; - -export {import foo;} - -export -{ - namespace foo - { - class c {}; - } - - template int f (); - - import bar; -} -EOI -export import bar; -export import foo; -EOO - -: non-module -: -$* <>EOO -import foo [[export({import})]]; -module bar [[module({module})]]; -EOI -import foo; -module bar; -EOO - -: import-duplicate -: -$* <>EOO -import foo; -import bar.baz; -import foo; -import bar . baz; -EOI -import foo; -import bar.baz; -EOO - -: brace-missing -: -$* <>EOE != 0 -export -{ - class foo - { - //}; - module foo; -} -EOI -stdin:8:1: error: {}-imbalance detected -EOE - -: brace-stray -: -$* <>EOE != 0 -export -{ - class foo - { - };} -} -module foo; -EOI -stdin:6:1: error: {}-imbalance detected -EOE - -: import-missing-name -: -$* <>EOE != 0 -import ; -EOI -stdin:1:8: error: module name expected instead of ';' -EOE - -: module-missing-name -: -$* <>EOE != 0 -module ; -EOI -stdin:1:1: error: module declaration expected after leading module marker -EOE - -: import-missing-semi -: -$* <>EOE != 0 -import foo -EOI -stdin:2:1: error: ';' expected instead of -EOE - -: module-missing-semi -: -$* <>EOE != 0 -export module foo -EOI -stdin:2:1: error: ';' expected instead of -EOE diff --git a/unit-tests/cc/parser/module.testscript b/unit-tests/cc/parser/module.testscript new file mode 100644 index 0000000..c6a7e31 --- /dev/null +++ b/unit-tests/cc/parser/module.testscript @@ -0,0 +1,149 @@ +# file : unit-tests/cc/parser/module.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test C++ module constructs. +# + +: import +: +$* <>EOI +import foo; +import foo.bar; +import foo.bar.baz; +EOI + +: module-implementation +: +$* <>EOI +module foo; +EOI + +: module-interface +: +$* <>EOI +export module foo; +EOI + +: export-imported +: +$* <>EOO +export import foo; +EOI +export import foo; +EOO + +: export-imported-block +: +$* <>EOO +import bar; + +export {import foo;} + +export +{ + namespace foo + { + class c {}; + } + + template int f (); + + import bar; +} +EOI +export import bar; +export import foo; +EOO + +: non-module +: +$* <>EOO +import foo [[export({import})]]; +module bar [[module({module})]]; +EOI +import foo; +module bar; +EOO + +: import-duplicate +: +$* <>EOO +import foo; +import bar.baz; +import foo; +import bar . baz; +EOI +import foo; +import bar.baz; +EOO + +: brace-missing +: +$* <>EOE != 0 +export +{ + class foo + { + //}; + module foo; +} +EOI +stdin:8:1: error: {}-imbalance detected +EOE + +: brace-stray +: +$* <>EOE != 0 +export +{ + class foo + { + };} +} +module foo; +EOI +stdin:6:1: error: {}-imbalance detected +EOE + +: import-missing-name +: +$* <>EOE != 0 +import ; +EOI +stdin:1:8: error: module name expected instead of ';' +EOE + +: module-missing-name +: +$* <>EOE != 0 +module ; +EOI +stdin:1:1: error: module declaration expected after leading module marker +EOE + +: import-missing-semi +: +$* <>EOE != 0 +import foo +EOI +stdin:2:1: error: ';' expected instead of +EOE + +: module-missing-semi +: +$* <>EOE != 0 +export module foo +EOI +stdin:2:1: error: ';' expected instead of +EOE diff --git a/unit-tests/function/buildfile b/unit-tests/function/buildfile index a3eb72f..d318351 100644 --- a/unit-tests/function/buildfile +++ b/unit-tests/function/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../build2/ -exe{driver}: {hxx cxx}{*} ../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../build2/libu{b} testscript{*} diff --git a/unit-tests/function/call.test b/unit-tests/function/call.test deleted file mode 100644 index 3dd9a85..0000000 --- a/unit-tests/function/call.test +++ /dev/null @@ -1,161 +0,0 @@ -# file : unit-tests/function/call.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: qual-implicit -: -$* <'print $dummy.dummy0()' >'abc' - -: qual-explicit -: -$* <'print $dummy.qual()' >'abc' - -: qual-fail -: -$* <'print $qual()' 2>>EOE != 0 -buildfile:1:8: error: unmatched call to qual() - info: candidate: dummy.qual() -EOE - -: derived-base -: Test derived-to-base overload resolution -: -$* <'print $dummy.abs([dir_path] .)' >'false'; -$* <'print $dummy.abs([abs_dir_path] .)' >'true' - -: variadic -: -$* <'print $variadic([bool] true, foo, bar)' >'3' - -: fail -: -$* <'$fail()' 2>>EOE != 0 -error: failed -buildfile:1:2: info: while calling fail() -EOE - -: fail-invalid-arg -: -$* <'$fail_arg(abc)' 2>>EOE != 0 -error: invalid argument: invalid uint64 value: 'abc' -buildfile:1:2: info: while calling fail_arg() -EOE - -: no-match-name -: -$* <'$bogus()' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus() -EOE - -: no-match-count -: -$* <'$dummy0(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to dummy0() - info: candidate: dummy0(), qualified name dummy.dummy0 -EOE - -: no-match-type -: -$* <'$dummy1([uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to dummy1(uint64) - info: candidate: dummy1(string), qualified name dummy.dummy1 -EOE - -: ambig -: -$* <'$ambig(abc)' 2>>~/EOE/ != 0 -buildfile:1:2: error: ambiguous call to ambig() -/(( - info: candidate: ambig( [, uint64]), qualified name dummy.ambig - info: candidate: ambig( [, string]), qualified name dummy.ambig -/)|( - info: candidate: ambig( [, string]), qualified name dummy.ambig - info: candidate: ambig( [, uint64]), qualified name dummy.ambig -/)) -EOE - -: unmatched -: -$* <'$ambig(abc, def)' 2>>~/EOE/ != 0 -buildfile:1:2: error: unmatched call to ambig(, ) -/(( - info: candidate: ambig( [, uint64]), qualified name dummy.ambig - info: candidate: ambig( [, string]), qualified name dummy.ambig -/)|( - info: candidate: ambig( [, string]), qualified name dummy.ambig - info: candidate: ambig( [, uint64]), qualified name dummy.ambig -/)) -EOE - -: reverse -: -$* <'print $reverse([string] abc)' >'abc' - -: optional-absent -: -$* <'print $optional()' >'true' - -: optional-present -: -$* <'print $optional(abc)' >'false' - -: null-true -: -$* <'print $nullable([null])' >'true' - -: null-false -: -$* <'print $nullable(nonull)' >'false' - -: null-fail -: -$* <'$dummy1([string null])' 2>>EOE != 0 -error: invalid argument: null value -buildfile:1:2: info: while calling dummy1(string) -EOE - -: print-call-1-untyped -: -$* <'$bogus(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus() -EOE - -: print-call-1-typed -: -$* <'$bogus([uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus(uint64) -EOE - -: print-call-2 -: -$* <'$bogus(abc, [uint64] 123)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to bogus(, uint64) -EOE - -: print-fovl -: -$* <'$ambig([bool] true)' 2>>~/EOE/ != 0 -buildfile:1:2: error: ambiguous call to ambig(bool) -/(( - info: candidate: ambig( [, uint64]), qualified name dummy.ambig - info: candidate: ambig( [, string]), qualified name dummy.ambig -/)|( - info: candidate: ambig( [, string]), qualified name dummy.ambig - info: candidate: ambig( [, uint64]), qualified name dummy.ambig -/)) -EOE - -: print-fovl-variadic -: -$* <'$variadic(abc)' 2>>EOE != 0 -buildfile:1:2: error: unmatched call to variadic() - info: candidate: variadic(bool [, ...]) -EOE - -: member-function -: -$* <'print $dummy.length([path] abc)' >'3' - -: data-member -: -$* <'print $dummy.type([name] cxx{foo})' >'cxx' diff --git a/unit-tests/function/call.testscript b/unit-tests/function/call.testscript new file mode 100644 index 0000000..4bc5897 --- /dev/null +++ b/unit-tests/function/call.testscript @@ -0,0 +1,161 @@ +# file : unit-tests/function/call.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: qual-implicit +: +$* <'print $dummy.dummy0()' >'abc' + +: qual-explicit +: +$* <'print $dummy.qual()' >'abc' + +: qual-fail +: +$* <'print $qual()' 2>>EOE != 0 +buildfile:1:8: error: unmatched call to qual() + info: candidate: dummy.qual() +EOE + +: derived-base +: Test derived-to-base overload resolution +: +$* <'print $dummy.abs([dir_path] .)' >'false'; +$* <'print $dummy.abs([abs_dir_path] .)' >'true' + +: variadic +: +$* <'print $variadic([bool] true, foo, bar)' >'3' + +: fail +: +$* <'$fail()' 2>>EOE != 0 +error: failed +buildfile:1:2: info: while calling fail() +EOE + +: fail-invalid-arg +: +$* <'$fail_arg(abc)' 2>>EOE != 0 +error: invalid argument: invalid uint64 value: 'abc' +buildfile:1:2: info: while calling fail_arg() +EOE + +: no-match-name +: +$* <'$bogus()' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to bogus() +EOE + +: no-match-count +: +$* <'$dummy0(abc)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to dummy0() + info: candidate: dummy0(), qualified name dummy.dummy0 +EOE + +: no-match-type +: +$* <'$dummy1([uint64] 123)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to dummy1(uint64) + info: candidate: dummy1(string), qualified name dummy.dummy1 +EOE + +: ambig +: +$* <'$ambig(abc)' 2>>~/EOE/ != 0 +buildfile:1:2: error: ambiguous call to ambig() +/(( + info: candidate: ambig( [, uint64]), qualified name dummy.ambig + info: candidate: ambig( [, string]), qualified name dummy.ambig +/)|( + info: candidate: ambig( [, string]), qualified name dummy.ambig + info: candidate: ambig( [, uint64]), qualified name dummy.ambig +/)) +EOE + +: unmatched +: +$* <'$ambig(abc, def)' 2>>~/EOE/ != 0 +buildfile:1:2: error: unmatched call to ambig(, ) +/(( + info: candidate: ambig( [, uint64]), qualified name dummy.ambig + info: candidate: ambig( [, string]), qualified name dummy.ambig +/)|( + info: candidate: ambig( [, string]), qualified name dummy.ambig + info: candidate: ambig( [, uint64]), qualified name dummy.ambig +/)) +EOE + +: reverse +: +$* <'print $reverse([string] abc)' >'abc' + +: optional-absent +: +$* <'print $optional()' >'true' + +: optional-present +: +$* <'print $optional(abc)' >'false' + +: null-true +: +$* <'print $nullable([null])' >'true' + +: null-false +: +$* <'print $nullable(nonull)' >'false' + +: null-fail +: +$* <'$dummy1([string null])' 2>>EOE != 0 +error: invalid argument: null value +buildfile:1:2: info: while calling dummy1(string) +EOE + +: print-call-1-untyped +: +$* <'$bogus(abc)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to bogus() +EOE + +: print-call-1-typed +: +$* <'$bogus([uint64] 123)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to bogus(uint64) +EOE + +: print-call-2 +: +$* <'$bogus(abc, [uint64] 123)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to bogus(, uint64) +EOE + +: print-fovl +: +$* <'$ambig([bool] true)' 2>>~/EOE/ != 0 +buildfile:1:2: error: ambiguous call to ambig(bool) +/(( + info: candidate: ambig( [, uint64]), qualified name dummy.ambig + info: candidate: ambig( [, string]), qualified name dummy.ambig +/)|( + info: candidate: ambig( [, string]), qualified name dummy.ambig + info: candidate: ambig( [, uint64]), qualified name dummy.ambig +/)) +EOE + +: print-fovl-variadic +: +$* <'$variadic(abc)' 2>>EOE != 0 +buildfile:1:2: error: unmatched call to variadic() + info: candidate: variadic(bool [, ...]) +EOE + +: member-function +: +$* <'print $dummy.length([path] abc)' >'3' + +: data-member +: +$* <'print $dummy.type([name] cxx{foo})' >'cxx' diff --git a/unit-tests/function/syntax.test b/unit-tests/function/syntax.test deleted file mode 100644 index 4620e6a..0000000 --- a/unit-tests/function/syntax.test +++ /dev/null @@ -1,29 +0,0 @@ -# file : unit-tests/function/syntax.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -$* <'$dump()' >:'' : none -$* <'$dump( )' >:'' : none-in-spaces -$* <'$dump("")' >'{}' : one-empty -$* <'$dump(a)' >'a' : one-single -$* <'$dump(a b c)' >'a b c' : one-list -$* <'$dump(d/t{x y z})' >'d/t{x} d/t{y} d/t{z}' : one-names - -$* <'print a$dummy1([string] b)c' >'abc' : concat -$* <'print $dummy2([uint64] 123, [uint64] 321)' >'444' : multi-arg - -: quoting -: Verify we can inhibit function call with quoting -: -$* <>EOO -foo = FOO -bar = BAR - -print $foo"($bar)" -print "$foo"($bar) -print "$foo""($bar)" -EOI -FOOBAR -FOOBAR -FOOBAR -EOO diff --git a/unit-tests/function/syntax.testscript b/unit-tests/function/syntax.testscript new file mode 100644 index 0000000..c9c56d3 --- /dev/null +++ b/unit-tests/function/syntax.testscript @@ -0,0 +1,29 @@ +# file : unit-tests/function/syntax.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* <'$dump()' >:'' : none +$* <'$dump( )' >:'' : none-in-spaces +$* <'$dump("")' >'{}' : one-empty +$* <'$dump(a)' >'a' : one-single +$* <'$dump(a b c)' >'a b c' : one-list +$* <'$dump(d/t{x y z})' >'d/t{x} d/t{y} d/t{z}' : one-names + +$* <'print a$dummy1([string] b)c' >'abc' : concat +$* <'print $dummy2([uint64] 123, [uint64] 321)' >'444' : multi-arg + +: quoting +: Verify we can inhibit function call with quoting +: +$* <>EOO +foo = FOO +bar = BAR + +print $foo"($bar)" +print "$foo"($bar) +print "$foo""($bar)" +EOI +FOOBAR +FOOBAR +FOOBAR +EOO diff --git a/unit-tests/lexer/buildfile b/unit-tests/lexer/buildfile index 2e14979..7434018 100644 --- a/unit-tests/lexer/buildfile +++ b/unit-tests/lexer/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../build2/ -exe{driver}: {hxx cxx}{*} ../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../build2/libu{b} testscript{*} diff --git a/unit-tests/lexer/buildspec.test b/unit-tests/lexer/buildspec.test deleted file mode 100644 index 9aa0f55..0000000 --- a/unit-tests/lexer/buildspec.test +++ /dev/null @@ -1,16 +0,0 @@ -# file : unit-tests/lexer/buildspec.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = buildspec - -: punctuation -: -$* <:'x,x(x)' >>EOO -'x' -, -'x' - ( -'x' -) -EOO diff --git a/unit-tests/lexer/buildspec.testscript b/unit-tests/lexer/buildspec.testscript new file mode 100644 index 0000000..d3dd660 --- /dev/null +++ b/unit-tests/lexer/buildspec.testscript @@ -0,0 +1,16 @@ +# file : unit-tests/lexer/buildspec.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = buildspec + +: punctuation +: +$* <:'x,x(x)' >>EOO +'x' +, +'x' + ( +'x' +) +EOO diff --git a/unit-tests/lexer/comment.test b/unit-tests/lexer/comment.test deleted file mode 100644 index 8e0ef2e..0000000 --- a/unit-tests/lexer/comment.test +++ /dev/null @@ -1,139 +0,0 @@ -# file : unit-tests/lexer/comment.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: single-line -: -{ - : only - : - $* <>:EOO - # comment - EOI - EOO - - : first - : - $* <>EOO - # comment - foo - EOI - 'foo' - - EOO - - : last - : - $* <>EOO - foo - # comment - EOI - 'foo' - - EOO - - : few - : - $* <>EOO - foo - # comment - # comment - EOI - 'foo' - - EOO - - : cont - : - $* <>EOO - foo - # comment\\ - bar - EOI - 'foo' - - 'bar' - - EOO - - : same - : - $* <>EOO - foo # comment - bar # comment - EOI - 'foo' - - 'bar' - - EOO -} - -: multi-line -: -{ - : only - : - $* <>:EOO - #\ - comment - comment - #\ - EOI - EOO - - : empty - : - $* <>:EOO - #\ - #\ - EOI - EOO - - : start-same - : - $* <>EOO - foo #\ - comment - comment - #\ - EOI - 'foo' - - EOO - - : end-same - : - $* <>EOO - #\ - comment - comment - foo #\ - bar - EOI - 'bar' - - EOO - - : end-not - : - $* <>EOO - #\ - comment - #\ not an end - foo #\ - bar - EOI - 'bar' - - EOO - - : unterm - : - $* <>EOE != 0 - #\ - comment - EOI - stdin:3:1: error: unterminated multi-line comment - EOE -} diff --git a/unit-tests/lexer/comment.testscript b/unit-tests/lexer/comment.testscript new file mode 100644 index 0000000..44aee11 --- /dev/null +++ b/unit-tests/lexer/comment.testscript @@ -0,0 +1,139 @@ +# file : unit-tests/lexer/comment.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: single-line +: +{ + : only + : + $* <>:EOO + # comment + EOI + EOO + + : first + : + $* <>EOO + # comment + foo + EOI + 'foo' + + EOO + + : last + : + $* <>EOO + foo + # comment + EOI + 'foo' + + EOO + + : few + : + $* <>EOO + foo + # comment + # comment + EOI + 'foo' + + EOO + + : cont + : + $* <>EOO + foo + # comment\\ + bar + EOI + 'foo' + + 'bar' + + EOO + + : same + : + $* <>EOO + foo # comment + bar # comment + EOI + 'foo' + + 'bar' + + EOO +} + +: multi-line +: +{ + : only + : + $* <>:EOO + #\ + comment + comment + #\ + EOI + EOO + + : empty + : + $* <>:EOO + #\ + #\ + EOI + EOO + + : start-same + : + $* <>EOO + foo #\ + comment + comment + #\ + EOI + 'foo' + + EOO + + : end-same + : + $* <>EOO + #\ + comment + comment + foo #\ + bar + EOI + 'bar' + + EOO + + : end-not + : + $* <>EOO + #\ + comment + #\ not an end + foo #\ + bar + EOI + 'bar' + + EOO + + : unterm + : + $* <>EOE != 0 + #\ + comment + EOI + stdin:3:1: error: unterminated multi-line comment + EOE +} diff --git a/unit-tests/lexer/eval.test b/unit-tests/lexer/eval.test deleted file mode 100644 index 4bd33c4..0000000 --- a/unit-tests/lexer/eval.test +++ /dev/null @@ -1,76 +0,0 @@ -# file : unit-tests/lexer/eval.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = eval - -: punctuation -: -$* <:'x:x{x}x[x]x$x?x,x(x)' >>EOO -'x' -: -'x' -{ -'x' -} -'x' -[ -'x' -] -'x' -$ -'x' -? -'x' -, -'x' -( -'x' -) -EOO - -: logical -: -$* <:'x|x||x&x&&x!x!!x)' >>EOO -'x|x' -|| -'x&x' -&& -'x' -! -'x' -! -! -'x' -) -EOO - -: comparison -: -$* <:'x=x==x!=xx>=)' >>EOO -'x=x' -== -'x' -!= -'x' -< -'x' -<= -'x' -> -'x' ->= -) -EOO - -: newline -: -$* <'x' >- 2>>EOE != 0 -stdin:1:2: error: newline in evaluation context -EOE - -: eof -: -$* <:'' 2>>EOE != 0 -stdin:1:1: error: unterminated evaluation context -EOE diff --git a/unit-tests/lexer/eval.testscript b/unit-tests/lexer/eval.testscript new file mode 100644 index 0000000..f09eed4 --- /dev/null +++ b/unit-tests/lexer/eval.testscript @@ -0,0 +1,76 @@ +# file : unit-tests/lexer/eval.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = eval + +: punctuation +: +$* <:'x:x{x}x[x]x$x?x,x(x)' >>EOO +'x' +: +'x' +{ +'x' +} +'x' +[ +'x' +] +'x' +$ +'x' +? +'x' +, +'x' +( +'x' +) +EOO + +: logical +: +$* <:'x|x||x&x&&x!x!!x)' >>EOO +'x|x' +|| +'x&x' +&& +'x' +! +'x' +! +! +'x' +) +EOO + +: comparison +: +$* <:'x=x==x!=xx>=)' >>EOO +'x=x' +== +'x' +!= +'x' +< +'x' +<= +'x' +> +'x' +>= +) +EOO + +: newline +: +$* <'x' >- 2>>EOE != 0 +stdin:1:2: error: newline in evaluation context +EOE + +: eof +: +$* <:'' 2>>EOE != 0 +stdin:1:1: error: unterminated evaluation context +EOE diff --git a/unit-tests/lexer/quoting.test b/unit-tests/lexer/quoting.test deleted file mode 100644 index 708e904..0000000 --- a/unit-tests/lexer/quoting.test +++ /dev/null @@ -1,108 +0,0 @@ -# file : unit-tests/lexer/quoting.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.options += -q - -: unquoted -: -$* <'foo' >>EOO -'foo' - -EOO - -: comp -: -{ - : single - : - $* <":'foo':" >>EOO - : - 'foo' [S/C] - : - - EOO - - : double - : - $* <':"foo":' >>EOO - : - 'foo' [D/C] - : - - EOO - - : single-empty - : - $* <"''" >>EOO - '' [S/C] - - EOO - - : double-empty - : - $* <'""' >>EOO - '' [D/C] - - EOO -} - -: part -{ - : quoted - { - : start - : Token start already quoted - : - $* <'"$foo"' >>EOO - '' [D/P] - $ [D/C] - 'foo' [D/P] - - EOO - - : end - : Token end still quoted - : - $* <'"foo$"' >>EOO - 'foo' [D/P] - $ [D/C] - '' [D/P] - - EOO - } - - : unquoted - { - : start - : Token starts with unquoted character - : - $* <'f"oo"' >>EOO - 'foo' [D/P] - - EOO - - : end - : Token continous with unquoted character - : - $* <'"fo"o' >>EOO - 'foo' [D/P] - - EOO - - : escape - : Token continous with unquoted escaped character - : - $* <'"fo"\"' >>EOO - 'fo"' [D/P] - - EOO - } -} - -: mixed -: -$* <"\"fo\"'o'" >>EOO -'foo' [M/P] - -EOO diff --git a/unit-tests/lexer/quoting.testscript b/unit-tests/lexer/quoting.testscript new file mode 100644 index 0000000..8543a67 --- /dev/null +++ b/unit-tests/lexer/quoting.testscript @@ -0,0 +1,108 @@ +# file : unit-tests/lexer/quoting.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.options += -q + +: unquoted +: +$* <'foo' >>EOO +'foo' + +EOO + +: comp +: +{ + : single + : + $* <":'foo':" >>EOO + : + 'foo' [S/C] + : + + EOO + + : double + : + $* <':"foo":' >>EOO + : + 'foo' [D/C] + : + + EOO + + : single-empty + : + $* <"''" >>EOO + '' [S/C] + + EOO + + : double-empty + : + $* <'""' >>EOO + '' [D/C] + + EOO +} + +: part +{ + : quoted + { + : start + : Token start already quoted + : + $* <'"$foo"' >>EOO + '' [D/P] + $ [D/C] + 'foo' [D/P] + + EOO + + : end + : Token end still quoted + : + $* <'"foo$"' >>EOO + 'foo' [D/P] + $ [D/C] + '' [D/P] + + EOO + } + + : unquoted + { + : start + : Token starts with unquoted character + : + $* <'f"oo"' >>EOO + 'foo' [D/P] + + EOO + + : end + : Token continous with unquoted character + : + $* <'"fo"o' >>EOO + 'foo' [D/P] + + EOO + + : escape + : Token continous with unquoted escaped character + : + $* <'"fo"\"' >>EOO + 'fo"' [D/P] + + EOO + } +} + +: mixed +: +$* <"\"fo\"'o'" >>EOO +'foo' [M/P] + +EOO diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile index 34c5d9f..bbfc032 100644 --- a/unit-tests/test/script/lexer/buildfile +++ b/unit-tests/test/script/lexer/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../../../build2/ -exe{driver}: {hxx cxx}{*} ../../../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../../../build2/libu{b} testscript{*} diff --git a/unit-tests/test/script/lexer/command-expansion.test b/unit-tests/test/script/lexer/command-expansion.test deleted file mode 100644 index 88d7ced..0000000 --- a/unit-tests/test/script/lexer/command-expansion.test +++ /dev/null @@ -1,248 +0,0 @@ -# file : unit-tests/test/script/lexer/command-expansion.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = command-expansion - -: pass-redirect -: -{ - : in - : - $* <:"0<|" >>EOO - '0' - <| - EOO - - : arg-in - : - $* <:"0 <|" >>EOO - '0 ' - <| - EOO - - : out - : - $* <:"1>|" >>EOO - '1' - >| - EOO - - : arg-out - : - $* <:"1 >|" >>EOO - '1 ' - >| - EOO -} - -: null-redirect -: -{ - : in - : - $* <:"0<-" >>EOO - '0' - <- - EOO - - : arg-in - : - $* <:"0 <-" >>EOO - '0 ' - <- - EOO - - : out - : - $* <:"1>-" >>EOO - '1' - >- - EOO - - : arg-out - : - $* <:"1 >-" >>EOO - '1 ' - >- - EOO -} - -: trace-redirect -: -{ - : out - : - $* <:"1>!" >>EOO - '1' - >! - EOO - - : arg-out - : - $* <:"1 >!" >>EOO - '1 ' - >! - EOO -} - -: merge-redirect -: -{ - : out - : - $* <:"1>&2" >>EOO - '1' - >& - '2' - EOO - - : arg-out - : - $* <:"1 >&2" >>EOO - '1 ' - >& - '2' - EOO -} - -: str-redirect -: -{ - : in - : - { - : newline - : - $* <:"0>EOO - '0' - < - 'a b' - EOO - - : no-newline - : - $* <:"0<:a b" >>EOO - '0' - <: - 'a b' - EOO - } - - : out - : - { - : newline - : - $* <:"1>a b" >>EOO - '1' - > - 'a b' - EOO - - : no-newline - : - $* <:"1>:a b" >>EOO - '1' - >: - 'a b' - EOO - } -} - -: doc-redirect -: -{ - : in - : - { - : newline - : - $* <:"0<>EOO - '0' - << - 'E O I' - EOO - - : no-newline - : - $* <:"0<<:E O I" >>EOO - '0' - <<: - 'E O I' - EOO - } - - : out - : - { - : newline - : - $* <:"1>>E O O" >>EOO - '1' - >> - 'E O O' - EOO - - : no-newline - : - $* <:"1>>:E O O" >>EOO - '1' - >>: - 'E O O' - EOO - } -} - -: file-redirect -: -{ - : in - : - $* <:"0<<>EOO - '0' - <<< - 'a b' - EOO - - : out - : - $* <:"1>=a b" >>EOO - '1' - >= - 'a b' - EOO - - : out-app - : - $* <:"1>+a b" >>EOO - '1' - >+ - 'a b' - EOO -} - -: cleanup -: -{ - : always - : - $* <:"&file" >>EOO - & - 'file' - EOO - - : maybe - : - $* <:"&?file" >>EOO - &? - 'file' - EOO - - : never - : - $* <:"&!file" >>EOO - &! - 'file' - EOO -} diff --git a/unit-tests/test/script/lexer/command-expansion.testscript b/unit-tests/test/script/lexer/command-expansion.testscript new file mode 100644 index 0000000..228fb61 --- /dev/null +++ b/unit-tests/test/script/lexer/command-expansion.testscript @@ -0,0 +1,248 @@ +# file : unit-tests/test/script/lexer/command-expansion.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = command-expansion + +: pass-redirect +: +{ + : in + : + $* <:"0<|" >>EOO + '0' + <| + EOO + + : arg-in + : + $* <:"0 <|" >>EOO + '0 ' + <| + EOO + + : out + : + $* <:"1>|" >>EOO + '1' + >| + EOO + + : arg-out + : + $* <:"1 >|" >>EOO + '1 ' + >| + EOO +} + +: null-redirect +: +{ + : in + : + $* <:"0<-" >>EOO + '0' + <- + EOO + + : arg-in + : + $* <:"0 <-" >>EOO + '0 ' + <- + EOO + + : out + : + $* <:"1>-" >>EOO + '1' + >- + EOO + + : arg-out + : + $* <:"1 >-" >>EOO + '1 ' + >- + EOO +} + +: trace-redirect +: +{ + : out + : + $* <:"1>!" >>EOO + '1' + >! + EOO + + : arg-out + : + $* <:"1 >!" >>EOO + '1 ' + >! + EOO +} + +: merge-redirect +: +{ + : out + : + $* <:"1>&2" >>EOO + '1' + >& + '2' + EOO + + : arg-out + : + $* <:"1 >&2" >>EOO + '1 ' + >& + '2' + EOO +} + +: str-redirect +: +{ + : in + : + { + : newline + : + $* <:"0>EOO + '0' + < + 'a b' + EOO + + : no-newline + : + $* <:"0<:a b" >>EOO + '0' + <: + 'a b' + EOO + } + + : out + : + { + : newline + : + $* <:"1>a b" >>EOO + '1' + > + 'a b' + EOO + + : no-newline + : + $* <:"1>:a b" >>EOO + '1' + >: + 'a b' + EOO + } +} + +: doc-redirect +: +{ + : in + : + { + : newline + : + $* <:"0<>EOO + '0' + << + 'E O I' + EOO + + : no-newline + : + $* <:"0<<:E O I" >>EOO + '0' + <<: + 'E O I' + EOO + } + + : out + : + { + : newline + : + $* <:"1>>E O O" >>EOO + '1' + >> + 'E O O' + EOO + + : no-newline + : + $* <:"1>>:E O O" >>EOO + '1' + >>: + 'E O O' + EOO + } +} + +: file-redirect +: +{ + : in + : + $* <:"0<<>EOO + '0' + <<< + 'a b' + EOO + + : out + : + $* <:"1>=a b" >>EOO + '1' + >= + 'a b' + EOO + + : out-app + : + $* <:"1>+a b" >>EOO + '1' + >+ + 'a b' + EOO +} + +: cleanup +: +{ + : always + : + $* <:"&file" >>EOO + & + 'file' + EOO + + : maybe + : + $* <:"&?file" >>EOO + &? + 'file' + EOO + + : never + : + $* <:"&!file" >>EOO + &! + 'file' + EOO +} diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test deleted file mode 100644 index 0b396b8..0000000 --- a/unit-tests/test/script/lexer/command-line.test +++ /dev/null @@ -1,208 +0,0 @@ -# file : unit-tests/test/script/lexer/command-line.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = command-line - -: semi -{ - : immediate - : - $* <"cmd;" >>EOO - 'cmd' - ; - - EOO - - : separated - : - $* <"cmd ;" >>EOO - 'cmd' - ; - - EOO - - : only - : - $* <";" >>EOO - ; - - EOO -} - -: colon -: -{ - : immediate - : - $* <"cmd: dsc" >>EOO - 'cmd' - : - 'dsc' - - EOO - - : separated - : - $* <"cmd :dsc" >>EOO - 'cmd' - : - 'dsc' - - EOO - - : only - : - $* <":" >>EOO - : - - EOO -} - -: redirect -: -{ - : pass - : - $* <"cmd <| 1>|" >>EOO - 'cmd' - <| - '1' - >| - - EOO - - : null - : - $* <"cmd <- 1>-" >>EOO - 'cmd' - <- - '1' - >- - - EOO - - : trace - : - $* <"cmd 1>!" >>EOO - 'cmd' - '1' - >! - - EOO - - : merge - : - $* <"cmd 1>&2" >>EOO - 'cmd' - '1' - >& - '2' - - EOO - - : str - : - $* <"cmd b" >>EOO - 'cmd' - < - 'a' - '1' - > - 'b' - - EOO - - : str-nn - : - $* <"cmd <:a 1>:b" >>EOO - 'cmd' - <: - 'a' - '1' - >: - 'b' - - EOO - - : doc - : - $* <"cmd <>EOO" >>EOO - 'cmd' - << - 'EOI' - '1' - >> - 'EOO' - - EOO - - : doc-nn - : - $* <"cmd <<:EOI 1>>:EOO" >>EOO - 'cmd' - <<: - 'EOI' - '1' - >>: - 'EOO' - - EOO - - : file-cmp - : - $* <"cmd <<>>out 2>>>err" >>EOO - 'cmd' - <<< - 'in' - >>> - 'out' - '2' - >>> - 'err' - - EOO - - : file-write - : - $* <"cmd >=out 2>+err" >>EOO - 'cmd' - >= - 'out' - '2' - >+ - 'err' - - EOO -} - -: cleanup -: -{ - : always - : - $* <"cmd &file" >>EOO - 'cmd' - & - 'file' - - EOO - - : maybe - : - $* <"cmd &?file" >>EOO - 'cmd' - &? - 'file' - - EOO - - : never - : - $* <"cmd &!file" >>EOO - 'cmd' - &! - 'file' - - EOO -} diff --git a/unit-tests/test/script/lexer/command-line.testscript b/unit-tests/test/script/lexer/command-line.testscript new file mode 100644 index 0000000..f84bc86 --- /dev/null +++ b/unit-tests/test/script/lexer/command-line.testscript @@ -0,0 +1,208 @@ +# file : unit-tests/test/script/lexer/command-line.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = command-line + +: semi +{ + : immediate + : + $* <"cmd;" >>EOO + 'cmd' + ; + + EOO + + : separated + : + $* <"cmd ;" >>EOO + 'cmd' + ; + + EOO + + : only + : + $* <";" >>EOO + ; + + EOO +} + +: colon +: +{ + : immediate + : + $* <"cmd: dsc" >>EOO + 'cmd' + : + 'dsc' + + EOO + + : separated + : + $* <"cmd :dsc" >>EOO + 'cmd' + : + 'dsc' + + EOO + + : only + : + $* <":" >>EOO + : + + EOO +} + +: redirect +: +{ + : pass + : + $* <"cmd <| 1>|" >>EOO + 'cmd' + <| + '1' + >| + + EOO + + : null + : + $* <"cmd <- 1>-" >>EOO + 'cmd' + <- + '1' + >- + + EOO + + : trace + : + $* <"cmd 1>!" >>EOO + 'cmd' + '1' + >! + + EOO + + : merge + : + $* <"cmd 1>&2" >>EOO + 'cmd' + '1' + >& + '2' + + EOO + + : str + : + $* <"cmd b" >>EOO + 'cmd' + < + 'a' + '1' + > + 'b' + + EOO + + : str-nn + : + $* <"cmd <:a 1>:b" >>EOO + 'cmd' + <: + 'a' + '1' + >: + 'b' + + EOO + + : doc + : + $* <"cmd <>EOO" >>EOO + 'cmd' + << + 'EOI' + '1' + >> + 'EOO' + + EOO + + : doc-nn + : + $* <"cmd <<:EOI 1>>:EOO" >>EOO + 'cmd' + <<: + 'EOI' + '1' + >>: + 'EOO' + + EOO + + : file-cmp + : + $* <"cmd <<>>out 2>>>err" >>EOO + 'cmd' + <<< + 'in' + >>> + 'out' + '2' + >>> + 'err' + + EOO + + : file-write + : + $* <"cmd >=out 2>+err" >>EOO + 'cmd' + >= + 'out' + '2' + >+ + 'err' + + EOO +} + +: cleanup +: +{ + : always + : + $* <"cmd &file" >>EOO + 'cmd' + & + 'file' + + EOO + + : maybe + : + $* <"cmd &?file" >>EOO + 'cmd' + &? + 'file' + + EOO + + : never + : + $* <"cmd &!file" >>EOO + 'cmd' + &! + 'file' + + EOO +} diff --git a/unit-tests/test/script/lexer/description-line.test b/unit-tests/test/script/lexer/description-line.test deleted file mode 100644 index 5f2ea13..0000000 --- a/unit-tests/test/script/lexer/description-line.test +++ /dev/null @@ -1,33 +0,0 @@ -# file : unit-tests/test/script/lexer/description-line.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = description-line - -: full -: -$* <" foo bar " >>EOO -' foo bar ' - -EOO - -: space -: -$* <" " >>EOO -' ' - -EOO - -: empty -: -$* <"" >>EOO - -EOO - -: eof -: -$* <:"foo" >>EOO 2>>EOE != 0 -'foo' -EOO -stdin:1:4: error: expected newline at the end of description line -EOE diff --git a/unit-tests/test/script/lexer/description-line.testscript b/unit-tests/test/script/lexer/description-line.testscript new file mode 100644 index 0000000..e14c8a0 --- /dev/null +++ b/unit-tests/test/script/lexer/description-line.testscript @@ -0,0 +1,33 @@ +# file : unit-tests/test/script/lexer/description-line.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = description-line + +: full +: +$* <" foo bar " >>EOO +' foo bar ' + +EOO + +: space +: +$* <" " >>EOO +' ' + +EOO + +: empty +: +$* <"" >>EOO + +EOO + +: eof +: +$* <:"foo" >>EOO 2>>EOE != 0 +'foo' +EOO +stdin:1:4: error: expected newline at the end of description line +EOE diff --git a/unit-tests/test/script/lexer/first-token.test b/unit-tests/test/script/lexer/first-token.test deleted file mode 100644 index d754d69..0000000 --- a/unit-tests/test/script/lexer/first-token.test +++ /dev/null @@ -1,97 +0,0 @@ -# file : unit-tests/test/script/lexer/first-token.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Note: this mode auto-expires after each token. -# -test.arguments = first-token - -: dot -: -$* <"." >>EOO -. - -EOO - -: semi -: -$* <";" >>EOO -; - -EOO - -: colon -: -$* <":" >>EOO -: - -EOO - -: lcbrace -: -$* <"{" >>EOO -{ - -EOO - -: rcbrace -: -$* <"}" >>EOO -} - -EOO - -: setup -: -$* <"+foo" >>EOO -+ -'foo' - -EOO - -: tdown -: -$* <"- foo" >>EOO -- -'foo' - -EOO - -: plus-leading -: -$* <"foo+bar" >>EOO -'foo+bar' - -EOO - -: minus-leading -: -$* <"foo- x" >>EOO -'foo-' -'x' - -EOO - -: assign -: -$* <"foo=" >>EOO -'foo' -'=' - -EOO - -: append -: -$* <"foo+=" >>EOO -'foo' -'+=' - -EOO - -: prepend -: -$* <"foo=+" >>EOO -'foo' -'=+' - -EOO diff --git a/unit-tests/test/script/lexer/first-token.testscript b/unit-tests/test/script/lexer/first-token.testscript new file mode 100644 index 0000000..0484b6d --- /dev/null +++ b/unit-tests/test/script/lexer/first-token.testscript @@ -0,0 +1,97 @@ +# file : unit-tests/test/script/lexer/first-token.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Note: this mode auto-expires after each token. +# +test.arguments = first-token + +: dot +: +$* <"." >>EOO +. + +EOO + +: semi +: +$* <";" >>EOO +; + +EOO + +: colon +: +$* <":" >>EOO +: + +EOO + +: lcbrace +: +$* <"{" >>EOO +{ + +EOO + +: rcbrace +: +$* <"}" >>EOO +} + +EOO + +: setup +: +$* <"+foo" >>EOO ++ +'foo' + +EOO + +: tdown +: +$* <"- foo" >>EOO +- +'foo' + +EOO + +: plus-leading +: +$* <"foo+bar" >>EOO +'foo+bar' + +EOO + +: minus-leading +: +$* <"foo- x" >>EOO +'foo-' +'x' + +EOO + +: assign +: +$* <"foo=" >>EOO +'foo' +'=' + +EOO + +: append +: +$* <"foo+=" >>EOO +'foo' +'+=' + +EOO + +: prepend +: +$* <"foo=+" >>EOO +'foo' +'=+' + +EOO diff --git a/unit-tests/test/script/lexer/second-token.test b/unit-tests/test/script/lexer/second-token.test deleted file mode 100644 index 8b3f452..0000000 --- a/unit-tests/test/script/lexer/second-token.test +++ /dev/null @@ -1,68 +0,0 @@ -# file : unit-tests/test/script/lexer/second-token.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Note: this mode auto-expires after each token. -# -test.arguments = second-token - -: semi -: -$* <";" >>EOO -; - -EOO - -: colon -: -$* <":" >>EOO -: - -EOO - -: assign -: -$* <"=foo" >>EOO -= -'foo' - -EOO - -: append -: -$* <"+= foo" >>EOO -+= -'foo' - -EOO - -: prepend -: -$* <" =+ foo" >>EOO -=+ -'foo' - -EOO - -: assign-leading -: -$* <"foo=bar" >>EOO -'foo=bar' - -EOO - -: append-leading -: -$* <"foo+= bar" >>EOO -'foo+=' -'bar' - -EOO - -: prepend-leading -: -$* <"foo =+bar" >>EOO -'foo' -'=+bar' - -EOO diff --git a/unit-tests/test/script/lexer/second-token.testscript b/unit-tests/test/script/lexer/second-token.testscript new file mode 100644 index 0000000..d7cc501 --- /dev/null +++ b/unit-tests/test/script/lexer/second-token.testscript @@ -0,0 +1,68 @@ +# file : unit-tests/test/script/lexer/second-token.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Note: this mode auto-expires after each token. +# +test.arguments = second-token + +: semi +: +$* <";" >>EOO +; + +EOO + +: colon +: +$* <":" >>EOO +: + +EOO + +: assign +: +$* <"=foo" >>EOO += +'foo' + +EOO + +: append +: +$* <"+= foo" >>EOO ++= +'foo' + +EOO + +: prepend +: +$* <" =+ foo" >>EOO +=+ +'foo' + +EOO + +: assign-leading +: +$* <"foo=bar" >>EOO +'foo=bar' + +EOO + +: append-leading +: +$* <"foo+= bar" >>EOO +'foo+=' +'bar' + +EOO + +: prepend-leading +: +$* <"foo =+bar" >>EOO +'foo' +'=+bar' + +EOO diff --git a/unit-tests/test/script/lexer/variable-line.test b/unit-tests/test/script/lexer/variable-line.test deleted file mode 100644 index 68d3a71..0000000 --- a/unit-tests/test/script/lexer/variable-line.test +++ /dev/null @@ -1,28 +0,0 @@ -# file : unit-tests/test/script/lexer/variable-line.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = variable-line - -: semi -: -$* <"cmd;" >>EOO -'cmd' -; - -EOO - -: semi-separated -: -$* <"cmd ;" >>EOO -'cmd' -; - -EOO - -: semi-only -: -$* <";" >>EOO -; - -EOO diff --git a/unit-tests/test/script/lexer/variable-line.testscript b/unit-tests/test/script/lexer/variable-line.testscript new file mode 100644 index 0000000..b28bc93 --- /dev/null +++ b/unit-tests/test/script/lexer/variable-line.testscript @@ -0,0 +1,28 @@ +# file : unit-tests/test/script/lexer/variable-line.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +test.arguments = variable-line + +: semi +: +$* <"cmd;" >>EOO +'cmd' +; + +EOO + +: semi-separated +: +$* <"cmd ;" >>EOO +'cmd' +; + +EOO + +: semi-only +: +$* <";" >>EOO +; + +EOO diff --git a/unit-tests/test/script/lexer/variable.test b/unit-tests/test/script/lexer/variable.test deleted file mode 100644 index 60106ab..0000000 --- a/unit-tests/test/script/lexer/variable.test +++ /dev/null @@ -1,70 +0,0 @@ -# file : unit-tests/test/script/lexer/variable.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test handling custom variable names ($*, $~, $NN). -# -test.arguments = variable - -: command -: -{ - : only - : - $* <"*" >>EOO - '*' - - EOO - - : followed - : - $* <"*abc" >>EOO - '*' - 'abc' - - EOO -} - -: working-dir -: -{ - : only - : - $* <"~" >>EOO - '~' - - EOO - - : followed - : - $* <"~123" >>EOO - '~' - '123' - - EOO -} - -: arg -: -{ - : only - : - $* <"0" >>EOO - '0' - - EOO - - : followed - : - $* <"1abc" >>EOO - '1' - 'abc' - - EOO - - : multi-digit - : - $* <"10" 2>>EOE != 0 - stdin:1:1: error: multi-digit special variable name - EOE -} diff --git a/unit-tests/test/script/lexer/variable.testscript b/unit-tests/test/script/lexer/variable.testscript new file mode 100644 index 0000000..b4f793e --- /dev/null +++ b/unit-tests/test/script/lexer/variable.testscript @@ -0,0 +1,70 @@ +# file : unit-tests/test/script/lexer/variable.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Test handling custom variable names ($*, $~, $NN). +# +test.arguments = variable + +: command +: +{ + : only + : + $* <"*" >>EOO + '*' + + EOO + + : followed + : + $* <"*abc" >>EOO + '*' + 'abc' + + EOO +} + +: working-dir +: +{ + : only + : + $* <"~" >>EOO + '~' + + EOO + + : followed + : + $* <"~123" >>EOO + '~' + '123' + + EOO +} + +: arg +: +{ + : only + : + $* <"0" >>EOO + '0' + + EOO + + : followed + : + $* <"1abc" >>EOO + '1' + 'abc' + + EOO + + : multi-digit + : + $* <"10" 2>>EOE != 0 + stdin:1:1: error: multi-digit special variable name + EOE +} diff --git a/unit-tests/test/script/parser/buildfile b/unit-tests/test/script/parser/buildfile index ee0e26d..173b15d 100644 --- a/unit-tests/test/script/parser/buildfile +++ b/unit-tests/test/script/parser/buildfile @@ -3,4 +3,4 @@ # license : MIT; see accompanying LICENSE file include ../../../../build2/ -exe{driver}: {hxx cxx}{*} ../../../../build2/libu{b} test{*} +exe{driver}: {hxx cxx}{*} ../../../../build2/libu{b} testscript{*} diff --git a/unit-tests/test/script/parser/cleanup.test b/unit-tests/test/script/parser/cleanup.test deleted file mode 100644 index 1b43c90..0000000 --- a/unit-tests/test/script/parser/cleanup.test +++ /dev/null @@ -1,58 +0,0 @@ -# file : unit-tests/test/script/parser/cleanup.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: always -: -$* <>EOO -cmd &file -EOI -cmd &file -EOO - -: maybe -: -$* <>EOO -cmd &?file -EOI -cmd &?file -EOO - -: never -: -$* <>EOO -cmd &!file -EOI -cmd &!file -EOO - -: empty -: -$* <>EOE != 0 -cmd &"" -EOI -testscript:1:6: error: empty cleanup path -EOE - -: missed-before -: -{ - : token - : - : Path missed before command next token - : - $* <>EOE != 0 - cmd & >file - EOI - testscript:1:7: error: missing cleanup path - EOE - - : end - : Test path missed before end of command - : - $* <>EOE != 0 - cmd & - EOI - testscript:1:6: error: missing cleanup path - EOE -} diff --git a/unit-tests/test/script/parser/cleanup.testscript b/unit-tests/test/script/parser/cleanup.testscript new file mode 100644 index 0000000..b429f5d --- /dev/null +++ b/unit-tests/test/script/parser/cleanup.testscript @@ -0,0 +1,58 @@ +# file : unit-tests/test/script/parser/cleanup.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: always +: +$* <>EOO +cmd &file +EOI +cmd &file +EOO + +: maybe +: +$* <>EOO +cmd &?file +EOI +cmd &?file +EOO + +: never +: +$* <>EOO +cmd &!file +EOI +cmd &!file +EOO + +: empty +: +$* <>EOE != 0 +cmd &"" +EOI +testscript:1:6: error: empty cleanup path +EOE + +: missed-before +: +{ + : token + : + : Path missed before command next token + : + $* <>EOE != 0 + cmd & >file + EOI + testscript:1:7: error: missing cleanup path + EOE + + : end + : Test path missed before end of command + : + $* <>EOE != 0 + cmd & + EOI + testscript:1:6: error: missing cleanup path + EOE +} diff --git a/unit-tests/test/script/parser/command-if.test b/unit-tests/test/script/parser/command-if.test deleted file mode 100644 index 4936553..0000000 --- a/unit-tests/test/script/parser/command-if.test +++ /dev/null @@ -1,548 +0,0 @@ -# file : unit-tests/test/script/parser/command-if.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: if -: -{ - : true - : - $* <>EOO - if true foo - cmd1 - cmd2 - end - EOI - ? true foo - cmd1 - cmd2 - EOO - - : false - : - $* <>EOO - if false foo - cmd1 - cmd2 - end - EOI - ? false foo - EOO - - : not-true - : - $* <>EOO - if! true foo - cmd1 - cmd2 - end - EOI - ? true foo - EOO - - : not-false - : - $* <>EOO - if! false foo - cmd1 - cmd2 - end - EOI - ? false foo - cmd1 - cmd2 - EOO - - : without-command - : - $* <>EOE != 0 - if - cmd - end - EOI - testscript:1:3: error: missing program - EOE - - : after-semi - : - $* -s <>EOO - cmd1; - if true - cmd2 - end - EOI - { - { - cmd1 - ? true - cmd2 - } - } - EOO - - : setup - : - $* -s <>EOO - +if true - cmd - end - EOI - { - ? true - +cmd - } - EOO - - : tdown - : - $* -s <>EOO - -if true - cmd - end - EOI - { - ? true - -cmd - } - EOO -} - -: elif -: -{ - : true - : - $* <>EOO - if false - cmd1 - cmd2 - elif true - cmd3 - cmd4 - end - EOI - ? false - ? true - cmd3 - cmd4 - EOO - - : false - : - $* <>EOO - if false - cmd1 - cmd2 - elif false - cmd3 - cmd4 - end - EOI - ? false - ? false - EOO - - : not-true - : - $* <>EOO - if false - cmd1 - cmd2 - elif! true - cmd3 - cmd4 - end - EOI - ? false - ? true - EOO - - : not-false - : - $* <>EOO - if false - cmd1 - cmd2 - elif! false - cmd3 - cmd4 - end - EOI - ? false - ? false - cmd3 - cmd4 - EOO - - : without-if - : - $* <>EOE != 0 - cmd - elif true - cmd - end - EOI - testscript:2:1: error: 'elif' without preceding 'if' - EOE - - : not-without-if - : - $* <>EOE != 0 - cmd - elif! true - cmd - end - EOI - testscript:2:1: error: 'elif!' without preceding 'if' - EOE - - : after-else - : - $* <>EOE != 0 - if false - cmd - else - cmd - elif true - cmd - end - EOI - testscript:5:1: error: 'elif' after 'else' - EOE -} - -: else -: -{ - : true - : - $* <>EOO - if false - cmd1 - cmd2 - else - cmd3 - cmd4 - end - EOI - ? false - cmd3 - cmd4 - EOO - - : false - : - $* <>EOO - if true - cmd1 - cmd2 - else - cmd3 - cmd4 - end - EOI - ? true - cmd1 - cmd2 - EOO - - : chain - : - $* <>EOO - if false - cmd - cmd - elif false - cmd - cmd - elif false - cmd - cmd - elif true - cmd1 - cmd2 - elif false - cmd - cmd - else - cmd - cmd - end - EOI - ? false - ? false - ? false - ? true - cmd1 - cmd2 - EOO - - : command-after - : - $* <>EOE != 0 - if true - cmd - else cmd - cmd - end - EOI - testscript:3:6: error: expected newline instead of 'cmd' - EOE - - : without-if - : - $* <>EOE != 0 - cmd - else - cmd - end - EOI - testscript:2:1: error: 'else' without preceding 'if' - EOE - - : after-else - : - $* <>EOE != 0 - if false - cmd - else - cmd - else - cmd - end - EOI - testscript:5:1: error: 'else' after 'else' - EOE -} - -: end -{ - : without-if - : - $* <>EOE != 0 - cmd - end - EOI - testscript:2:1: error: 'end' without preceding 'if' - EOE - - : before - { - : semi - : - $* -s <>EOO - if true - cmd1 - end; - cmd2 - EOI - { - { - ? true - cmd1 - cmd2 - } - } - EOO - - : command - : - $* <>EOE != 0 - if true - cmd - end cmd - EOI - testscript:3:5: error: expected newline instead of 'cmd' - EOE - - : colon - : - $* -s <>EOO - if true - cmd1 - cmd2 - end : test - EOI - { - : id:test - { - ? true - cmd1 - cmd2 - } - } - EOO - } -} - -: nested -: -{ - : take - : - $* <>EOO - if true - cmd1 - if false - cmd - elif false - if true - cmd - end - else - cmd2 - end - cmd3 - end - EOI - ? true - cmd1 - ? false - ? false - cmd2 - cmd3 - EOO - - : skip - : - $* <>EOO - if false - cmd1 - if false - cmd - elif false - if true - cmd - end - else - cmd2 - end - cmd3 - else - cmd - end - EOI - ? false - cmd - EOO -} - -: contained -{ - : semi - : - $* <>EOE != 0 - if - cmd; - cmd - end - EOI - testscript:2:3: error: ';' inside 'if' - EOE - - : colon-leading - : - $* <>EOE != 0 - if - : foo - cmd - end - EOI - testscript:2:3: error: description inside 'if' - EOE - - : colon-trailing - : - $* <>EOE != 0 - if - cmd : foo - end - EOI - testscript:2:3: error: description inside 'if' - EOE - - : eos - : - $* <>EOE != 0 - if - EOI - testscript:2:1: error: expected closing 'end' - EOE - - : scope - : - $* <>EOE != 0 - if - cmd - { - } - end - EOI - testscript:3:3: error: expected closing 'end' - EOE - - : setup - : - $* <>EOE != 0 - if - +cmd - end - EOI - testscript:2:3: error: setup command inside 'if' - EOE - - : tdown - : - $* <>EOE != 0 - if - -cmd - end - EOI - testscript:2:3: error: teardown command inside 'if' - EOE -} - -: line-index -: -$* -l <>EOO -if false - cmd - if true - cmd - end - cmd -elif false - cmd -else - cmd -end -EOI -? false # 1 -? false # 6 -cmd # 8 -EOO - -: var -: -$* <>EOO -if true - x = foo -else - x = bar -end; -cmd $x -EOI -? true -cmd foo -EOO - -: leading-and-trailing-description -: -$* <>EOE != 0 -: foo -if true - cmd -end : bar -EOI -testscript:4:1: error: both leading and trailing descriptions -EOE diff --git a/unit-tests/test/script/parser/command-if.testscript b/unit-tests/test/script/parser/command-if.testscript new file mode 100644 index 0000000..264c522 --- /dev/null +++ b/unit-tests/test/script/parser/command-if.testscript @@ -0,0 +1,548 @@ +# file : unit-tests/test/script/parser/command-if.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: if +: +{ + : true + : + $* <>EOO + if true foo + cmd1 + cmd2 + end + EOI + ? true foo + cmd1 + cmd2 + EOO + + : false + : + $* <>EOO + if false foo + cmd1 + cmd2 + end + EOI + ? false foo + EOO + + : not-true + : + $* <>EOO + if! true foo + cmd1 + cmd2 + end + EOI + ? true foo + EOO + + : not-false + : + $* <>EOO + if! false foo + cmd1 + cmd2 + end + EOI + ? false foo + cmd1 + cmd2 + EOO + + : without-command + : + $* <>EOE != 0 + if + cmd + end + EOI + testscript:1:3: error: missing program + EOE + + : after-semi + : + $* -s <>EOO + cmd1; + if true + cmd2 + end + EOI + { + { + cmd1 + ? true + cmd2 + } + } + EOO + + : setup + : + $* -s <>EOO + +if true + cmd + end + EOI + { + ? true + +cmd + } + EOO + + : tdown + : + $* -s <>EOO + -if true + cmd + end + EOI + { + ? true + -cmd + } + EOO +} + +: elif +: +{ + : true + : + $* <>EOO + if false + cmd1 + cmd2 + elif true + cmd3 + cmd4 + end + EOI + ? false + ? true + cmd3 + cmd4 + EOO + + : false + : + $* <>EOO + if false + cmd1 + cmd2 + elif false + cmd3 + cmd4 + end + EOI + ? false + ? false + EOO + + : not-true + : + $* <>EOO + if false + cmd1 + cmd2 + elif! true + cmd3 + cmd4 + end + EOI + ? false + ? true + EOO + + : not-false + : + $* <>EOO + if false + cmd1 + cmd2 + elif! false + cmd3 + cmd4 + end + EOI + ? false + ? false + cmd3 + cmd4 + EOO + + : without-if + : + $* <>EOE != 0 + cmd + elif true + cmd + end + EOI + testscript:2:1: error: 'elif' without preceding 'if' + EOE + + : not-without-if + : + $* <>EOE != 0 + cmd + elif! true + cmd + end + EOI + testscript:2:1: error: 'elif!' without preceding 'if' + EOE + + : after-else + : + $* <>EOE != 0 + if false + cmd + else + cmd + elif true + cmd + end + EOI + testscript:5:1: error: 'elif' after 'else' + EOE +} + +: else +: +{ + : true + : + $* <>EOO + if false + cmd1 + cmd2 + else + cmd3 + cmd4 + end + EOI + ? false + cmd3 + cmd4 + EOO + + : false + : + $* <>EOO + if true + cmd1 + cmd2 + else + cmd3 + cmd4 + end + EOI + ? true + cmd1 + cmd2 + EOO + + : chain + : + $* <>EOO + if false + cmd + cmd + elif false + cmd + cmd + elif false + cmd + cmd + elif true + cmd1 + cmd2 + elif false + cmd + cmd + else + cmd + cmd + end + EOI + ? false + ? false + ? false + ? true + cmd1 + cmd2 + EOO + + : command-after + : + $* <>EOE != 0 + if true + cmd + else cmd + cmd + end + EOI + testscript:3:6: error: expected newline instead of 'cmd' + EOE + + : without-if + : + $* <>EOE != 0 + cmd + else + cmd + end + EOI + testscript:2:1: error: 'else' without preceding 'if' + EOE + + : after-else + : + $* <>EOE != 0 + if false + cmd + else + cmd + else + cmd + end + EOI + testscript:5:1: error: 'else' after 'else' + EOE +} + +: end +{ + : without-if + : + $* <>EOE != 0 + cmd + end + EOI + testscript:2:1: error: 'end' without preceding 'if' + EOE + + : before + { + : semi + : + $* -s <>EOO + if true + cmd1 + end; + cmd2 + EOI + { + { + ? true + cmd1 + cmd2 + } + } + EOO + + : command + : + $* <>EOE != 0 + if true + cmd + end cmd + EOI + testscript:3:5: error: expected newline instead of 'cmd' + EOE + + : colon + : + $* -s <>EOO + if true + cmd1 + cmd2 + end : test + EOI + { + : id:test + { + ? true + cmd1 + cmd2 + } + } + EOO + } +} + +: nested +: +{ + : take + : + $* <>EOO + if true + cmd1 + if false + cmd + elif false + if true + cmd + end + else + cmd2 + end + cmd3 + end + EOI + ? true + cmd1 + ? false + ? false + cmd2 + cmd3 + EOO + + : skip + : + $* <>EOO + if false + cmd1 + if false + cmd + elif false + if true + cmd + end + else + cmd2 + end + cmd3 + else + cmd + end + EOI + ? false + cmd + EOO +} + +: contained +{ + : semi + : + $* <>EOE != 0 + if + cmd; + cmd + end + EOI + testscript:2:3: error: ';' inside 'if' + EOE + + : colon-leading + : + $* <>EOE != 0 + if + : foo + cmd + end + EOI + testscript:2:3: error: description inside 'if' + EOE + + : colon-trailing + : + $* <>EOE != 0 + if + cmd : foo + end + EOI + testscript:2:3: error: description inside 'if' + EOE + + : eos + : + $* <>EOE != 0 + if + EOI + testscript:2:1: error: expected closing 'end' + EOE + + : scope + : + $* <>EOE != 0 + if + cmd + { + } + end + EOI + testscript:3:3: error: expected closing 'end' + EOE + + : setup + : + $* <>EOE != 0 + if + +cmd + end + EOI + testscript:2:3: error: setup command inside 'if' + EOE + + : tdown + : + $* <>EOE != 0 + if + -cmd + end + EOI + testscript:2:3: error: teardown command inside 'if' + EOE +} + +: line-index +: +$* -l <>EOO +if false + cmd + if true + cmd + end + cmd +elif false + cmd +else + cmd +end +EOI +? false # 1 +? false # 6 +cmd # 8 +EOO + +: var +: +$* <>EOO +if true + x = foo +else + x = bar +end; +cmd $x +EOI +? true +cmd foo +EOO + +: leading-and-trailing-description +: +$* <>EOE != 0 +: foo +if true + cmd +end : bar +EOI +testscript:4:1: error: both leading and trailing descriptions +EOE diff --git a/unit-tests/test/script/parser/command-re-parse.test b/unit-tests/test/script/parser/command-re-parse.test deleted file mode 100644 index a6ef6d3..0000000 --- a/unit-tests/test/script/parser/command-re-parse.test +++ /dev/null @@ -1,12 +0,0 @@ -# file : unit-tests/test/script/parser/command-re-parse.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: double-quote -: -$* <>EOO -x = cmd \">-\" "'<-'" -$x -EOI -cmd '>-' '<-' -EOO diff --git a/unit-tests/test/script/parser/command-re-parse.testscript b/unit-tests/test/script/parser/command-re-parse.testscript new file mode 100644 index 0000000..b137b0e --- /dev/null +++ b/unit-tests/test/script/parser/command-re-parse.testscript @@ -0,0 +1,12 @@ +# file : unit-tests/test/script/parser/command-re-parse.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: double-quote +: +$* <>EOO +x = cmd \">-\" "'<-'" +$x +EOI +cmd '>-' '<-' +EOO diff --git a/unit-tests/test/script/parser/description.test b/unit-tests/test/script/parser/description.test deleted file mode 100644 index e651a4a..0000000 --- a/unit-tests/test/script/parser/description.test +++ /dev/null @@ -1,486 +0,0 @@ -# file : unit-tests/test/script/parser/description.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: id -: -{ - : lead - : - $* <>EOO - : foo - cmd - EOI - : id:foo - cmd - EOO - - : trail - : - $* <>EOO - cmd : foo - EOI - : id:foo - cmd - EOO - - : dup - : Id uniqueness - : - { - : test - : - { - : test - : - $* <>EOE != 0 - : foo - cmd - : foo - cmd - EOI - testscript:3:1: error: duplicate id foo - testscript:1:1: info: previously used here - EOE - - : group - : - $* <>EOE != 0 - : foo - cmd - : foo - { - cmd - cmd - } - EOI - testscript:3:1: error: duplicate id foo - testscript:1:1: info: previously used here - EOE - - : derived - : - $* <>EOE != 0 - : 3 - cmd - cmd - EOI - testscript:3:1: error: duplicate id 3 - testscript:1:1: info: previously used here - EOE - } - - : group - : - { - : test - : - $* <>EOE != 0 - : foo - { - cmd - cmd - } - : foo - cmd - EOI - testscript:6:1: error: duplicate id foo - testscript:1:1: info: previously used here - EOE - - : group - : - $* <>EOE != 0 - : foo - { - cmd - cmd - } - : foo - { - cmd - cmd - } - EOI - testscript:6:1: error: duplicate id foo - testscript:1:1: info: previously used here - EOE - - : derived - : - $* <>EOE != 0 - : 3 - cmd - { - cmd - cmd - } - EOI - testscript:3:1: error: duplicate id 3 - testscript:1:1: info: previously used here - EOE - } - } -} - -: summary -{ - : lead - : - $* <>EOO - : foo bar - cmd - EOI - : sm:foo bar - cmd - EOO - - : trail - : - $* <>EOO - cmd: foo bar - EOI - : sm:foo bar - cmd - EOO - - : id - : - $* <>EOO - : foo-bar - : foo bar - cmd - EOI - : id:foo-bar - : sm:foo bar - cmd - EOO -} - -: details -{ - : id - : - $* <>EOO - : foo-bar - : - : foo bar - : bar baz - cmd - EOI - : id:foo-bar - : - : foo bar - : bar baz - cmd - EOO - - : summary - : - { - : only - : - $* <>EOO - : foo bar - : - : foo bar - : bar baz - cmd - EOI - : sm:foo bar - : - : foo bar - : bar baz - cmd - EOO - - : assumed - : - $* <>EOO - : foo bar - : bar baz - cmd - EOI - : foo bar - : bar baz - cmd - EOO - - : id - : - $* <>EOO - : foo-bar - : foo bar - : - : foo bar - : bar baz - cmd - EOI - : id:foo-bar - : sm:foo bar - : - : foo bar - : bar baz - cmd - EOO - - : id-assumed - : - $* <>EOO - : foo-bar - : bar baz - : baz fox - cmd - EOI - : foo-bar - : bar baz - : baz fox - cmd - EOO - } -} - -: legal -: -: Legal places for description. -: -{ - : var - : - $* <>EOO - : foo bar - x = y; - cmd $x - EOI - : sm:foo bar - cmd y - EOO -} - -: illegal -: -: Illegal places for description. -: -{ - : eof - : - $* <": foo" 2>>EOE != 0 - testscript:2:1: error: description before - EOE - - : rcbrace - : - $* <>EOE != 0 - { - cmd - : foo - } - EOI - testscript:4:1: error: description before '}' - EOE - - : setup - : - $* <>EOE != 0 - : foo - +cmd - EOI - testscript:2:1: error: description before setup command - EOE - - : tdown - : - $* <>EOE != 0 - : foo - -cmd - EOI - testscript:2:1: error: description before teardown command - EOE - - : var - : - $* <>EOE != 0 - : foo - x = y - EOI - testscript:2:1: error: description before setup/teardown variable - EOE - - : var-if - : - $* <>EOE != 0 - : foo - if true - x = y - end - EOI - testscript:2:1: error: description before/after setup/teardown variable-if - EOE - - : var-if-after - : - $* <>EOE != 0 - if true - x = y - end : foo - EOI - testscript:1:1: error: description before/after setup/teardown variable-if - EOE - - : test - : - $* <>EOE != 0 - cmd1; - : foo - cmd2 - EOI - testscript:2:1: error: description inside test - EOE -} - -: test-scope -: -: Interaction with test scope merging. -: -{ - : both - : - : No merge since both have description. - : - $* -s -i <>EOO - : foo - { - : bar - cmd - } - EOI - { - : id:foo - { # foo - : id:bar - { # foo/bar - cmd - } - } - } - EOO - - : test - : - : No merge since test has description. - : - $* -s -i <>EOO - { - : foo-bar - : foo bar - cmd - } - EOI - { - { # 1 - : id:foo-bar - : sm:foo bar - { # 1/foo-bar - cmd - } - } - } - EOO - - : group - : - $* -s -i <>EOO - : foo-bar - : foo bar - { - cmd - } - EOI - { - : id:foo-bar - : sm:foo bar - { # foo-bar - cmd - } - } - EOO -} - -: blanks -: -$* <>EOO -: -: -: foo bar -: bar baz -: -: baz fox -: -: -cmd -EOI -: foo bar -: bar baz -: -: baz fox -cmd -EOO - -: strip -: -$* <>EOO -: foo-bar -: bar baz -: -: baz fox -: fox biz -:biz buz -: -cmd -EOI -: id:foo-bar -: sm:bar baz -: -: baz fox -: fox biz -: biz buz -cmd -EOO - -: trail-compound -: -$* <>EOO -cmd1; -cmd2: foo -EOI -: id:foo -cmd1 -cmd2 -EOO - -: empty -: -$* <>EOE != 0 -: -: -cmd -EOI -testscript:1:1: error: empty description -EOE - -: trail-empty -: -$* <>EOE != 0 -cmd: -EOI -testscript:1:4: error: empty description -EOE - -: both -: -$* <>EOE != 0 -: foo -cmd : bar -EOI -testscript:2:1: error: both leading and trailing descriptions -EOE diff --git a/unit-tests/test/script/parser/description.testscript b/unit-tests/test/script/parser/description.testscript new file mode 100644 index 0000000..1945cd2 --- /dev/null +++ b/unit-tests/test/script/parser/description.testscript @@ -0,0 +1,486 @@ +# file : unit-tests/test/script/parser/description.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: id +: +{ + : lead + : + $* <>EOO + : foo + cmd + EOI + : id:foo + cmd + EOO + + : trail + : + $* <>EOO + cmd : foo + EOI + : id:foo + cmd + EOO + + : dup + : Id uniqueness + : + { + : test + : + { + : test + : + $* <>EOE != 0 + : foo + cmd + : foo + cmd + EOI + testscript:3:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : group + : + $* <>EOE != 0 + : foo + cmd + : foo + { + cmd + cmd + } + EOI + testscript:3:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : derived + : + $* <>EOE != 0 + : 3 + cmd + cmd + EOI + testscript:3:1: error: duplicate id 3 + testscript:1:1: info: previously used here + EOE + } + + : group + : + { + : test + : + $* <>EOE != 0 + : foo + { + cmd + cmd + } + : foo + cmd + EOI + testscript:6:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : group + : + $* <>EOE != 0 + : foo + { + cmd + cmd + } + : foo + { + cmd + cmd + } + EOI + testscript:6:1: error: duplicate id foo + testscript:1:1: info: previously used here + EOE + + : derived + : + $* <>EOE != 0 + : 3 + cmd + { + cmd + cmd + } + EOI + testscript:3:1: error: duplicate id 3 + testscript:1:1: info: previously used here + EOE + } + } +} + +: summary +{ + : lead + : + $* <>EOO + : foo bar + cmd + EOI + : sm:foo bar + cmd + EOO + + : trail + : + $* <>EOO + cmd: foo bar + EOI + : sm:foo bar + cmd + EOO + + : id + : + $* <>EOO + : foo-bar + : foo bar + cmd + EOI + : id:foo-bar + : sm:foo bar + cmd + EOO +} + +: details +{ + : id + : + $* <>EOO + : foo-bar + : + : foo bar + : bar baz + cmd + EOI + : id:foo-bar + : + : foo bar + : bar baz + cmd + EOO + + : summary + : + { + : only + : + $* <>EOO + : foo bar + : + : foo bar + : bar baz + cmd + EOI + : sm:foo bar + : + : foo bar + : bar baz + cmd + EOO + + : assumed + : + $* <>EOO + : foo bar + : bar baz + cmd + EOI + : foo bar + : bar baz + cmd + EOO + + : id + : + $* <>EOO + : foo-bar + : foo bar + : + : foo bar + : bar baz + cmd + EOI + : id:foo-bar + : sm:foo bar + : + : foo bar + : bar baz + cmd + EOO + + : id-assumed + : + $* <>EOO + : foo-bar + : bar baz + : baz fox + cmd + EOI + : foo-bar + : bar baz + : baz fox + cmd + EOO + } +} + +: legal +: +: Legal places for description. +: +{ + : var + : + $* <>EOO + : foo bar + x = y; + cmd $x + EOI + : sm:foo bar + cmd y + EOO +} + +: illegal +: +: Illegal places for description. +: +{ + : eof + : + $* <": foo" 2>>EOE != 0 + testscript:2:1: error: description before + EOE + + : rcbrace + : + $* <>EOE != 0 + { + cmd + : foo + } + EOI + testscript:4:1: error: description before '}' + EOE + + : setup + : + $* <>EOE != 0 + : foo + +cmd + EOI + testscript:2:1: error: description before setup command + EOE + + : tdown + : + $* <>EOE != 0 + : foo + -cmd + EOI + testscript:2:1: error: description before teardown command + EOE + + : var + : + $* <>EOE != 0 + : foo + x = y + EOI + testscript:2:1: error: description before setup/teardown variable + EOE + + : var-if + : + $* <>EOE != 0 + : foo + if true + x = y + end + EOI + testscript:2:1: error: description before/after setup/teardown variable-if + EOE + + : var-if-after + : + $* <>EOE != 0 + if true + x = y + end : foo + EOI + testscript:1:1: error: description before/after setup/teardown variable-if + EOE + + : test + : + $* <>EOE != 0 + cmd1; + : foo + cmd2 + EOI + testscript:2:1: error: description inside test + EOE +} + +: test-scope +: +: Interaction with test scope merging. +: +{ + : both + : + : No merge since both have description. + : + $* -s -i <>EOO + : foo + { + : bar + cmd + } + EOI + { + : id:foo + { # foo + : id:bar + { # foo/bar + cmd + } + } + } + EOO + + : test + : + : No merge since test has description. + : + $* -s -i <>EOO + { + : foo-bar + : foo bar + cmd + } + EOI + { + { # 1 + : id:foo-bar + : sm:foo bar + { # 1/foo-bar + cmd + } + } + } + EOO + + : group + : + $* -s -i <>EOO + : foo-bar + : foo bar + { + cmd + } + EOI + { + : id:foo-bar + : sm:foo bar + { # foo-bar + cmd + } + } + EOO +} + +: blanks +: +$* <>EOO +: +: +: foo bar +: bar baz +: +: baz fox +: +: +cmd +EOI +: foo bar +: bar baz +: +: baz fox +cmd +EOO + +: strip +: +$* <>EOO +: foo-bar +: bar baz +: +: baz fox +: fox biz +:biz buz +: +cmd +EOI +: id:foo-bar +: sm:bar baz +: +: baz fox +: fox biz +: biz buz +cmd +EOO + +: trail-compound +: +$* <>EOO +cmd1; +cmd2: foo +EOI +: id:foo +cmd1 +cmd2 +EOO + +: empty +: +$* <>EOE != 0 +: +: +cmd +EOI +testscript:1:1: error: empty description +EOE + +: trail-empty +: +$* <>EOE != 0 +cmd: +EOI +testscript:1:4: error: empty description +EOE + +: both +: +$* <>EOE != 0 +: foo +cmd : bar +EOI +testscript:2:1: error: both leading and trailing descriptions +EOE diff --git a/unit-tests/test/script/parser/directive.test b/unit-tests/test/script/parser/directive.test deleted file mode 100644 index 66bae0d..0000000 --- a/unit-tests/test/script/parser/directive.test +++ /dev/null @@ -1,74 +0,0 @@ -# file : unit-tests/test/script/parser/directive.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: not-directive -: -$* <>EOO -x = x -".include" foo.test -\.include foo.test -EOI -.include foo.test -.include foo.test -EOO - -: expected-name -: -$* <>EOE != 0 -.$ -EOI -testscript:1:2: error: expected directive name instead of '$' -EOE - -: unknown-name -: -$* <>EOE != 0 -.bogus -EOI -testscript:1:2: error: unknown directive 'bogus' -EOE - -: separated -: -touch foo.test; -$* <="foo-$(build.verson.project).test"; -cmd -EOI -$* <>EOO -.include "foo-$(build.verson.project).test" -EOI -cmd -EOO - -: after-semi -: -$* <>EOE != 0 -cmd; -.include foo.test -EOI -testscript:2:1: error: directive after ';' -EOE - -: semi-after -: -$* <>EOE != 0 -.include foo.test; -cmd -EOI -testscript:1:18: error: ';' after directive -EOE diff --git a/unit-tests/test/script/parser/directive.testscript b/unit-tests/test/script/parser/directive.testscript new file mode 100644 index 0000000..82fc471 --- /dev/null +++ b/unit-tests/test/script/parser/directive.testscript @@ -0,0 +1,74 @@ +# file : unit-tests/test/script/parser/directive.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: not-directive +: +$* <>EOO +x = x +".include" foo.testscript +\.include foo.testscript +EOI +.include foo.testscript +.include foo.testscript +EOO + +: expected-name +: +$* <>EOE != 0 +.$ +EOI +testscript:1:2: error: expected directive name instead of '$' +EOE + +: unknown-name +: +$* <>EOE != 0 +.bogus +EOI +testscript:1:2: error: unknown directive 'bogus' +EOE + +: separated +: +touch foo.testscript; +$* <="foo-$(build.verson.project).testscript"; +cmd +EOI +$* <>EOO +.include "foo-$(build.verson.project).testscript" +EOI +cmd +EOO + +: after-semi +: +$* <>EOE != 0 +cmd; +.include foo.testscript +EOI +testscript:2:1: error: directive after ';' +EOE + +: semi-after +: +$* <>EOE != 0 +.include foo.testscript; +cmd +EOI +testscript:1:24: error: ';' after directive +EOE diff --git a/unit-tests/test/script/parser/exit.test b/unit-tests/test/script/parser/exit.test deleted file mode 100644 index 3c796f1..0000000 --- a/unit-tests/test/script/parser/exit.test +++ /dev/null @@ -1,27 +0,0 @@ -# file : unit-tests/test/script/parser/exit.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: eq -: -$* <>EOO -cmd == 1 -EOI -cmd == 1 -EOO - -: ne -: -$* <>EOO -cmd!=1 -EOI -cmd != 1 -EOO - -: end -: -$* <>EOE != 0 -cmd != 1 <"foo" -EOI -testscript:1:10: error: unexpected '<' after command exit status -EOE diff --git a/unit-tests/test/script/parser/exit.testscript b/unit-tests/test/script/parser/exit.testscript new file mode 100644 index 0000000..af3707d --- /dev/null +++ b/unit-tests/test/script/parser/exit.testscript @@ -0,0 +1,27 @@ +# file : unit-tests/test/script/parser/exit.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: eq +: +$* <>EOO +cmd == 1 +EOI +cmd == 1 +EOO + +: ne +: +$* <>EOO +cmd!=1 +EOI +cmd != 1 +EOO + +: end +: +$* <>EOE != 0 +cmd != 1 <"foo" +EOI +testscript:1:10: error: unexpected '<' after command exit status +EOE diff --git a/unit-tests/test/script/parser/expansion.test b/unit-tests/test/script/parser/expansion.test deleted file mode 100644 index e161c2c..0000000 --- a/unit-tests/test/script/parser/expansion.test +++ /dev/null @@ -1,36 +0,0 @@ -# file : unit-tests/test/script/parser/expansion.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: quote -: -: Make sure everything expanded as strings. -: -$* <>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 - -: unterm-quoted-seq -: -$* <>EOE != 0 -x = "'a bc" -cmd xy$x -EOI -:1:8: error: unterminated single-quoted sequence - testscript:2:5: info: while parsing string 'xy'a bc' -EOE - -: invalid-redirect -: -$* <>EOE != 0 -x = "1>&a" -cmd $x -EOI -:1:4: error: stdout merge redirect file descriptor must be 2 - testscript:2:5: info: while parsing string '1>&a' -EOE diff --git a/unit-tests/test/script/parser/expansion.testscript b/unit-tests/test/script/parser/expansion.testscript new file mode 100644 index 0000000..710d7a1 --- /dev/null +++ b/unit-tests/test/script/parser/expansion.testscript @@ -0,0 +1,36 @@ +# file : unit-tests/test/script/parser/expansion.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: quote +: +: Make sure everything expanded as strings. +: +$* <>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 + +: unterm-quoted-seq +: +$* <>EOE != 0 +x = "'a bc" +cmd xy$x +EOI +:1:8: error: unterminated single-quoted sequence + testscript:2:5: info: while parsing string 'xy'a bc' +EOE + +: invalid-redirect +: +$* <>EOE != 0 +x = "1>&a" +cmd $x +EOI +:1:4: error: stdout merge redirect file descriptor must be 2 + testscript:2:5: info: while parsing string '1>&a' +EOE diff --git a/unit-tests/test/script/parser/here-document.test b/unit-tests/test/script/parser/here-document.test deleted file mode 100644 index 9aebed4..0000000 --- a/unit-tests/test/script/parser/here-document.test +++ /dev/null @@ -1,213 +0,0 @@ -# file : unit-tests/test/script/parser/here-document.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: end-marker -: -{ - : missing-newline - : - $* <'cmd <<' 2>>EOE != 0 - testscript:1:7: error: expected here-document end marker - EOE - - : missing-exit - : - $* <'cmd << != 0' 2>>EOE != 0 - testscript:1:8: error: expected here-document end marker - EOE - - : missing-empty - : - $* <'cmd <<""' 2>>EOE != 0 - testscript:1:7: error: expected here-document end marker - EOE - - : unseparated-expansion - : - $* <'cmd <>EOE != 0 - testscript:1:10: error: here-document end marker must be literal - EOE - - : quoted-single-partial - : - $* <"cmd <>EOE != 0 - testscript:1:7: error: partially-quoted here-document end marker - EOE - - : quoted-double-partial - : - $* <'cmd <<"FO"O' 2>>EOE != 0 - testscript:1:7: error: partially-quoted here-document end marker - EOE - - : quoted-mixed - : - $* <"cmd <<\"FO\"'O'" 2>>EOE != 0 - testscript:1:7: error: partially-quoted here-document end marker - EOE - - : unseparated - : - $* <>EOO - cmd <>EOO - cmd <<'EOF' - foo - EOF - EOI - cmd <>EOO - cmd <<"EOF" - foo - EOF - EOI - cmd <>EOO - cmd <>EOO - cmd <>EOO - cmd <>EOO - x = foo bar - cmd <<"EOF" - $x - EOF - EOI - cmd <>EOO - x = foo - cmd <<"EOF" - $x bar $x - EOF - EOI - cmd <>EOE != 0 - cmd <>EOO -cmd <>EOO -cmd <<"EOF" -'single' -"double" -b'o't"h" -('single' "double") -EOF -EOI -cmd <>EOE != 0 + testscript:1:7: error: expected here-document end marker + EOE + + : missing-exit + : + $* <'cmd << != 0' 2>>EOE != 0 + testscript:1:8: error: expected here-document end marker + EOE + + : missing-empty + : + $* <'cmd <<""' 2>>EOE != 0 + testscript:1:7: error: expected here-document end marker + EOE + + : unseparated-expansion + : + $* <'cmd <>EOE != 0 + testscript:1:10: error: here-document end marker must be literal + EOE + + : quoted-single-partial + : + $* <"cmd <>EOE != 0 + testscript:1:7: error: partially-quoted here-document end marker + EOE + + : quoted-double-partial + : + $* <'cmd <<"FO"O' 2>>EOE != 0 + testscript:1:7: error: partially-quoted here-document end marker + EOE + + : quoted-mixed + : + $* <"cmd <<\"FO\"'O'" 2>>EOE != 0 + testscript:1:7: error: partially-quoted here-document end marker + EOE + + : unseparated + : + $* <>EOO + cmd <>EOO + cmd <<'EOF' + foo + EOF + EOI + cmd <>EOO + cmd <<"EOF" + foo + EOF + EOI + cmd <>EOO + cmd <>EOO + cmd <>EOO + cmd <>EOO + x = foo bar + cmd <<"EOF" + $x + EOF + EOI + cmd <>EOO + x = foo + cmd <<"EOF" + $x bar $x + EOF + EOI + cmd <>EOE != 0 + cmd <>EOO +cmd <>EOO +cmd <<"EOF" +'single' +"double" +b'o't"h" +('single' "double") +EOF +EOI +cmd <>EOO -cmd <"" -EOI -cmd <'' -EOO - -: empty-nn -: -$* <>EOO -cmd <:"" -EOI -cmd <:'' -EOO diff --git a/unit-tests/test/script/parser/here-string.testscript b/unit-tests/test/script/parser/here-string.testscript new file mode 100644 index 0000000..a9e42c0 --- /dev/null +++ b/unit-tests/test/script/parser/here-string.testscript @@ -0,0 +1,19 @@ +# file : unit-tests/test/script/parser/here-string.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: empty +: +$* <>EOO +cmd <"" +EOI +cmd <'' +EOO + +: empty-nn +: +$* <>EOO +cmd <:"" +EOI +cmd <:'' +EOO diff --git a/unit-tests/test/script/parser/include.test b/unit-tests/test/script/parser/include.test deleted file mode 100644 index 99e17de..0000000 --- a/unit-tests/test/script/parser/include.test +++ /dev/null @@ -1,104 +0,0 @@ -# file : unit-tests/test/script/parser/include.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: none -: -$* <=foo.test; -$* <>EOO -.include foo.test -EOI -cmd -EOO - -: multiple -: -cat <"cmd foo" >=foo.test; -cat <"cmd bar" >=bar.test; -$* <>EOO -.include foo.test bar.test -EOI -cmd foo -cmd bar -EOO - -: once -: -cat <"cmd" >=foo.test; -$* <>EOO -.include foo.test -x -.include --once foo.test -.include --once bar/../foo.test -y -.include ../once/foo.test -EOI -cmd -x -y -cmd -EOO - -: group-id -: -cat <=foo.test; -{ - x = b -} -EOI -$* -s -i <>EOO -x = a -.include foo.test -EOI -{ - { # 2-foo-1 - } -} -EOO - -: test-id -: -cat <=foo.test; -cmd -EOI -$* -s -i <>EOO -x = a -.include foo.test -EOI -{ - { # 2-foo-1 - cmd - } -} -EOO - -: invalid-path -: -$* <>EOE != 0 -.include "" -EOI -testscript:1:2: error: invalid testscript include path '' -EOE - -: unable-open -: -$* <>~/EOE/ != 0 -.include foo.test -EOI -/testscript:1:2: error: unable to read testscript foo.test: .+/ -EOE diff --git a/unit-tests/test/script/parser/include.testscript b/unit-tests/test/script/parser/include.testscript new file mode 100644 index 0000000..5e31f0d --- /dev/null +++ b/unit-tests/test/script/parser/include.testscript @@ -0,0 +1,104 @@ +# file : unit-tests/test/script/parser/include.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: none +: +$* <=foo.testscript; +$* <>EOO +.include foo.testscript +EOI +cmd +EOO + +: multiple +: +cat <"cmd foo" >=foo.testscript; +cat <"cmd bar" >=bar.testscript; +$* <>EOO +.include foo.testscript bar.testscript +EOI +cmd foo +cmd bar +EOO + +: once +: +cat <"cmd" >=foo.testscript; +$* <>EOO +.include foo.testscript +x +.include --once foo.testscript +.include --once bar/../foo.testscript +y +.include ../once/foo.testscript +EOI +cmd +x +y +cmd +EOO + +: group-id +: +cat <=foo.testscript; +{ + x = b +} +EOI +$* -s -i <>EOO +x = a +.include foo.testscript +EOI +{ + { # 2-foo-1 + } +} +EOO + +: test-id +: +cat <=foo.testscript; +cmd +EOI +$* -s -i <>EOO +x = a +.include foo.testscript +EOI +{ + { # 2-foo-1 + cmd + } +} +EOO + +: invalid-path +: +$* <>EOE != 0 +.include "" +EOI +testscript:1:2: error: invalid testscript include path '' +EOE + +: unable-open +: +$* <>~/EOE/ != 0 +.include foo.testscript +EOI +/testscript:1:2: error: unable to read testscript foo.testscript: .+/ +EOE diff --git a/unit-tests/test/script/parser/pipe-expr.test b/unit-tests/test/script/parser/pipe-expr.test deleted file mode 100644 index 3b06da3..0000000 --- a/unit-tests/test/script/parser/pipe-expr.test +++ /dev/null @@ -1,133 +0,0 @@ -# file : unit-tests/test/script/parser/pipe-expr.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: pipe -: -$* <>EOO -cmd1 | cmd2|cmd3 -EOI -cmd1 | cmd2 | cmd3 -EOO - -: log -: -$* <>EOO -cmd1 || cmd2&&cmd3 -EOI -cmd1 || cmd2 && cmd3 -EOO - -: pipe-log -: -$* <>EOO -cmd1 | cmd2 && cmd3 | cmd4 -EOI -cmd1 | cmd2 && cmd3 | cmd4 -EOO - -: exit -: -$* <>EOO -cmd1|cmd2==1&&cmd3!=0|cmd4 -EOI -cmd1 | cmd2 == 1 && cmd3 != 0 | cmd4 -EOO - -: here-doc -: -$* <>EOO -cmd1 <>EOO2 && cmd3 <&1 | cmd4 2>>EOE4 >>EOO4 -input -one -EOI1 -ouput -two -EOO2 -input -three -EOI3 -error -four -EOE4 -output -four -EOO4 -EOI -cmd1 <>EOO2 && cmd3 <&1 | cmd4 >>EOO4 2>>EOE4 -input -one -EOI1 -ouput -two -EOO2 -input -three -EOI3 -output -four -EOO4 -error -four -EOE4 -EOO - -: leading -: -$* <>EOE != 0 -| cmd -EOI -testscript:1:1: error: missing program -EOE - -: trailing -: -$* <>EOE != 0 -cmd && -EOI -testscript:1:7: error: missing program -EOE - -: redirected -: -{ - : input - : - { - : first - : - $* <>EOO - cmd1 >EOE != 0 - cmd1 | cmd2 >EOO - cmd1 | cmd2 >foo - EOI - cmd1 | cmd2 >foo - EOO - - : non-last - : - $* <>EOE != 0 - cmd1 >foo | cmd2 - EOI - testscript:1:11: error: stdout is both redirected and piped - EOE - } -} diff --git a/unit-tests/test/script/parser/pipe-expr.testscript b/unit-tests/test/script/parser/pipe-expr.testscript new file mode 100644 index 0000000..7086181 --- /dev/null +++ b/unit-tests/test/script/parser/pipe-expr.testscript @@ -0,0 +1,133 @@ +# file : unit-tests/test/script/parser/pipe-expr.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: pipe +: +$* <>EOO +cmd1 | cmd2|cmd3 +EOI +cmd1 | cmd2 | cmd3 +EOO + +: log +: +$* <>EOO +cmd1 || cmd2&&cmd3 +EOI +cmd1 || cmd2 && cmd3 +EOO + +: pipe-log +: +$* <>EOO +cmd1 | cmd2 && cmd3 | cmd4 +EOI +cmd1 | cmd2 && cmd3 | cmd4 +EOO + +: exit +: +$* <>EOO +cmd1|cmd2==1&&cmd3!=0|cmd4 +EOI +cmd1 | cmd2 == 1 && cmd3 != 0 | cmd4 +EOO + +: here-doc +: +$* <>EOO +cmd1 <>EOO2 && cmd3 <&1 | cmd4 2>>EOE4 >>EOO4 +input +one +EOI1 +ouput +two +EOO2 +input +three +EOI3 +error +four +EOE4 +output +four +EOO4 +EOI +cmd1 <>EOO2 && cmd3 <&1 | cmd4 >>EOO4 2>>EOE4 +input +one +EOI1 +ouput +two +EOO2 +input +three +EOI3 +output +four +EOO4 +error +four +EOE4 +EOO + +: leading +: +$* <>EOE != 0 +| cmd +EOI +testscript:1:1: error: missing program +EOE + +: trailing +: +$* <>EOE != 0 +cmd && +EOI +testscript:1:7: error: missing program +EOE + +: redirected +: +{ + : input + : + { + : first + : + $* <>EOO + cmd1 >EOE != 0 + cmd1 | cmd2 >EOO + cmd1 | cmd2 >foo + EOI + cmd1 | cmd2 >foo + EOO + + : non-last + : + $* <>EOE != 0 + cmd1 >foo | cmd2 + EOI + testscript:1:11: error: stdout is both redirected and piped + EOE + } +} diff --git a/unit-tests/test/script/parser/pre-parse.test b/unit-tests/test/script/parser/pre-parse.test deleted file mode 100644 index b1f4209..0000000 --- a/unit-tests/test/script/parser/pre-parse.test +++ /dev/null @@ -1,23 +0,0 @@ -# file : unit-tests/test/script/parser/pre-parse.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: attribute -: -{ - : pair - : - $* <>EOE != 0 - x = [foo=bar] - EOI - testscript:1:5: error: unknown value attribute foo=bar - EOE - - : pair-empty - : - $* <>EOE != 0 - x = [foo=] - EOI - testscript:1:5: error: unknown value attribute foo - EOE -} diff --git a/unit-tests/test/script/parser/pre-parse.testscript b/unit-tests/test/script/parser/pre-parse.testscript new file mode 100644 index 0000000..d37f972 --- /dev/null +++ b/unit-tests/test/script/parser/pre-parse.testscript @@ -0,0 +1,23 @@ +# file : unit-tests/test/script/parser/pre-parse.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: attribute +: +{ + : pair + : + $* <>EOE != 0 + x = [foo=bar] + EOI + testscript:1:5: error: unknown value attribute foo=bar + EOE + + : pair-empty + : + $* <>EOE != 0 + x = [foo=] + EOI + testscript:1:5: error: unknown value attribute foo + EOE +} diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test deleted file mode 100644 index 766d6cc..0000000 --- a/unit-tests/test/script/parser/redirect.test +++ /dev/null @@ -1,356 +0,0 @@ -# file : unit-tests/test/script/parser/redirect.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# @@ Add tests for redirects other than trace, here-*, file and merge. -# @@ Does it make sense to split into separate files - one per redirect type? -# - -: trace -: -{ - $* <'cmd >!' >'cmd >!' : out - $* <'cmd 2>!' >'cmd 2>!' : err -} - -: str -: -{ - : literal - : - { - : portable-path - : - $* <>EOO - cmd /bar 2>/baz - EOI - cmd /bar 2>/baz - EOO - } - - : regex - : - { - : portable-path - : - $* <>EOO - cmd >/~%foo% 2>/~%bar% - EOI - cmd >/~%foo% 2>/~%bar% - EOO - } -} - -: doc -: -{ - : literal - : - { - : portable-path - : - $* <>EOO - cmd </EOO_ 2>/EOE_ - foo - EOI_ - bar - EOO_ - baz - EOE_ - EOI - cmd </EOO_ 2>/EOE_ - foo - EOI_ - bar - EOO_ - baz - EOE_ - EOO - - : sharing - : - { - : in-out - : - $* <>EOO - cmd <<:/EOF >>:/EOF - foo - EOF - EOI - cmd <<:/EOF >>:/EOF - foo - EOF - EOO - - : different - : - { - : modifiers - : - $* <>EOE != 0 - cmd <<:/EOF >>:EOF - foo - EOF - EOI - testscript:1:16: error: different modifiers for shared here-document 'EOF' - EOE - - : quoting - : - $* <>EOE != 0 - cmd <>"EOF" - foo - EOF - EOI - testscript:1:13: error: different quoting for shared here-document 'EOF' - EOE - } - } - } - - : regex - : - { - : portable-path - : - $* <>EOO - cmd >/~%EOF% 2>/~%EOE% - foo - EOF - bar - EOE - EOI - cmd >/~%EOF% 2>/~%EOE% - foo - EOF - bar - EOE - EOO - - : sharing - : - { - : in-out - : - $* <>EOO - cmd >>~/EOF/ 2>>~/EOF/ - foo - EOF - EOI - cmd >>~/EOF/ 2>>~/EOF/ - foo - EOF - EOO - - : different - : - { - : introducers - : - $* <>EOE != 0 - cmd >>~/EOF/ 2>>~%EOF% - foo - EOF - EOI - testscript:1:18: error: different introducers for shared here-document regex 'EOF' - EOE - - : flags - : - $* <>EOE != 0 - cmd >>~/EOF/ 2>>~/EOF/i - foo - EOF - EOI - testscript:1:18: error: different global flags for shared here-document regex 'EOF' - EOE - } - } - } -} - -: file -: -{ - : cmp - : - $* <>EOO - cmd 0<<>>b 2>>>c - EOI - cmd <<>>b 2>>>c - EOO - - : write - : - $* <>EOO - cmd 1>=b 2>+c - EOI - cmd >=b 2>+c - EOO - - : quote - : - $* <>EOO - cmd 0<<<"a f" 1>="b f" 2>+"c f" - EOI - cmd <<<'a f' >='b f' 2>+'c f' - EOO - - : in - : - { - : missed - : - $* <>EOE !=0 - cmd <<< - EOI - testscript:1:8: error: missing stdin file - EOE - - : empty - : - $* <>EOE !=0 - cmd <<<"" - EOI - testscript:1:8: error: empty stdin redirect path - EOE - } - - : out - : - { - : missed - : - $* <>EOE !=0 - cmd >= - EOI - testscript:1:7: error: missing stdout file - EOE - - : empty - : - $* <>EOE !=0 - cmd >="" - EOI - testscript:1:7: error: empty stdout redirect path - EOE - } - - : err - : - { - : missed - : - $* <>EOE !=0 - cmd 2>= - EOI - testscript:1:8: error: missing stderr file - EOE - - : empty - : - $* <>EOE !=0 - cmd 2>="" - EOI - testscript:1:8: error: empty stderr redirect path - EOE - } -} - -: merge -{ - : out - : - { - : err - : - $* <>EOO - cmd 1>&2 - EOI - cmd >&2 - EOO - - : no-mutual - : - $* <>EOO - cmd 1>&2 2>&1 2>a - EOI - cmd >&2 2>a - EOO - - : not-descriptor - : - $* <>EOE != 0 - cmd 1>&a - EOI - testscript:1:8: error: stdout merge redirect file descriptor must be 2 - EOE - - : self - : - $* <>EOE != 0 - cmd 1>&1 - EOI - testscript:1:8: error: stdout merge redirect file descriptor must be 2 - EOE - - : missed - : - $* <>EOE != 0 - cmd 1>& - EOI - testscript:1:8: error: missing stdout file descriptor - EOE - } - - : err - { - : out - : - $* <>EOO - cmd 2>&1 - EOI - cmd 2>&1 - EOO - - : no-mutual - : - $* <>EOO - cmd 1>&2 2>&1 >a - EOI - cmd >a 2>&1 - EOO - - : not-descriptor - : - $* <>EOE != 0 - cmd 2>&a - EOI - testscript:1:8: error: stderr merge redirect file descriptor must be 1 - EOE - - : self - : - $* <>EOE != 0 - cmd 2>&2 - EOI - testscript:1:8: error: stderr merge redirect file descriptor must be 1 - EOE - - : missed - : - $* <>EOE != 0 - cmd 2>& - EOI - testscript:1:8: error: missing stderr file descriptor - EOE - } - - : mutual - : - $* <>EOE != 0 - cmd 1>&2 2>&1 - EOI - testscript:1:14: error: stdout and stderr redirected to each other - EOE -} diff --git a/unit-tests/test/script/parser/redirect.testscript b/unit-tests/test/script/parser/redirect.testscript new file mode 100644 index 0000000..4001a3b --- /dev/null +++ b/unit-tests/test/script/parser/redirect.testscript @@ -0,0 +1,356 @@ +# file : unit-tests/test/script/parser/redirect.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# @@ Add tests for redirects other than trace, here-*, file and merge. +# @@ Does it make sense to split into separate files - one per redirect type? +# + +: trace +: +{ + $* <'cmd >!' >'cmd >!' : out + $* <'cmd 2>!' >'cmd 2>!' : err +} + +: str +: +{ + : literal + : + { + : portable-path + : + $* <>EOO + cmd /bar 2>/baz + EOI + cmd /bar 2>/baz + EOO + } + + : regex + : + { + : portable-path + : + $* <>EOO + cmd >/~%foo% 2>/~%bar% + EOI + cmd >/~%foo% 2>/~%bar% + EOO + } +} + +: doc +: +{ + : literal + : + { + : portable-path + : + $* <>EOO + cmd </EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOI + cmd </EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOO + + : sharing + : + { + : in-out + : + $* <>EOO + cmd <<:/EOF >>:/EOF + foo + EOF + EOI + cmd <<:/EOF >>:/EOF + foo + EOF + EOO + + : different + : + { + : modifiers + : + $* <>EOE != 0 + cmd <<:/EOF >>:EOF + foo + EOF + EOI + testscript:1:16: error: different modifiers for shared here-document 'EOF' + EOE + + : quoting + : + $* <>EOE != 0 + cmd <>"EOF" + foo + EOF + EOI + testscript:1:13: error: different quoting for shared here-document 'EOF' + EOE + } + } + } + + : regex + : + { + : portable-path + : + $* <>EOO + cmd >/~%EOF% 2>/~%EOE% + foo + EOF + bar + EOE + EOI + cmd >/~%EOF% 2>/~%EOE% + foo + EOF + bar + EOE + EOO + + : sharing + : + { + : in-out + : + $* <>EOO + cmd >>~/EOF/ 2>>~/EOF/ + foo + EOF + EOI + cmd >>~/EOF/ 2>>~/EOF/ + foo + EOF + EOO + + : different + : + { + : introducers + : + $* <>EOE != 0 + cmd >>~/EOF/ 2>>~%EOF% + foo + EOF + EOI + testscript:1:18: error: different introducers for shared here-document regex 'EOF' + EOE + + : flags + : + $* <>EOE != 0 + cmd >>~/EOF/ 2>>~/EOF/i + foo + EOF + EOI + testscript:1:18: error: different global flags for shared here-document regex 'EOF' + EOE + } + } + } +} + +: file +: +{ + : cmp + : + $* <>EOO + cmd 0<<>>b 2>>>c + EOI + cmd <<>>b 2>>>c + EOO + + : write + : + $* <>EOO + cmd 1>=b 2>+c + EOI + cmd >=b 2>+c + EOO + + : quote + : + $* <>EOO + cmd 0<<<"a f" 1>="b f" 2>+"c f" + EOI + cmd <<<'a f' >='b f' 2>+'c f' + EOO + + : in + : + { + : missed + : + $* <>EOE !=0 + cmd <<< + EOI + testscript:1:8: error: missing stdin file + EOE + + : empty + : + $* <>EOE !=0 + cmd <<<"" + EOI + testscript:1:8: error: empty stdin redirect path + EOE + } + + : out + : + { + : missed + : + $* <>EOE !=0 + cmd >= + EOI + testscript:1:7: error: missing stdout file + EOE + + : empty + : + $* <>EOE !=0 + cmd >="" + EOI + testscript:1:7: error: empty stdout redirect path + EOE + } + + : err + : + { + : missed + : + $* <>EOE !=0 + cmd 2>= + EOI + testscript:1:8: error: missing stderr file + EOE + + : empty + : + $* <>EOE !=0 + cmd 2>="" + EOI + testscript:1:8: error: empty stderr redirect path + EOE + } +} + +: merge +{ + : out + : + { + : err + : + $* <>EOO + cmd 1>&2 + EOI + cmd >&2 + EOO + + : no-mutual + : + $* <>EOO + cmd 1>&2 2>&1 2>a + EOI + cmd >&2 2>a + EOO + + : not-descriptor + : + $* <>EOE != 0 + cmd 1>&a + EOI + testscript:1:8: error: stdout merge redirect file descriptor must be 2 + EOE + + : self + : + $* <>EOE != 0 + cmd 1>&1 + EOI + testscript:1:8: error: stdout merge redirect file descriptor must be 2 + EOE + + : missed + : + $* <>EOE != 0 + cmd 1>& + EOI + testscript:1:8: error: missing stdout file descriptor + EOE + } + + : err + { + : out + : + $* <>EOO + cmd 2>&1 + EOI + cmd 2>&1 + EOO + + : no-mutual + : + $* <>EOO + cmd 1>&2 2>&1 >a + EOI + cmd >a 2>&1 + EOO + + : not-descriptor + : + $* <>EOE != 0 + cmd 2>&a + EOI + testscript:1:8: error: stderr merge redirect file descriptor must be 1 + EOE + + : self + : + $* <>EOE != 0 + cmd 2>&2 + EOI + testscript:1:8: error: stderr merge redirect file descriptor must be 1 + EOE + + : missed + : + $* <>EOE != 0 + cmd 2>& + EOI + testscript:1:8: error: missing stderr file descriptor + EOE + } + + : mutual + : + $* <>EOE != 0 + cmd 1>&2 2>&1 + EOI + testscript:1:14: error: stdout and stderr redirected to each other + EOE +} diff --git a/unit-tests/test/script/parser/regex.test b/unit-tests/test/script/parser/regex.test deleted file mode 100644 index d8ebb68..0000000 --- a/unit-tests/test/script/parser/regex.test +++ /dev/null @@ -1,223 +0,0 @@ -# file : unit-tests/test/script/parser/regex.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: here-string -: -{ - : stdout - : - { - : missed - : - $* <'cmd >~' 2>>EOE != 0 - testscript:1:7: error: missing stdout here-string regex - EOE - - : no-introducer - : - $* <'cmd >~""' 2>>EOE != 0 - testscript:1:7: error: no introducer character in stdout regex redirect - EOE - - : no-term-introducer - : - $* <'cmd >~/' 2>>EOE != 0 - testscript:1:7: error: no closing introducer character in stdout regex redirect - EOE - - : portable-path-introducer - : - $* <'cmd >/~/foo/' 2>>EOE != 0 - testscript:1:8: error: portable path modifier and '/' introducer in stdout regex redirect - EOE - - : empty - : - $* <'cmd >~//' 2>>EOE != 0 - testscript:1:7: error: stdout regex redirect is empty - EOE - - : no-flags - : - $* <'cmd >~/fo*/' >'cmd >~/fo*/' - - : idot - : - $* <'cmd >~/fo*/d' >'cmd >~/fo*/d' - - : icase - : - $* <'cmd >~/fo*/i' >'cmd >~/fo*/i' - - : invalid-flags1 - : - $* <'cmd >~/foo/z' 2>>EOE != 0 - testscript:1:7: error: junk at the end of stdout regex redirect - EOE - - : invalid-flags2 - : - $* <'cmd >~/foo/iz' 2>>EOE != 0 - testscript:1:7: error: junk at the end of stdout regex redirect - EOE - - : no-newline - : - $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' - } - - : stderr - : - { - : missed - : - $* <'cmd 2>~' 2>>EOE != 0 - testscript:1:8: error: missing stderr here-string regex - EOE - - : no-introducer - : - : Note that there is no need to reproduce all the errors as for stdout. - : All we need is to make sure that the proper description is passed to - : the parse_regex() function. - : - $* <'cmd 2>~""' 2>>EOE != 0 - 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 -: -{ - : stdout - : - { - : missed - : - $* <'cmd >>~' 2>>EOE != 0 - testscript:1:8: error: expected here-document regex end marker - EOE - - : portable-path-introducer - : - $* <>EOE != 0 - cmd >>/~/EOO/ - foo - EOO - EOI - testscript:1:5: error: portable path modifier and '/' introducer in here-document regex end marker - EOE - - : unterminated-line-char - : - $* <>EOE != 0 - cmd >>~/EOO/ - / - EOO - EOI - testscript:2:1: error: no syntax line characters - EOE - - : empty - : - $* <>EOE != 0 - cmd >>:~/EOO/ - EOO - EOI - testscript:2:1: error: empty here-document regex - EOE - - : no-flags - : - $* <>EOO - cmd 2>>~/EOE/ - foo - /? - /foo/ - /foo/* - /foo/i - /foo/i* - - // - //* - EOE - EOI - cmd 2>>~/EOE/ - foo - /? - /foo/ - /foo/* - /foo/i - /foo/i* - - // - //* - EOE - EOO - - : no-newline - : - $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' - $* <>EOO - cmd 2>>:~/EOE/ - foo - EOE - EOI - cmd 2>>:~/EOE/ - foo - EOE - EOO - - : end-marker-restore - : - { - : idot - : - $* <>EOO - cmd 2>>~/EOE/d - foo - EOE - EOI - cmd 2>>~/EOE/d - foo - EOE - EOO - - : icase - : - $* <>EOO - cmd 2>>~/EOE/i - foo - EOE - EOI - cmd 2>>~/EOE/i - foo - EOE - EOO - } - } - - : stderr - : - { - : missed - : - $* <'cmd 2>>~' 2>>EOE != 0 - 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 -} diff --git a/unit-tests/test/script/parser/regex.testscript b/unit-tests/test/script/parser/regex.testscript new file mode 100644 index 0000000..67832eb --- /dev/null +++ b/unit-tests/test/script/parser/regex.testscript @@ -0,0 +1,223 @@ +# file : unit-tests/test/script/parser/regex.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: here-string +: +{ + : stdout + : + { + : missed + : + $* <'cmd >~' 2>>EOE != 0 + testscript:1:7: error: missing stdout here-string regex + EOE + + : no-introducer + : + $* <'cmd >~""' 2>>EOE != 0 + testscript:1:7: error: no introducer character in stdout regex redirect + EOE + + : no-term-introducer + : + $* <'cmd >~/' 2>>EOE != 0 + testscript:1:7: error: no closing introducer character in stdout regex redirect + EOE + + : portable-path-introducer + : + $* <'cmd >/~/foo/' 2>>EOE != 0 + testscript:1:8: error: portable path modifier and '/' introducer in stdout regex redirect + EOE + + : empty + : + $* <'cmd >~//' 2>>EOE != 0 + testscript:1:7: error: stdout regex redirect is empty + EOE + + : no-flags + : + $* <'cmd >~/fo*/' >'cmd >~/fo*/' + + : idot + : + $* <'cmd >~/fo*/d' >'cmd >~/fo*/d' + + : icase + : + $* <'cmd >~/fo*/i' >'cmd >~/fo*/i' + + : invalid-flags1 + : + $* <'cmd >~/foo/z' 2>>EOE != 0 + testscript:1:7: error: junk at the end of stdout regex redirect + EOE + + : invalid-flags2 + : + $* <'cmd >~/foo/iz' 2>>EOE != 0 + testscript:1:7: error: junk at the end of stdout regex redirect + EOE + + : no-newline + : + $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' + } + + : stderr + : + { + : missed + : + $* <'cmd 2>~' 2>>EOE != 0 + testscript:1:8: error: missing stderr here-string regex + EOE + + : no-introducer + : + : Note that there is no need to reproduce all the errors as for stdout. + : All we need is to make sure that the proper description is passed to + : the parse_regex() function. + : + $* <'cmd 2>~""' 2>>EOE != 0 + 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 +: +{ + : stdout + : + { + : missed + : + $* <'cmd >>~' 2>>EOE != 0 + testscript:1:8: error: expected here-document regex end marker + EOE + + : portable-path-introducer + : + $* <>EOE != 0 + cmd >>/~/EOO/ + foo + EOO + EOI + testscript:1:5: error: portable path modifier and '/' introducer in here-document regex end marker + EOE + + : unterminated-line-char + : + $* <>EOE != 0 + cmd >>~/EOO/ + / + EOO + EOI + testscript:2:1: error: no syntax line characters + EOE + + : empty + : + $* <>EOE != 0 + cmd >>:~/EOO/ + EOO + EOI + testscript:2:1: error: empty here-document regex + EOE + + : no-flags + : + $* <>EOO + cmd 2>>~/EOE/ + foo + /? + /foo/ + /foo/* + /foo/i + /foo/i* + + // + //* + EOE + EOI + cmd 2>>~/EOE/ + foo + /? + /foo/ + /foo/* + /foo/i + /foo/i* + + // + //* + EOE + EOO + + : no-newline + : + $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' + $* <>EOO + cmd 2>>:~/EOE/ + foo + EOE + EOI + cmd 2>>:~/EOE/ + foo + EOE + EOO + + : end-marker-restore + : + { + : idot + : + $* <>EOO + cmd 2>>~/EOE/d + foo + EOE + EOI + cmd 2>>~/EOE/d + foo + EOE + EOO + + : icase + : + $* <>EOO + cmd 2>>~/EOE/i + foo + EOE + EOI + cmd 2>>~/EOE/i + foo + EOE + EOO + } + } + + : stderr + : + { + : missed + : + $* <'cmd 2>>~' 2>>EOE != 0 + 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 +} diff --git a/unit-tests/test/script/parser/scope-if.test b/unit-tests/test/script/parser/scope-if.test deleted file mode 100644 index c0cf6fb..0000000 --- a/unit-tests/test/script/parser/scope-if.test +++ /dev/null @@ -1,554 +0,0 @@ -# file : unit-tests/test/script/parser/scope-if.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: if -: -{ - : true - : - $* -s <>EOO - if true foo - { - cmd - } - EOI - { - ? true foo - { - cmd - } - } - EOO - - : false - : - $* -s <>EOO - if false foo - { - cmd - } - EOI - { - ? false foo - } - EOO - - : not-true - : - $* -s <>EOO - if! true - { - cmd - } - EOI - { - ? true - } - EOO - - : not-false - : - $* -s <>EOO - if! false - { - cmd - } - EOI - { - ? false - { - cmd - } - } - EOO - - : eos-inside - : - $* <>EOE != 0 - if - { - EOI - testscript:3:1: error: expected '}' at the end of the scope - EOE - -} - -: elif -: -{ - : true - : - $* -s <>EOO - if false - { - cmd - } - elif true - { - cmd1 - } - EOI - { - ? false - ? true - { - cmd1 - } - } - EOO - - : false - : - $* -s <>EOO - if false - { - cmd - } - elif false - { - cmd - } - EOI - { - ? false - ? false - } - EOO - - : not-false - : - $* -s <>EOO - if false - { - cmd - } - elif! false - { - cmd1 - } - EOI - { - ? false - ? false - { - cmd1 - } - } - EOO - - : not-true - : - $* -s <>EOO - if false - { - cmd - } - elif! true - { - cmd - } - EOI - { - ? false - ? true - } - EOO - - : after-else - : - $* <>EOE != 0 - if false - { - cmd - } - else - { - cmd - } - elif true - { - cmd - } - EOI - testscript:9:1: error: 'elif' after 'else' - EOE -} - -: else -: -{ - : true - : - $* -s <>EOO - if false - { - cmd - } - else - { - cmd1 - } - EOI - { - ? false - { - cmd1 - } - } - EOO - - : false - : - $* -s <>EOO - if true - { - cmd1 - } - else - { - cmd - } - EOI - { - ? true - { - cmd1 - } - } - EOO - - : chain - : - $* -s <>EOO - if false - { - cmd - } - elif false - { - cmd - cmd - } - elif false - { - cmd - } - elif true - { - cmd1 - cmd2 - } - elif false - { - cmd - } - else - { - cmd - cmd - } - EOI - { - ? false - ? false - ? false - ? true - { - { - cmd1 - } - { - cmd2 - } - } - } - EOO - - : scope-expected - : - $* <>EOE != 0 - if - { - cmd - } - else - cmd - EOI - testscript:5:1: error: expected scope after 'else' - EOE - - : after-else - : - $* <>EOE != 0 - if false - { - cmd - } - else - { - cmd - } - else - { - cmd - } - EOI - testscript:9:1: error: 'else' after 'else' - EOE -} - -: nested -: -{ - : take - : - $* -s <>EOO - if true - { - cmd1 - if false - { - cmd - } - elif false - { - if true - { - cmd - } - } - else - { - cmd2 - } - cmd3 - } - EOI - { - ? true - { - { - cmd1 - } - ? false - ? false - { - { - cmd2 - } - } - { - cmd3 - } - } - } - EOO - - : skip - : - $* -s <>EOO - if false - { - cmd1 - if false - { - cmd - } - elif false - { - if true - { - cmd - } - } - else - { - cmd2 - } - cmd3 - } - else - { - cmd - } - EOI - { - ? false - { - { - cmd - } - } - } - EOO -} - -: demote -: -{ - : group - : Chain remains a group - : - $* -s <>EOO - if false - { - cmd - } - elif true - { - cmd1 - cmd2 - } - else - { - cmd - } - EOI - { - ? false - ? true - { - { - cmd1 - } - { - cmd2 - } - } - } - EOO - - : test - : Chain demoted to test - : - $* -s <>EOO - if false - { - cmd - } - elif true - { - cmd1 - } - else - { - cmd - } - EOI - { - ? false - ? true - { - cmd1 - } - } - EOO -} - -: line-index -: Make sure command line index spans setup/if/teardown -: -$* -s -l <>EOO -+setup # 1 - -if false one # 2 -{ - cmd -} -elif false two # 3 -{ - cmd -} -elif true # 4 -{ - cmd1 -} -elif false # 5 -{ - cmd -} -else -{ - cmd -} - -if false one # 6 -{ - cmd -} -elif false two # 7 -{ - cmd -} -else -{ - cmd2 -} - --tdown # 8 -EOI -{ - +setup # 1 - ? false one # 2 - ? false two # 3 - ? true # 4 - { - cmd1 # 0 - } - ? false one # 6 - ? false two # 7 - { - cmd2 # 0 - } - -tdown # 8 -} -EOO - -: scope-comman-if -: -$* -s <>EOO -if true -{ - cmd -} -if true - cmd1 - cmd2 -end -EOI -{ - ? true - { - cmd - } - { - ? true - cmd1 - cmd2 - } -} -EOO - -: shared-id-desc -: -$* -s -i <>EOO -: test summary -: -if false -{ - cmd -} -else -{ - cmd1 -} -EOI -{ - ? false - : sm:test summary - { # 3 - cmd1 - } -} -EOO diff --git a/unit-tests/test/script/parser/scope-if.testscript b/unit-tests/test/script/parser/scope-if.testscript new file mode 100644 index 0000000..c76fab7 --- /dev/null +++ b/unit-tests/test/script/parser/scope-if.testscript @@ -0,0 +1,554 @@ +# file : unit-tests/test/script/parser/scope-if.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: if +: +{ + : true + : + $* -s <>EOO + if true foo + { + cmd + } + EOI + { + ? true foo + { + cmd + } + } + EOO + + : false + : + $* -s <>EOO + if false foo + { + cmd + } + EOI + { + ? false foo + } + EOO + + : not-true + : + $* -s <>EOO + if! true + { + cmd + } + EOI + { + ? true + } + EOO + + : not-false + : + $* -s <>EOO + if! false + { + cmd + } + EOI + { + ? false + { + cmd + } + } + EOO + + : eos-inside + : + $* <>EOE != 0 + if + { + EOI + testscript:3:1: error: expected '}' at the end of the scope + EOE + +} + +: elif +: +{ + : true + : + $* -s <>EOO + if false + { + cmd + } + elif true + { + cmd1 + } + EOI + { + ? false + ? true + { + cmd1 + } + } + EOO + + : false + : + $* -s <>EOO + if false + { + cmd + } + elif false + { + cmd + } + EOI + { + ? false + ? false + } + EOO + + : not-false + : + $* -s <>EOO + if false + { + cmd + } + elif! false + { + cmd1 + } + EOI + { + ? false + ? false + { + cmd1 + } + } + EOO + + : not-true + : + $* -s <>EOO + if false + { + cmd + } + elif! true + { + cmd + } + EOI + { + ? false + ? true + } + EOO + + : after-else + : + $* <>EOE != 0 + if false + { + cmd + } + else + { + cmd + } + elif true + { + cmd + } + EOI + testscript:9:1: error: 'elif' after 'else' + EOE +} + +: else +: +{ + : true + : + $* -s <>EOO + if false + { + cmd + } + else + { + cmd1 + } + EOI + { + ? false + { + cmd1 + } + } + EOO + + : false + : + $* -s <>EOO + if true + { + cmd1 + } + else + { + cmd + } + EOI + { + ? true + { + cmd1 + } + } + EOO + + : chain + : + $* -s <>EOO + if false + { + cmd + } + elif false + { + cmd + cmd + } + elif false + { + cmd + } + elif true + { + cmd1 + cmd2 + } + elif false + { + cmd + } + else + { + cmd + cmd + } + EOI + { + ? false + ? false + ? false + ? true + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO + + : scope-expected + : + $* <>EOE != 0 + if + { + cmd + } + else + cmd + EOI + testscript:5:1: error: expected scope after 'else' + EOE + + : after-else + : + $* <>EOE != 0 + if false + { + cmd + } + else + { + cmd + } + else + { + cmd + } + EOI + testscript:9:1: error: 'else' after 'else' + EOE +} + +: nested +: +{ + : take + : + $* -s <>EOO + if true + { + cmd1 + if false + { + cmd + } + elif false + { + if true + { + cmd + } + } + else + { + cmd2 + } + cmd3 + } + EOI + { + ? true + { + { + cmd1 + } + ? false + ? false + { + { + cmd2 + } + } + { + cmd3 + } + } + } + EOO + + : skip + : + $* -s <>EOO + if false + { + cmd1 + if false + { + cmd + } + elif false + { + if true + { + cmd + } + } + else + { + cmd2 + } + cmd3 + } + else + { + cmd + } + EOI + { + ? false + { + { + cmd + } + } + } + EOO +} + +: demote +: +{ + : group + : Chain remains a group + : + $* -s <>EOO + if false + { + cmd + } + elif true + { + cmd1 + cmd2 + } + else + { + cmd + } + EOI + { + ? false + ? true + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO + + : test + : Chain demoted to test + : + $* -s <>EOO + if false + { + cmd + } + elif true + { + cmd1 + } + else + { + cmd + } + EOI + { + ? false + ? true + { + cmd1 + } + } + EOO +} + +: line-index +: Make sure command line index spans setup/if/teardown +: +$* -s -l <>EOO ++setup # 1 + +if false one # 2 +{ + cmd +} +elif false two # 3 +{ + cmd +} +elif true # 4 +{ + cmd1 +} +elif false # 5 +{ + cmd +} +else +{ + cmd +} + +if false one # 6 +{ + cmd +} +elif false two # 7 +{ + cmd +} +else +{ + cmd2 +} + +-tdown # 8 +EOI +{ + +setup # 1 + ? false one # 2 + ? false two # 3 + ? true # 4 + { + cmd1 # 0 + } + ? false one # 6 + ? false two # 7 + { + cmd2 # 0 + } + -tdown # 8 +} +EOO + +: scope-comman-if +: +$* -s <>EOO +if true +{ + cmd +} +if true + cmd1 + cmd2 +end +EOI +{ + ? true + { + cmd + } + { + ? true + cmd1 + cmd2 + } +} +EOO + +: shared-id-desc +: +$* -s -i <>EOO +: test summary +: +if false +{ + cmd +} +else +{ + cmd1 +} +EOI +{ + ? false + : sm:test summary + { # 3 + cmd1 + } +} +EOO diff --git a/unit-tests/test/script/parser/scope.test b/unit-tests/test/script/parser/scope.test deleted file mode 100644 index 21a6f50..0000000 --- a/unit-tests/test/script/parser/scope.test +++ /dev/null @@ -1,280 +0,0 @@ -# file : unit-tests/test/script/parser/scope.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -$* testscript <'cmd $@' >"cmd 1" : id-testscript -$* foo.test <'cmd $@' >"cmd foo/1" : id - -: wd-testscript -: -$* testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]1'?%" - -: wd -: -$* foo.test <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]foo[/\\\\]1'?%" - -: group -: -{ - : empty - : - $* -s <>EOO - { - cmd1 - cmd2 - } - EOI - { - { - { - cmd1 - } - { - cmd2 - } - } - } - EOO -} - -: test -: -{ - : explicit - : - { - : one-level - : - $* -s -i <>EOO - { - cmd - } - EOI - { - { # 1 - cmd - } - } - EOO - - : nested - : - $* -s -i <>EOO - { - { - cmd - } - } - EOI - { - { # 1 - cmd - } - } - EOO - - : var - : - $* -s -i <>EOO - { - x = abc - cmd $x - } - EOI - { - { # 1 - cmd abc - } - } - EOO - - : setup - : - $* -s -i <>EOO - { - x = abc - +setup - cmd $x - } - EOI - { - { # 1 - +setup - { # 1/4 - cmd abc - } - } - } - EOO - } - - : implicit - { - : one-cmd - : - $* -s <>EOO - cmd1 - EOI - { - { - cmd1 - } - } - EOO - - : two-cmd - : - $* -s <>EOO - cmd1; - cmd2 - EOI - { - { - cmd1 - cmd2 - } - } - EOO - - : three-cmd - : - $* -s <>EOO - cmd1; - cmd2; - cmd3 - EOI - { - { - cmd1 - cmd2 - cmd3 - } - } - EOO - - : var - : - $* -s <>EOO - cmd1; - x = abc; - cmd2 $x - EOI - { - { - cmd1 - cmd2 abc - } - } - EOO - - : var-first - : - $* -s <>EOO - x = abc; - cmd $x - EOI - { - { - cmd abc - } - } - EOO - - : var-setup-tdown - : - $* -s <>EOO - x = abc - cmd $x - y = 123 - EOI - { - { - cmd abc - } - } - EOO - - : after-tdown - : - $* <>EOE != 0 - cmd1 - x = abc - cmd2 - EOI - testscript:3:1: error: test after teardown - testscript:2:1: info: last teardown line appears here - EOE - } -} - -: expected -{ - : newline-lcbrace - : - $* <:"{x" 2>>EOE != 0 - testscript:1:2: error: expected newline after '{' - EOE - - : rcbrace - : - $* <"{" 2>>EOE != 0 - testscript:2:1: error: expected '}' at the end of the scope - EOE - - : line-rcbrace - : - $* <>EOE != 0 - { - cmd; - } - EOI - testscript:3:1: error: expected another line after ';' - EOE - - : newline-rcbrace - : - $* <<:EOI 2>>EOE != 0 - { - } - EOI - testscript:2:2: error: expected newline after '}' - EOE - - : line-eof - : - $* <>EOE != 0 - cmd; - EOI - testscript:2:1: error: expected another line after ';' - EOE - - : newline-cmd - : - $* <<:EOI 2>>EOE != 0 - cmd; - EOI - testscript:1:5: error: expected newline instead of - EOE - - : newline-var - : - $* <:"x = abc;" 2>>EOE != 0 - testscript:1:9: error: expected newline instead of - EOE -} diff --git a/unit-tests/test/script/parser/scope.testscript b/unit-tests/test/script/parser/scope.testscript new file mode 100644 index 0000000..721e455 --- /dev/null +++ b/unit-tests/test/script/parser/scope.testscript @@ -0,0 +1,280 @@ +# file : unit-tests/test/script/parser/scope.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* testscript <'cmd $@' >"cmd 1" : id-testscript +$* foo.testscript <'cmd $@' >"cmd foo/1" : id + +: wd-testscript +: +$* testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]1'?%" + +: wd +: +$* foo.testscript <'cmd "$~"' >~"%cmd '?.+[/\\\\]test-driver[/\\\\]foo[/\\\\]1'?%" + +: group +: +{ + : empty + : + $* -s <>EOO + { + cmd1 + cmd2 + } + EOI + { + { + { + cmd1 + } + { + cmd2 + } + } + } + EOO +} + +: test +: +{ + : explicit + : + { + : one-level + : + $* -s -i <>EOO + { + cmd + } + EOI + { + { # 1 + cmd + } + } + EOO + + : nested + : + $* -s -i <>EOO + { + { + cmd + } + } + EOI + { + { # 1 + cmd + } + } + EOO + + : var + : + $* -s -i <>EOO + { + x = abc + cmd $x + } + EOI + { + { # 1 + cmd abc + } + } + EOO + + : setup + : + $* -s -i <>EOO + { + x = abc + +setup + cmd $x + } + EOI + { + { # 1 + +setup + { # 1/4 + cmd abc + } + } + } + EOO + } + + : implicit + { + : one-cmd + : + $* -s <>EOO + cmd1 + EOI + { + { + cmd1 + } + } + EOO + + : two-cmd + : + $* -s <>EOO + cmd1; + cmd2 + EOI + { + { + cmd1 + cmd2 + } + } + EOO + + : three-cmd + : + $* -s <>EOO + cmd1; + cmd2; + cmd3 + EOI + { + { + cmd1 + cmd2 + cmd3 + } + } + EOO + + : var + : + $* -s <>EOO + cmd1; + x = abc; + cmd2 $x + EOI + { + { + cmd1 + cmd2 abc + } + } + EOO + + : var-first + : + $* -s <>EOO + x = abc; + cmd $x + EOI + { + { + cmd abc + } + } + EOO + + : var-setup-tdown + : + $* -s <>EOO + x = abc + cmd $x + y = 123 + EOI + { + { + cmd abc + } + } + EOO + + : after-tdown + : + $* <>EOE != 0 + cmd1 + x = abc + cmd2 + EOI + testscript:3:1: error: test after teardown + testscript:2:1: info: last teardown line appears here + EOE + } +} + +: expected +{ + : newline-lcbrace + : + $* <:"{x" 2>>EOE != 0 + testscript:1:2: error: expected newline after '{' + EOE + + : rcbrace + : + $* <"{" 2>>EOE != 0 + testscript:2:1: error: expected '}' at the end of the scope + EOE + + : line-rcbrace + : + $* <>EOE != 0 + { + cmd; + } + EOI + testscript:3:1: error: expected another line after ';' + EOE + + : newline-rcbrace + : + $* <<:EOI 2>>EOE != 0 + { + } + EOI + testscript:2:2: error: expected newline after '}' + EOE + + : line-eof + : + $* <>EOE != 0 + cmd; + EOI + testscript:2:1: error: expected another line after ';' + EOE + + : newline-cmd + : + $* <<:EOI 2>>EOE != 0 + cmd; + EOI + testscript:1:5: error: expected newline instead of + EOE + + : newline-var + : + $* <:"x = abc;" 2>>EOE != 0 + testscript:1:9: error: expected newline instead of + EOE +} diff --git a/unit-tests/test/script/parser/setup-teardown.test b/unit-tests/test/script/parser/setup-teardown.test deleted file mode 100644 index f9cbb04..0000000 --- a/unit-tests/test/script/parser/setup-teardown.test +++ /dev/null @@ -1,151 +0,0 @@ -# file : unit-tests/test/script/parser/setup-teardown.test -# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: setup -: -{ - : followed - : - { - : semi - : - $* <"+cmd;" 2>>EOE != 0 - testscript:1:5: error: ';' after setup command - EOE - - : colon - : - $* <"+cmd:" 2>>EOE != 0 - testscript:1:5: error: ':' after setup command - EOE - } - - : after - : - { - : test - : - $* <>EOE != 0 - cmd - +cmd - EOI - testscript:2:1: error: setup command after tests - EOE - - : after-tdownt - : - $* <>EOE != 0 - -cmd - +cmd - EOI - testscript:2:1: error: setup command after teardown - EOE - } - - : in-test - : - $* <>EOE != 0 - cmd; - +cmd - EOI - testscript:2:1: error: setup command in test - EOE -} - -: tdown -: -{ - : followed - : - { - : semi - : - $* <"-cmd;" 2>>EOE != 0 - testscript:1:5: error: ';' after teardown command - EOE - - : colon - : - $* <"-cmd:" 2>>EOE != 0 - testscript:1:5: error: ':' after teardown command - EOE - } - - : in-test - : - $* <>EOE != 0 - cmd; - -cmd - EOI - testscript:2:1: error: teardown command in test - EOE -} - -: var -: -{ - : between-tests - : - $* <>EOE != 0 - cmd - x = y - cmd - EOI - testscript:3:1: error: test after teardown - testscript:2:1: info: last teardown line appears here - EOE - - : between-tests-scope - : - $* <>EOE != 0 - cmd - x = y - { - cmd - } - EOI - testscript:3:1: error: scope after teardown - testscript:2:1: info: last teardown line appears here - EOE - - : between-tests-command-if - : - $* <>EOE != 0 - cmd - x = y - if true - cmd - end - EOI - testscript:3:1: error: test after teardown - testscript:2:1: info: last teardown line appears here - EOE - - : between-tests-scope-if - : - $* <>EOE != 0 - cmd - x = y - if true - { - cmd - } - EOI - testscript:3:1: error: scope after teardown - testscript:2:1: info: last teardown line appears here - EOE - - : between-tests-variable-if - : - $* <>EOO - cmd - x = y - if true - y = x - end - EOI - cmd - ? true - EOO -} diff --git a/unit-tests/test/script/parser/setup-teardown.testscript b/unit-tests/test/script/parser/setup-teardown.testscript new file mode 100644 index 0000000..12fde8c --- /dev/null +++ b/unit-tests/test/script/parser/setup-teardown.testscript @@ -0,0 +1,151 @@ +# file : unit-tests/test/script/parser/setup-teardown.testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +: setup +: +{ + : followed + : + { + : semi + : + $* <"+cmd;" 2>>EOE != 0 + testscript:1:5: error: ';' after setup command + EOE + + : colon + : + $* <"+cmd:" 2>>EOE != 0 + testscript:1:5: error: ':' after setup command + EOE + } + + : after + : + { + : test + : + $* <>EOE != 0 + cmd + +cmd + EOI + testscript:2:1: error: setup command after tests + EOE + + : after-tdownt + : + $* <>EOE != 0 + -cmd + +cmd + EOI + testscript:2:1: error: setup command after teardown + EOE + } + + : in-test + : + $* <>EOE != 0 + cmd; + +cmd + EOI + testscript:2:1: error: setup command in test + EOE +} + +: tdown +: +{ + : followed + : + { + : semi + : + $* <"-cmd;" 2>>EOE != 0 + testscript:1:5: error: ';' after teardown command + EOE + + : colon + : + $* <"-cmd:" 2>>EOE != 0 + testscript:1:5: error: ':' after teardown command + EOE + } + + : in-test + : + $* <>EOE != 0 + cmd; + -cmd + EOI + testscript:2:1: error: teardown command in test + EOE +} + +: var +: +{ + : between-tests + : + $* <>EOE != 0 + cmd + x = y + cmd + EOI + testscript:3:1: error: test after teardown + testscript:2:1: info: last teardown line appears here + EOE + + : between-tests-scope + : + $* <>EOE != 0 + cmd + x = y + { + cmd + } + EOI + testscript:3:1: error: scope after teardown + testscript:2:1: info: last teardown line appears here + EOE + + : between-tests-command-if + : + $* <>EOE != 0 + cmd + x = y + if true + cmd + end + EOI + testscript:3:1: error: test after teardown + testscript:2:1: info: last teardown line appears here + EOE + + : between-tests-scope-if + : + $* <>EOE != 0 + cmd + x = y + if true + { + cmd + } + EOI + testscript:3:1: error: scope after teardown + testscript:2:1: info: last teardown line appears here + EOE + + : between-tests-variable-if + : + $* <>EOO + cmd + x = y + if true + y = x + end + EOI + cmd + ? true + EOO +} -- cgit v1.1