From 7cf026b8989a71a0d0e775e21e697ba9f1bee987 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Jan 2017 23:31:45 +0300 Subject: Move builtin and runner tests to '$c ... && $b' pattern --- tests/test/script/runner/cleanup.test | 81 +++++----------- tests/test/script/runner/redirect.test | 170 +++++++++------------------------ tests/test/script/runner/regex.test | 87 +++++------------ tests/test/script/runner/status.test | 18 ++-- 4 files changed, 102 insertions(+), 254 deletions(-) (limited to 'tests/test/script/runner') diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test index 1c3ccae..7b3539b 100644 --- a/tests/test/script/runner/cleanup.test +++ b/tests/test/script/runner/cleanup.test @@ -6,26 +6,20 @@ b += --no-column -# @@ TODO: $c <'$* -f a &a' && $b -# - : file : { : always : - $c <'$* -f a &a'; - $b + $c <'$* -f a &a' && $b : maybe : - $c <'$* &?a'; - $b + $c <'$* &?a' && $b : never : - $c <'$* &!a'; - $b + $c <'$* &!a' && $b : implicit : @@ -33,30 +27,27 @@ b += --no-column : 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 + $c <'$* &a' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup file test/1/a does not exist EOE @@ -64,8 +55,7 @@ b += --no-column : : Test explicit cleanup of a file out of the testscript working directory. : - $c <'$* &../../a'; - $b 2>>/EOE != 0 + $c <'$* &../../a' && $b 2>>/EOE != 0 testscript:1: error: file cleanup ../../a is out of working directory test/ EOE @@ -74,8 +64,7 @@ b += --no-column : 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 + $c <'$* &../a' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup file test/a does not exist EOE @@ -83,8 +72,7 @@ b += --no-column : : Test cleanup of a directory as a file. : - $c <'$* -d a &a'; - $b 2>>/~%EOE% != 0 + $c <'$* -d a &a' && $b 2>>/~%EOE% != 0 %error: unable to remove file test/1/a: .+% EOE } @@ -94,13 +82,11 @@ b += --no-column { : always : - $c <'$* -d a &a/'; - $b + $c <'$* -d a &a/' && $b : maybe : - $c <'$* &?a/'; - $b + $c <'$* &?a/' && $b : implicit : @@ -108,18 +94,16 @@ b += --no-column : not implicitly registered for cleanup. If it were, the test would fail due : to the directory absence at the cleanup time. : - $c <>/EOE != 0 + $c <'$* &a/' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup directory test/1/a/ does not exist EOE @@ -127,8 +111,7 @@ b += --no-column : : Test cleanup of a directory out of the testscript working directory. : - $c <'$* &../../a/'; - $b 2>>/EOE != 0 + $c <'$* &../../a/' && $b 2>>/EOE != 0 testscript:1: error: directory cleanup ../../a/ is out of working directory test/ EOE @@ -137,8 +120,7 @@ b += --no-column : 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 + $c <'$* &../a/' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup directory test/a/ does not exist EOE @@ -146,8 +128,7 @@ b += --no-column : : Test cleanup of a non-empty directory. : - $c <'$* -d a -f a/b &a/'; - $b 2>>/EOE != 0 + $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 @@ -155,8 +136,7 @@ b += --no-column : : Test cleanup of a file as a directory. : - $c <'$* -f a &a/'; - $b 2>>/~%EOE% != 0 + $c <'$* -f a &a/' && $b 2>>/~%EOE% != 0 %error: unable to remove directory test/1/a/: .+% EOE } @@ -166,20 +146,17 @@ b += --no-column { : always : - $c <'$* -d a/b -f a/b/c &a/***'; - $b + $c <'$* -d a/b -f a/b/c &a/***' && $b : maybe : - $c <'$* &?a/***'; - $b + $c <'$* &?a/***' && $b : not-exists : : Test cleanup of a wildcard not matching any directory. : - $c <'$* &a/***'; - $b 2>>/EOE != 0 + $c <'$* &a/***' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup wildcard test/1/a/*** doesn't match a directory EOE @@ -187,8 +164,7 @@ b += --no-column : : Test cleanup of a wildcard out of the testscript working directory. : - $c <'$* &../../a/***'; - $b 2>>/EOE != 0 + $c <'$* &../../a/***' && $b 2>>/EOE != 0 testscript:1: error: wildcard cleanup ../../a/*** is out of working directory test/ EOE @@ -198,8 +174,7 @@ b += --no-column : outside the test working directory is inside the testscript working : directory. : - $c <'$* &../a/***'; - $b 2>>/EOE != 0 + $c <'$* &../a/***' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup wildcard test/a/*** doesn't match a directory EOE @@ -207,8 +182,7 @@ b += --no-column : : Test cleanup of a file as a wildcard. : - $c <'$* -f a &a/***'; - $b 2>>/~%EOE% != 0 + $c <'$* -f a &a/***' && $b 2>>/~%EOE% != 0 %error: unable to remove directory test/1/a/: .+% EOE } @@ -217,15 +191,13 @@ b += --no-column : : Test that cleanup is performed in registration reversed order. : -$c <'$* -d a/b &a/ &a/b/'; -$b +$c <'$* -d a/b &a/ &a/b/' && $b : implicit-overwrite : : Test an implicit cleanup being overwritten with the explicit one, : -$c <'$* -o foo >=a &!a'; -$b 2>>/EOE != 0 +$c <'$* -o foo >=a &!a' && $b 2>>/EOE != 0 testscript:1: error: registered for cleanup directory test/1/ is not empty EOE @@ -233,10 +205,9 @@ EOE : : Test an explicit cleanup not being overwritten with the implicit one. : -$c <>/EOE != 0 $* &!a; $* -o foo >=a EOO -$b 2>>/EOE != 0 testscript:2: error: registered for cleanup directory test/1/ is not empty EOE diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test index cfc12c5..3cd6c69 100644 --- a/tests/test/script/runner/redirect.test +++ b/tests/test/script/runner/redirect.test @@ -12,7 +12,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : pass : { - $c <'$* -i 1 -e bar <| >| 2>|'; + cat <'$* -i 1 -e bar <| >| 2>|' >=testscript; cat <=buildfile; test{testscript}: $target EOI @@ -22,15 +22,8 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : null : { - : out - : - $c <'$* -o foo >-'; - $b - - : err - : - $c <'$* -e foo 2>-'; - $b + $c <'$* -o foo >-' && $b : out + $c <'$* -e foo 2>-' && $b : err } : str @@ -39,25 +32,10 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : literal : { - : in - : - $c <'$* -i 0 foo'; - $b - - : err - : - $c <'$* -e foo 2>foo'; - $b - - : inout - : - $c <'$* -i 1 foo'; - $b + $c <'$* -i 0 foo' && $b : out + $c <'$* -e foo 2>foo' && $b : err + $c <'$* -i 1 foo' && $b : inout : inout-fail : @@ -75,30 +53,11 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. +foo EOE - : inerr - : - $c <'$* -i 2 foo'; - $b - - : inout-err - : - $c <'$* -i 1 -e bar foo 2>bar'; - $b - - : empty - : - $c <'$* -o "" >""'; - $b - - : no-newline - : - $c <'$* -i 1 <:"foo" >:"foo"'; - $b - - : no-newline-empty - : - $c <'$* -i 1 <:"" >:""'; - $b + $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 : @@ -124,31 +83,19 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : merge : - $c <>EOE 1>&2 foo bar EOE EOI - $b : portable-path : { - : in - : - $c <"\$* -i 1 'foo$ps'"; - $b - - : out - : - $c <"\$* -i 1 <'foo$ps' >/'foo/'"; - $b - - : err - : - $c <"\$* -i 2 <'foo$ps' 2>/'foo/'"; - $b + $c <"\$* -i 1 'foo$ps'" && $b : in + $c <"\$* -i 1 <'foo$ps' >/'foo/'" && $b : out + $c <"\$* -i 2 <'foo$ps' 2>/'foo/'" && $b : err } } @@ -211,37 +158,34 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : in : - $c <>EOO foo bar EOO EOI - $b : err : - $c <>EOO foo bar EOO EOI - $b : inout : - $c <>EOO foo bar @@ -250,11 +194,10 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. bar EOO EOI - $b : inerr : - $c <>EOE foo bar @@ -263,59 +206,53 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. bar EOE EOI - $b : empty : - $c <>EOO EOF EOO EOI - $b : shared : - $c <>EOF foo bar EOF EOI - $b : extra-newline : - $c <>EOO EOF EOO EOI - $b : no-newline : - $c <>:EOO foo EOF foo EOO EOI - $b : no-newline-fail1 : - $c <>~/EOE/ != 0 $* -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 @@ -325,14 +262,13 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : no-newline-fail2 : - $c <>~/EOE/ != 0 $* -i 1 <>:EOO foo EOF foo EOO EOI - $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo @@ -342,27 +278,25 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : 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 @@ -372,23 +306,21 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. baz EOO EOI - $b : 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 - $b 2>>/~%EOE%d != 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 @@ -401,30 +333,27 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : in : - $c <<"EOI"; + $c <<"EOI" && $b \$* -i 1 <'foo$ps' foo/ EOF EOI - $b : out : - $c <<"EOI"; + $c <<"EOI" && $b \$* -i 1 <'foo$ps' >>/EOO foo/ EOO EOI - $b : err : - $c <<"EOI"; + $c <<"EOI" && $b \$* -i 2 <'foo$ps' 2>>/EOE foo/ EOE EOI - $b } } @@ -436,41 +365,37 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : match : - $c <>~/EOO/i /FO*/* bar /* EOO EOI - $b : match-empty : - $c <>:~/EOO/ /.{0} EOO EOI - $b : shared : - $c <>~/EOF/ 2>>~/EOF/ foo EOF EOI - $b : mismatch : - $c <>/~%EOE%d != 0 $* -o foo >>~/EOO/ bar EOO EOI - $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex @@ -478,12 +403,11 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : mismatch-icase : - $c <>/~%EOE%d != 0 $* -o foo >>~/EOO/i bar EOO EOI - $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../../driver(.exe)? stdout doesn't match the regex% info: stdout: test/1/stdout info: stdout regex: test/1/stdout.regex~i @@ -496,18 +420,17 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : in : - $c <=out; $* -i 1 <<foo EOI - $b : out : { : match : - $c <=out; $* -e bar 2>+out; $* -i 1 <>>out @@ -515,15 +438,13 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. bar EOF EOI - $b : mismatch : - $c <>/~%EOE%d != 0 $* -o foo >=out; $* -o bar >>>out EOI - $b 2>>/~%EOE%d != 0 %testscript:2: error: ../../../../../driver(.exe)? stdout doesn't match the expected output% info: stdout: test/1/stdout-2 info: expected stdout: test/1/out @@ -538,7 +459,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : merge : - $c <&1 >=out; $* -e baz -o biz 1>&2 2>+out; $* -i 1 <<>EOO @@ -548,5 +469,4 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. biz EOO EOI - $b } diff --git a/tests/test/script/runner/regex.test b/tests/test/script/runner/regex.test index f4863b1..413069c 100644 --- a/tests/test/script/runner/regex.test +++ b/tests/test/script/runner/regex.test @@ -23,20 +23,9 @@ : str : { - : out - : - $c <'cat ~/fo./'; - $b - - : err - : - $c <'cat &2 2>~/fo./'; - $b - - : no-newline - : - $c <'cat <:foo >:~/fo./'; - $b + $c <'cat ~/fo./' && $b : out + $c <'cat &2 2>~/fo./' && $b : err + $c <'cat <:foo >:~/fo./' && $b : no-newline : malformed : @@ -55,34 +44,31 @@ { : out : - $c <>~/EOO/ /foo/ EOO EOI - $b : err : - $c <&2 2>>~/EOO/ /fo./ EOO EOI - $b : no-newline : - $c <>:~/EOO/ /fo./ EOO EOI - $b : line-char : - $c <>~/EOO/ foo bar @@ -107,11 +93,10 @@ //{2} EOO EOI - $b : expansion : - $c <>EOE != 0 $* -o foo >>~/EOO/ /x EOO EOI - $b 2>>EOE != 0 testscript:2:3: error: invalid syntax character 'x' in stdout regex redirect info: regex line: '/x' EOE : invalid-char-regex : - $c <>~/EOE/ != 0 $* -o foo >>~/EOO/ /foo[/ EOO EOI - $b 2>>~/EOE/ != 0 /testscript:2:3: error: invalid char-regex in stdout regex redirect.*/ info: regex line: '/foo[/' EOE : invalid-line-regex : - $c <>/~%EOE% != 0 $* -o foo >>~/EOO/ a /{ EOO EOI - $b 2>>/~%EOE% != 0 %testscript:4:3: error: invalid stdout regex redirect.*% info: stdout regex: test/1/stdout.regex EOE @@ -174,8 +155,7 @@ { : i : - $c <'cat ~/foo/i'; - $b + $c <'cat ~/foo/i' && $b : d : @@ -185,15 +165,13 @@ : Escaped dot becomes syntax dot and matches any character ('i' in our : case). : - $c <'cat ~/f\\.o/d'; - $b + $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 + $c <'cat ~/f.o/d' && $b 2>>~/EOE/ != 0 testscript:1:1: error: cat stdout doesn't match the regex /.+ EOE @@ -204,12 +182,11 @@ { : i : - $c <>~/EOO/ /foo/i EOO EOI - $b : d : @@ -219,21 +196,19 @@ { : escaped-dot : - $c <>~/EOO/ /f\.o/d EOO EOI - $b : syntax-dot : - $c <>~/EOE/ != 0 cat >~/EOO/ /f.o/d EOO EOI - $b 2>>~/EOE/ != 0 testscript:1:1: error: cat stdout doesn't match the regex /.+ EOE @@ -244,33 +219,30 @@ { : i : - $c <>~/EOO/i /foo/ EOO EOI - $b : d : { : escaped-dot : - $c <>~/EOO/d /f\.o/ EOO EOI - $b : syntax-dot : - $c <>~/EOE/ != 0 cat >~/EOO/d /f.o/ EOO EOI - $b 2>>~/EOE/ != 0 testscript:1:1: error: cat stdout doesn't match the regex /.+ EOE @@ -287,35 +259,26 @@ : str : { - : out - : - $c <"cat <'foo$ps' >/~%foo/%"; - $b - - : err - : - $c <"cat <'foo$ps' >/~%foo/%"; - $b + $c <"cat <'foo$ps' >/~%foo/%" && $b : out + $c <"cat <'foo$ps' 1>&2 2>/~%foo/%" && $b : err } : doc { : out : - $c <<"EOI"; + $c <<"EOI" && $b cat <'foo$ps' >>/~%EOO% foo/ EOO EOI - $b : err : - $c <<"EOI"; - cat <'foo$ps' >>/~%EOO% + $c <<"EOI" && $b + cat <'foo$ps' 1>&2 2>>/~%EOO% foo/ EOO EOI - $b } } diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test index c1df3e4..67ce3ae 100644 --- a/tests/test/script/runner/status.test +++ b/tests/test/script/runner/status.test @@ -11,13 +11,11 @@ b += --no-column { : true : - $c <'$* == 0'; - $b + $c <'$* == 0' && $b : false : - $c <'$* -s 1 == 0'; - $b 2>>/~%EOE%d != 0 + $c <'$* -s 1 == 0' && $b 2>>/~%EOE%d != 0 %testscript:1: error: ../../../../driver(.exe)? exit status 1 != 0% EOE } @@ -27,21 +25,18 @@ b += --no-column { : true : - $c <'$* -s 1 != 0'; - $b + $c <'$* -s 1 != 0' && $b : false : - $c <'$* -s 1 != 1'; - $b 2>>/~%EOE% != 0 + $c <'$* -s 1 != 1' && $b 2>>/~%EOE% != 0 %testscript:1: error: ../../../../driver(.exe)? exit status 1 == 1% EOE } : error : -$c <'$* -s 1 -e "Error"'; -$b 2>>/~%EOE% != 0 +$c <'$* -s 1 -e "Error"' && $b 2>>/~%EOE% != 0 %testscript:1: error: ../../../driver(.exe)? exit status 1 != 0% info: stderr: test/1/stderr Error @@ -53,8 +48,7 @@ EOE : 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 +$c <'$* -t m' && $b 2>>/~%EOE% != 0 %wine: .+%? %testscript:1: error: ../../../driver(.exe)? terminated abnormally%d % info: .+% -- cgit v1.1