From b917233d4b618d587f569706d8d528b051efdba4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 31 Dec 2016 03:14:50 +0300 Subject: Tests cleanup --- tests/test/script/runner/cleanup.test | 414 +++++++++++---------- tests/test/script/runner/redirect.test | 647 +++++++++++++++++---------------- tests/test/script/runner/status.test | 54 +-- 3 files changed, 573 insertions(+), 542 deletions(-) (limited to 'tests/test/script/runner') 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 <>>&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 <>>&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 <>~%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 -'; + $b +} -: out-str +: str : -$c <'$* -o foo >foo'; -$b +{ + : in + : + $c <'$* -i 0 foo'; -$b + : out + : + $c <'$* -o foo >foo'; + $b -: inout-str -: -$c <'$* -i 1 foo'; -$b + : err + : + $c <'$* -e foo 2>foo'; + $b -: inout-str-fail -: -$c <'$* -i 1 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'; -$b + : inout + : + $c <'$* -i 1 foo'; + $b -: inout-err-str -: -$c <'$* -i 1 -e bar foo 2>bar'; -$b + : inout-fail + : + $c <'$* -i 1 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 <>EOO -foo -bar -EOO -EOI -$b - -: err-doc -: -$c <>EOO -foo -bar -EOO -EOI -$b - -: inout-doc -: -$c <>EOO -foo -bar -EOF -foo -bar -EOO -EOI -$b - -: inerr-doc -: -$c <>EOE -foo -bar -EOF -foo -bar -EOE -EOI -$b - -: empty-str-doc -: -$c <>EOO 2>"" -EOF -EOO -EOI -$b - -: nl-containing-doc -: -$c <>EOO + : inerr + : + $c <'$* -i 2 foo'; + $b -EOF + : inout-err + : + $c <'$* -i 1 -e bar 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 <>"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 <>:EOO -foo -EOF -foo -EOO -EOI -$b - -: no-newline-doc-fail1 -: -$c <>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 <>: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 <>:EOO 2>:"" -EOF -EOO -EOI -$b - -: no-newline-nl-cont-doc -: -$c <>: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 <>EOE 1>&2 + foo + bar + EOE + EOI + $b +} -# Merge tests. -# -: merge-str -: -$c <>EOE 1>&2 -foo -bar -EOE -EOI -$b - -: merge-doc -: -$c <>EOO 2>&1 -foo -bar -EOF -foo -bar -baz -EOO -EOI -$b - -# File tests. -# -: file -: -$c <>>out; -$* -e bar 2>>>&out; -$* -i 1 <<>EOO -foo -bar -EOO -EOI -$b - -: merge-file -: -$c <&1 >>>out; -$* -e baz -o biz 1>&2 2>>>&out; -$* -i 1 <<>EOO -foo -bar -baz -biz -EOO -EOI -$b - -# Regex tests. -# -: out-str-regex +: doc : { - : match + : in + : + $c <>EOO + foo + bar + EOO + EOI + $b + + : err : - $c <'$* -o foo >~/Foo?/i'; + $c <>EOO + foo + bar + EOO + EOI + $b + + : inout + : + $c <>EOO + foo + bar + EOF + foo + bar + EOO + EOI + $b + + : inerr + : + $c <>EOE + foo + bar + EOF + foo + bar + EOE + EOI + $b + + : empty + : + $c <>EOO + EOF + EOO + EOI + $b + + : extra-newline + : + $c <>EOO + + EOF + + EOO + EOI + $b + + : no-newline + : + $c <>:EOO + foo + EOF + foo + EOO + EOI + $b + + : no-newline-fail1 + : + $c <>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 <>: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 <>:EOO + EOF + EOO + EOI + $b + + : no-newline-extra-newline + : + $c <>:EOO + + EOF + + EOO + EOI + $b + + : merge + : + $c <>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 <>"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 <>~/EOO/i - /FO*/* + $* -o foo >>>out; + $* -i 1 <<foo + EOI + $b + + : append + : + $c <>>out; + $* -e bar 2>>>&out; + $* -i 1 <<>EOO + foo bar - /* EOO EOI $b - : match-empty + : merge : $c <>:~/EOO/i - /.{0} + $* -o foo -e bar 2>&1 >>>out; + $* -e baz -o biz 1>&2 2>>>&out; + $* -i 1 <<>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 <>~/EOO/i + /FO*/* + bar + /* + EOO + EOI + $b + + : match-empty + : + $c <>:~/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 : -- cgit v1.1