diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-12-31 03:14:50 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-05 15:30:49 +0300 |
commit | b917233d4b618d587f569706d8d528b051efdba4 (patch) | |
tree | 1ff132a7299cb962a5be4be3a4b0fadeea2141f3 | |
parent | e1837dc7da78055ab3e355c3e941a7415146c1b8 (diff) |
Tests cleanup
-rw-r--r-- | build2/functions-string.cxx | 6 | ||||
-rw-r--r-- | tests/test/script/builtin/cat.test | 40 | ||||
-rw-r--r-- | tests/test/script/builtin/mkdir.test | 30 | ||||
-rw-r--r-- | tests/test/script/builtin/rm.test | 41 | ||||
-rw-r--r-- | tests/test/script/builtin/touch.test | 27 | ||||
-rw-r--r-- | tests/test/script/integration/testscript | 4 | ||||
-rw-r--r-- | tests/test/script/runner/cleanup.test | 414 | ||||
-rw-r--r-- | tests/test/script/runner/redirect.test | 647 | ||||
-rw-r--r-- | tests/test/script/runner/status.test | 54 | ||||
-rw-r--r-- | unit-tests/function/call.test | 2 | ||||
-rw-r--r-- | unit-tests/function/driver.cxx | 4 |
11 files changed, 692 insertions, 577 deletions
diff --git a/build2/functions-string.cxx b/build2/functions-string.cxx index 1bf7aa8..29bc62a 100644 --- a/build2/functions-string.cxx +++ b/build2/functions-string.cxx @@ -15,7 +15,11 @@ namespace build2 function_family f ("string"); f["string"] = [](string s) {return s;}; - f["string"] = [](strings v) {return v;}; + + // @@ Shouldn't it concatenate elements into the single string? + // @@ Doesn't seem to be used so far. Can consider removing. + // + // f["string"] = [](strings v) {return v;}; // String-specific overloads from builtins. // diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test index 5049ca9..20cdb86 100644 --- a/tests/test/script/builtin/cat.test +++ b/tests/test/script/builtin/cat.test @@ -2,66 +2,82 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# @@ I think these should be run indirectly (via cat & build) -# for cross-testing to work (we want to run the via the build -# system we built, not the one we used to acomplish this. +.include ../common.test : in : -cat <<EOI >>EOO +$c <<EOI; +cat <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : dash : -cat - <<EOI >>EOO +$c <<EOI; +cat - <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : file : -cat <<EOI >>>out; +$c <<EOI; +cat <<EOF >>>out; foo bar -EOI +EOF cat out >>EOO foo bar EOO +EOI +$b : in-repeat : -cat - <<EOI >>EOO +$c <<EOI; +cat - <<EOF >>EOO foo bar -EOI +EOF foo bar EOO +EOI +$b : non-existent : : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; cat in 2>>~%EOE% != 0 -%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]in': .+% +%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]test[/\\]1[/\\]in': .+% %%? EOE +EOI +$b : empty-path : : Cat an empty path. : +$c <<EOI; cat '' 2>"cat: invalid path ''" == 1 +EOI +$b # @@ When piping is ready test cat on a big file to test it is asynchronous. # diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test index dafcd35..07b6090 100644 --- a/tests/test/script/builtin/mkdir.test +++ b/tests/test/script/builtin/mkdir.test @@ -2,38 +2,54 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : dirs : +$c <<EOI; mkdir a b; touch a/a b/b +EOI +$b : parent : +$c <<EOI; mkdir -p a/b; touch a/a a/b/b +EOI +$b : exists : -mkdir -p a a a/b a/b +$c <'mkdir -p a a a/b a/b'; +$b : double-dash : : Make sure '-p' directory is created. : +$c <<EOI; mkdir -p -- -p; touch -p/a +EOI +$b : no-args : : Test passing no arguments. : -mkdir 2>"mkdir: missing directory" == 1 +$c <'mkdir 2>"mkdir: missing directory" == 1'; +$b : empty-path : : Test creation of empty directory path. : +$c <<EOI; mkdir '' 2>"mkdir: invalid path ''" == 1 +EOI +$b : already-exists : @@ -42,10 +58,13 @@ mkdir '' 2>"mkdir: invalid path ''" == 1 : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; mkdir a a 2>>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]a': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : not-exists : @@ -54,7 +73,10 @@ EOE : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; mkdir a/b 2>>~%EOE% == 1 -%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]a[/\\]b': .+% +%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]test[/\\]1[/\\]a[/\\]b': .+% %%? EOE +EOI +$b diff --git a/tests/test/script/builtin/rm.test b/tests/test/script/builtin/rm.test index 20b2b24..9a18de1 100644 --- a/tests/test/script/builtin/rm.test +++ b/tests/test/script/builtin/rm.test @@ -2,32 +2,40 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -td = $~ +.include ../common.test : no-args : : Removing with no arguments fails. : -rm 2>"rm: missing file" == 1 +$c <'rm 2>"rm: missing file" == 1'; +$b : no-args-force : : Removing with no arguments succeeds with -f option. : -rm -f +$c <'rm -f'; +$b : empty-path : : Removing an empty path fails. : +$c <<EOI; rm '' 2>"rm: invalid path ''" == 1 +EOI +$b : file : : Removing existing file succeeds. : +$c <<EOI; touch a &!a; rm a +EOI +$b : file-not-exists : @@ -36,36 +44,49 @@ rm a : Note that there is an optional trailing blank line in the regex that matches : the newline added by msvcrt as a part of the error description. : +$c <<EOI; rm a 2>>~%EOE% == 1 -%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]a': .+% +%rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file-not-exists[/\\]test[/\\]1[/\\]a': .+% %%? EOE +EOI +$b : file-not-exists-force : : Removing non-existing file succeeds with -f option. : -rm -f a +$c <'rm -f a'; +$b : dir : : Removing directory fails by default. : +$c <<EOI; mkdir a; rm a 2>"rm: '$normalize([path] $~/a)' is a directory" == 1 +EOI +$b : dir-recursive : : Removing directory succeeds with -r option. : +$c <<EOI; mkdir -p a/b &!a &!a/b; rm -r a +EOI +$b : scope-dir : : Removing scope directory fails. : +$c <<EOI; rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1 +EOI +$b : outside-scope : @@ -73,7 +94,12 @@ rm -r ./ 2>"rm: '([string] $~)' contains test working directory '$~'" == 1 : path that unlikely exists (not to remove something useful). : : -rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working directory '$td'" == 1 +$c <<EOI; +rm ../../a/b/c 2>>~%EOE% == 1 +%rm: '.+[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'% +EOE +EOI +$b : outside-scope-force : @@ -81,4 +107,5 @@ rm ../../a/b/c 2>"rm: '$normalize([path] $~/../../a/b/c)' is out of working dire : option. Need to use a path that unlikely exists (not to remove something : useful). : -rm -f ../../a/b/c +$c <'rm -f ../../a/b/c'; +$b diff --git a/tests/test/script/builtin/touch.test b/tests/test/script/builtin/touch.test index da9ed91..3aa0271 100644 --- a/tests/test/script/builtin/touch.test +++ b/tests/test/script/builtin/touch.test @@ -2,54 +2,73 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file +.include ../common.test + : file : -touch a +$c <'touch a'; +$b : file-create : : Test that file is created. If it didn't then 'rm' would fail. : +$c <<EOI; touch a &!a; rm a +EOI +$b : file-update : : Test that existing file touch doesn't fail. : +$c <<EOI; cat <"" >>>a; touch a +EOI +$b : no-cleanup : -: Test that touching an existing file doesn't register cleanup. If it does then +: Test that touches an existing file doesn't 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 <<EOI; { +touch a { touch ../a } } +EOI +$b : no-args : : Test passing no arguments. : -touch 2>"touch: missing file" == 1 +$c <'touch 2>"touch: missing file" == 1'; +$b : empty-path : : Test touching an empty path. : +$c <<EOI; touch '' 2>"touch: invalid path ''" == 1 +EOI +$b : dir-update : : Test touching an existing directory. : +$c <<EOI; a = $~; a += "a"; mkdir a; -touch 2>"touch: '$a' exists and is not a file" a == 1 +touch a 2>"touch: '$a' exists and is not a file" == 1 +EOI +$b diff --git a/tests/test/script/integration/testscript b/tests/test/script/integration/testscript index 495c75a..2d56dde 100644 --- a/tests/test/script/integration/testscript +++ b/tests/test/script/integration/testscript @@ -2,10 +2,6 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# @@ I think these should be run indirectly (via cat & build) -# for cross-testing to work (we want to run the via the build -# system we built, not the one we used to acomplish this. - .include ../../common.test : script-files diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test index 6f6bb95..aec3f20 100644 --- a/tests/test/script/runner/cleanup.test +++ b/tests/test/script/runner/cleanup.test @@ -6,76 +6,221 @@ b += --no-column -# Valid cleanups. -# # @@ TODO: $c <'$* -f a &a' && $b # -: file-always -: -$c <'$* -f a &a'; -$b - -: file-maybe -: -$c <'$* &?a'; -$b - -: file-never -: -$c <'$* &!a'; -$b - -: file-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 -: rm failure. -: -$c <'touch ../../a'; -$b; -rm a - -: file-append -: -: Test that file append redirect does not not register cleanup. If it did, -: that cleanup would fail as the file would be already deleted by rm. -: -$c <<EOI; -touch a &!a; -$* -o foo >>>&a; -rm a -EOI -$b - -: dir-always -: -$c <'$* -d a &a/'; -$b - -: dir-maybe -: -$c <'$* &?a/'; -$b - -: dir-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 -: rm failure. -: -$c <'mkdir ../../a'; -$b; -rm -r a -: wildcard-always -: -$c <'$* -d a/b -f a/b/c &a/***'; -$b - -: wildcard-maybe -: -$c <'$* &?a/***'; -$b +: 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 <<EOI; + touch ../../a; + rm -f ../../a + EOI + $b + + : append + : + : Test that file append redirect does not not register cleanup. If it did, + : that cleanup would fail as the file would be already deleted by rm. + : + $c <<EOI; + touch a &!a; + $* -o foo >>>&a; + rm a + EOI + $b + + : 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. Note that there is an optional + : trailing blank line in the regex that matches the newline added by msvcrt + : as a part of the error description. + : + $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 <<EOI; + mkdir ../../a; + rm -r -f ../../a + EOI + $b + + : not-exists + : + : Test cleanup of non-existing 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 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. + : + $c <'$* -d a -f a/b &a/'; + $b 2>>~%EOE% != 0 + %testscript:1: error: registered for cleanup directory test[/\\]1[/\\]a[/\\] is not empty% + EOE + + : not-dir + : + : Test cleanup of a file as a directory. Note that there is an optional + : trailing blank line in the regex that matches the newline added by msvcrt + : as a part of the error description. + : + $c <'$* -f a &a/'; + $b 2>>~%EOE% != 0 + %error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+% + %%? + EOE +} + +: wildcard +: +{ + : always + : + $c <'$* -d a/b -f a/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 wildcard test[/\\]1[/\\]a[/\\]\*\*\* doesn't match a directory% + 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 wildcard test[/\\]a[/\\]\*\*\* doesn't match a directory% + EOE + + : not-dir + : + : Test cleanup of a file as a wildcard. Note that there is an optional + : trailing blank line in the regex that matches the newline added by msvcrt + : as a part of the error description. + : + $c <'$* -f a &a/***'; + $b 2>>~%EOE% != 0 + %error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+% + %%? + EOE +} : order : @@ -84,141 +229,6 @@ $b $c <'$* -d a/b &a/ &a/b/'; $b -# Invalid cleanups. -# -: file-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 - -: file-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 - -: file-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. -: -: Note that there is an optional trailing blank line in the regex that matches -: the newline added by msvcrt as a part of the error description. -: -$c <'$* -d a &a'; -$b 2>>~%EOE% != 0 -%error: unable to remove file test[/\\]1[/\\]a: .+% -%%? -EOE - -: dir-not-exists -: -: Test cleanup of non-existing directory. -: -$c <'$* &a/'; -$b 2>>~%EOE% != 0 -%testscript:1: error: registered for cleanup directory test[/\\]1[/\\]a[/\\] does not exist% -EOE - -: dir-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 - -: dir-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 - -: dir-not-empty -: -: Test cleanup of a non-empty directory. -: -$c <'$* -d a -f a/b &a/'; -$b 2>>~%EOE% != 0 -%testscript:1: error: registered for cleanup directory test[/\\]1[/\\]a[/\\] is not empty% -EOE - -: not-dir -: -: Test cleanup of a file as a directory. -: -: Note that there is an optional trailing blank line in the regex that matches -: the newline added by msvcrt as a part of the error description. -: -$c <'$* -f a &a/'; -$b 2>>~%EOE% != 0 -%error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+% -%%? -EOE - -: wildcard-not-exists -: -: Test cleanup of a wildcard not matching any directory. -: -$c <'$* &a/***'; -$b 2>>~%EOE% != 0 -%testscript:1: error: registered for cleanup wildcard test[/\\]1[/\\]a[/\\]\*\*\* doesn't match a directory% -EOE - -: wildcard-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 - -: wildcard-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 wildcard test[/\\]a[/\\]\*\*\* doesn't match a directory% -EOE - -: wildcard-not-dir -: -: Test cleanup of a file as a wildcard. -: -: Note that there is an optional trailing blank line in the regex that matches -: the newline added by msvcrt as a part of the error description. -: -$c <'$* -f a &a/***'; -$b 2>>~%EOE% != 0 -%error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+% -%%? -EOE - : implicit-overwrite : : Test an implicit cleanup being overwritten with the explicit one, diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test index 7aa4ec0..64b11ea 100644 --- a/tests/test/script/runner/redirect.test +++ b/tests/test/script/runner/redirect.test @@ -6,365 +6,382 @@ b += --no-column -# null-redirect tests. -# -: out-null -: -$c <'$* -o foo >-'; -$b - -: err-null +: null : -$c <'$* -e foo 2>-'; -$b +{ + : out + : + $c <'$* -o foo >-'; + $b -# Here-string tests. -# -: in-str -: -$c <'$* -i 0 <foo'; -$b + : err + : + $c <'$* -e foo 2>-'; + $b +} -: out-str +: str : -$c <'$* -o foo >foo'; -$b +{ + : in + : + $c <'$* -i 0 <foo'; + $b -: err-str -: -$c <'$* -e foo 2>foo'; -$b + : out + : + $c <'$* -o foo >foo'; + $b -: inout-str -: -$c <'$* -i 1 <foo >foo'; -$b + : err + : + $c <'$* -e foo 2>foo'; + $b -: inout-str-fail -: -$c <'$* -i 1 <foo >bar'; -$b 2>>~%EOE% != 0 -%testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the expected output% -% 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 - -: inerr-str -: -$c <'$* -i 2 <foo 2>foo'; -$b + : inout + : + $c <'$* -i 1 <foo >foo'; + $b -: inout-err-str -: -$c <'$* -i 1 -e bar <foo 1>foo 2>bar'; -$b + : inout-fail + : + $c <'$* -i 1 <foo >bar'; + $b 2>>~%EOE% != 0 + %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the expected output% + % 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 -# Here-document tests. -# -: in-doc -: -$c <<EOI; -$* -i 0 <<EOO -foo -bar -EOO -EOI -$b - -: out-doc -: -$c <<EOI; -$* -o foo -o bar >>EOO -foo -bar -EOO -EOI -$b - -: err-doc -: -$c <<EOI; -$* -e foo -e bar 2>>EOO -foo -bar -EOO -EOI -$b - -: inout-doc -: -$c <<EOI; -$* -i 1 <<EOF >>EOO -foo -bar -EOF -foo -bar -EOO -EOI -$b - -: inerr-doc -: -$c <<EOI; -$* -i 2 <<EOF 2>>EOE -foo -bar -EOF -foo -bar -EOE -EOI -$b - -: empty-str-doc -: -$c <<EOI; -$* -i 1 -e "" <<EOF >>EOO 2>"" -EOF -EOO -EOI -$b - -: nl-containing-doc -: -$c <<EOI; -$* -i 1 <<EOF >>EOO + : inerr + : + $c <'$* -i 2 <foo 2>foo'; + $b -EOF + : inout-err + : + $c <'$* -i 1 -e bar <foo 1>foo 2>bar'; + $b -EOO -EOI -$b + : empty + : + $c <'$* -o "" >""'; + $b -: doc-fail-largediff -: -: Make sure that the large (>4KB) expected/real output difference is not -: printed as a part of diagnostics. -: -$c <<EOI; -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$s"; -$* -i 1 <<"EOF" >>"EOO" -$s -EOF -x$s -EOO -EOI -$b 2>>~%EOE% != 0 -%testscript:3: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the expected output% -% 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 - -# No-newline tests. -# -: no-newline-str -: -$c <'$* -i 1 <:"foo" >:"foo"'; -$b + : no-newline + : + $c <'$* -i 1 <:"foo" >:"foo"'; + $b -: no-newline-empty-str -: -$c <'$* -i 1 <:"" >:""'; -$b + : no-newline-empty + : + $c <'$* -i 1 <:"" >:""'; + $b -: no-newline-str-fail1 -: -$c <'$* -i 1 <:"foo" >"foo"'; -$b 2>>~/EOE/ != 0 -/testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ -/.{7} --foo -+foo -\ No newline at end of file -EOE - -: no-newline-str-fail2 -: -$c <'$* -i 1 <"foo" >:"foo"'; -$b 2>>~/EOE/ != 0 -/testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ -/.{7} --foo -\ No newline at end of file -+foo -EOE - -: no-newline-doc -: -$c <<EOI; -$* -i 1 <<:EOF >>:EOO -foo -EOF -foo -EOO -EOI -$b - -: no-newline-doc-fail1 -: -$c <<EOI; -$* -i 1 <<:EOF >>EOO -foo -EOF -foo -EOO -EOI -$b 2>>~/EOE/ != 0 -/testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ -/.{7} --foo -+foo -\ No newline at end of file -EOE - -: no-newline-doc-fail2 -: -$c <<EOI; -$* -i 1 <<EOF >>:EOO -foo -EOF -foo -EOO -EOI -$b 2>>~/EOE/ != 0 -/testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ -/.{7} --foo -\ No newline at end of file -+foo -EOE - -: no-newline-empty-str-doc -: -$c <<EOI; -$* -i 1 <<:EOF >>:EOO 2>:"" -EOF -EOO -EOI -$b - -: no-newline-nl-cont-doc -: -$c <<EOI; -$* -i 1 <<:EOF >>:EOO + : no-newline-fail1 + : + $c <'$* -i 1 <:"foo" >"foo"'; + $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ + /.{7} + -foo + +foo + \ No newline at end of file + EOE -EOF + : no-newline-fail2 + : + $c <'$* -i 1 <"foo" >:"foo"'; + $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ + /.{7} + -foo + \ No newline at end of file + +foo + EOE -EOO -EOI -$b + : merge + : + $c <<EOI; + $* -o foo -e bar 2>>EOE 1>&2 + foo + bar + EOE + EOI + $b +} -# Merge tests. -# -: merge-str -: -$c <<EOI; -$* -o foo -e bar 2>>EOE 1>&2 -foo -bar -EOE -EOI -$b - -: merge-doc -: -$c <<EOI; -$* -i 1 <<EOF -e baz >>EOO 2>&1 -foo -bar -EOF -foo -bar -baz -EOO -EOI -$b - -# File tests. -# -: file -: -$c <<EOI; -$* -o foo >>>out; -$* -e bar 2>>>&out; -$* -i 1 <<<out >>EOO -foo -bar -EOO -EOI -$b - -: merge-file -: -$c <<EOI; -$* -o foo -e bar 2>&1 >>>out; -$* -e baz -o biz 1>&2 2>>>&out; -$* -i 1 <<<out >>EOO -foo -bar -baz -biz -EOO -EOI -$b - -# Regex tests. -# -: out-str-regex +: doc : { - : match + : in + : + $c <<EOI; + $* -i 0 <<EOO + foo + bar + EOO + EOI + $b + + : out + : + $c <<EOI; + $* -o foo -o bar >>EOO + foo + bar + EOO + EOI + $b + + : err : - $c <'$* -o foo >~/Foo?/i'; + $c <<EOI; + $* -e foo -e bar 2>>EOO + foo + bar + EOO + EOI + $b + + : inout + : + $c <<EOI; + $* -i 1 <<EOF >>EOO + foo + bar + EOF + foo + bar + EOO + EOI + $b + + : inerr + : + $c <<EOI; + $* -i 2 <<EOF 2>>EOE + foo + bar + EOF + foo + bar + EOE + EOI + $b + + : empty + : + $c <<EOI; + $* -i 1 <<EOF >>EOO + EOF + EOO + EOI + $b + + : extra-newline + : + $c <<EOI; + $* -i 1 <<EOF >>EOO + + EOF + + EOO + EOI + $b + + : no-newline + : + $c <<EOI; + $* -i 1 <<:EOF >>:EOO + foo + EOF + foo + EOO + EOI + $b + + : no-newline-fail1 + : + $c <<EOI; + $* -i 1 <<:EOF >>EOO + foo + EOF + foo + EOO + EOI + $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ + /.{7} + -foo + +foo + \ No newline at end of file + EOE + + : no-newline-fail2 + : + $c <<EOI; + $* -i 1 <<EOF >>:EOO + foo + EOF + foo + EOO + EOI + $b 2>>~/EOE/ != 0 + /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ + /.{7} + -foo + \ No newline at end of file + +foo + EOE + + : no-newline-empty + : + $c <<EOI; + $* -i 1 <<:EOF >>:EOO + EOF + EOO + EOI + $b + + : no-newline-extra-newline + : + $c <<EOI; + $* -i 1 <<:EOF >>:EOO + + EOF + + EOO + EOI + $b + + : merge + : + $c <<EOI; + $* -i 1 <<EOF -e baz >>EOO 2>&1 + foo + bar + EOF + foo + bar + baz + EOO + EOI $b - : fail + : large-diff + : + : Make sure that the large (>4KB) expected/real output difference is not + : printed as a part of the diagnostics. : - $c <'$* -o fooo >~/Foo?/i'; + $c <<EOI; + 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$s"; + $* -i 1 <<"EOF" >>"EOO" + $s + EOF + x$s + EOO + EOI $b 2>>~%EOE% != 0 - %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the regex% + %testscript:3: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the expected output% % info: stdout: test[/\\]1[/\\]stdout% - % info: stdout regex: test[/\\]1[/\\]stdout\.regex% + % info: expected stdout: test[/\\]1[/\\]stdout\.orig% + % info: stdout diff: test[/\\]1[/\\]stdout\.diff% + % info: stdin: test[/\\]1[/\\]stdin% EOE } -: out-doc-regex +: file : { - : match + : in-out : $c <<EOI; - $* -o foo -o foo -o bar >>~/EOO/i - /FO*/* + $* -o foo >>>out; + $* -i 1 <<<out >foo + EOI + $b + + : append + : + $c <<EOI; + $* -o foo >>>out; + $* -e bar 2>>>&out; + $* -i 1 <<<out >>EOO + foo bar - /* EOO EOI $b - : match-empty + : merge : $c <<EOI; - $* >>:~/EOO/i - /.{0} + $* -o foo -e bar 2>&1 >>>out; + $* -e baz -o biz 1>&2 2>>>&out; + $* -i 1 <<<out >>EOO + foo + bar + baz + biz EOO EOI $b } -# Builtins redirects. -# +: regex +: +{ + : str + : + { + : match + : + $c <'$* -o foo >~/Foo?/i'; + $b + + : mismatch + : + $c <'$* -o fooo >~/Foo?/i'; + $b 2>>~%EOE% != 0 + %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? stdout doesn't match the regex% + % info: stdout: test[/\\]1[/\\]stdout% + % info: stdout regex: test[/\\]1[/\\]stdout\.regex% + EOE + } + + : doc + : + { + : match + : + $c <<EOI; + $* -o foo -o foo -o bar >>~/EOO/i + /FO*/* + bar + /* + EOO + EOI + $b + + : match-empty + : + $c <<EOI; + $* >>:~/EOO/i + /.{0} + EOO + EOI + $b + } +} + # @@ That will probably become redundant when builtins and process obtain file # descriptors uniformly. # diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test index f12cd58..0daa8c7 100644 --- a/tests/test/script/runner/status.test +++ b/tests/test/script/runner/status.test @@ -6,33 +6,37 @@ b += --no-column -# Successfull tests. -# -: eq-true +: eq : -$c <'$* == 0'; -$b - -: ne-true -: -$c <'$* -s 1 != 0'; -$b - -# Faulty tests. -# -: eq-false -: -$c <'$* -s 1 == 0'; -$b 2>>~%EOE% != 0 -%testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 != 0% -EOE - -: ne-false +{ + : true + : + $c <'$* == 0'; + $b + + : false + : + $c <'$* -s 1 == 0'; + $b 2>>~%EOE% != 0 + %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 != 0% + EOE +} + +: ne : -$c <'$* -s 1 != 1'; -$b 2>>~%EOE% != 0 -%testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 == 1% -EOE +{ + : true + : + $c <'$* -s 1 != 0'; + $b + + : false + : + $c <'$* -s 1 != 1'; + $b 2>>~%EOE% != 0 + %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 == 1% + EOE +} : error : diff --git a/unit-tests/function/call.test b/unit-tests/function/call.test index 5584c15..f3b59b9 100644 --- a/unit-tests/function/call.test +++ b/unit-tests/function/call.test @@ -140,7 +140,7 @@ EOE : member-function : -$* <'print $dummy.length([string] abc)' >'3' +$* <'print $dummy.length([path] abc)' >'3' : data-member : diff --git a/unit-tests/function/driver.cxx b/unit-tests/function/driver.cxx index 235af0c..9e50973 100644 --- a/unit-tests/function/driver.cxx +++ b/unit-tests/function/driver.cxx @@ -45,8 +45,8 @@ namespace build2 f[".qual"] = []() {return "abc";}; - f[".length"] = &string::size; // Member function. - f[".type"] = &name::type; // Data member. + f[".length"] = &path::size; // Member function. + f[".type"] = &name::type; // Data member. f[".abs"] = [](dir_path d) {return d.absolute ();}; |