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{} --- 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 +- 113 files changed, 5562 insertions(+), 5561 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 (limited to 'tests') 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 : -- cgit v1.1