aboutsummaryrefslogtreecommitdiff
path: root/tests/test/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-01-11 01:43:09 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-19 17:56:07 +0300
commita83f3866667bca073c4d4c5d80b4deb5ac05906c (patch)
tree479464203f6be4535c8f165a20d21322a88a2751 /tests/test/script
parentba99b60aeb8ccdeffc777589b99728395cd28f95 (diff)
Add support for portable path modifer and dot character escaping inversion
Diffstat (limited to 'tests/test/script')
-rw-r--r--tests/test/script/builtin/cat.test4
-rw-r--r--tests/test/script/builtin/mkdir.test8
-rw-r--r--tests/test/script/builtin/rm.test8
-rw-r--r--tests/test/script/runner/buildfile2
-rw-r--r--tests/test/script/runner/cleanup.test60
-rw-r--r--tests/test/script/runner/driver.cxx1
-rw-r--r--tests/test/script/runner/redirect.test684
-rw-r--r--tests/test/script/runner/regex.test321
-rw-r--r--tests/test/script/runner/status.test18
9 files changed, 773 insertions, 333 deletions
diff --git a/tests/test/script/builtin/cat.test b/tests/test/script/builtin/cat.test
index 89301cd..f5041fc 100644
--- a/tests/test/script/builtin/cat.test
+++ b/tests/test/script/builtin/cat.test
@@ -60,8 +60,8 @@ $b
: non-existent
:
$c <<EOI;
-cat in 2>>~%EOE% != 0
-%cat: unable to print '.+[/\\]test[/\\]cat[/\\]non-existent[/\\]test[/\\]1[/\\]in': .+%
+cat in 2>>/~%EOE% != 0
+%cat: unable to print '.+/test/cat/non-existent/test/1/in': .+%
EOE
EOI
$b
diff --git a/tests/test/script/builtin/mkdir.test b/tests/test/script/builtin/mkdir.test
index 8ad2714..ace4012 100644
--- a/tests/test/script/builtin/mkdir.test
+++ b/tests/test/script/builtin/mkdir.test
@@ -56,8 +56,8 @@ $b
: Test creation of an existing directory.
:
$c <<EOI;
-mkdir a a 2>>~%EOE% == 1
-%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]already-exists[/\\]test[/\\]1[/\\]a': .+%
+mkdir a a 2>>/~%EOE% == 1
+%mkdir: unable to create directory '.+/test/mkdir/already-exists/test/1/a': .+%
EOE
EOI
$b
@@ -67,8 +67,8 @@ $b
: Test creation of a directory with non-existent parent.
:
$c <<EOI;
-mkdir a/b 2>>~%EOE% == 1
-%mkdir: unable to create directory '.+[/\\]test[/\\]mkdir[/\\]not-exists[/\\]test[/\\]1[/\\]a[/\\]b': .+%
+mkdir a/b 2>>/~%EOE% == 1
+%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 cd4a922..a6de003 100644
--- a/tests/test/script/builtin/rm.test
+++ b/tests/test/script/builtin/rm.test
@@ -40,8 +40,8 @@
: Removing non-existing file fails.
:
$c <<EOI;
- rm a 2>>~%EOE% == 1
- %rm: unable to remove '.+[/\\]test[/\\]rm[/\\]file[/\\]not-exists[/\\]test[/\\]1[/\\]a': .+%
+ rm a 2>>/~%EOE% == 1
+ %rm: unable to remove '.+/test/rm/file/not-exists/test/1/a': .+%
EOE
EOI
$b
@@ -106,8 +106,8 @@
:
:
$c <<EOI;
- rm ../../a/b/c 2>>~%EOE% == 1
- %rm: '.+[/\\]path[/\\]outside-scope[/\\]a[/\\]b[/\\]c' is out of working directory '.+[/\\]outside-scope[/\\]test'%
+ rm ../../a/b/c 2>>/~%EOE% == 1
+ %rm: '.+/path/outside-scope/a/b/c' is out of working directory '.+/outside-scope/test'%
EOE
EOI
$b
diff --git a/tests/test/script/runner/buildfile b/tests/test/script/runner/buildfile
index 1ea8643..86c18e2 100644
--- a/tests/test/script/runner/buildfile
+++ b/tests/test/script/runner/buildfile
@@ -2,7 +2,7 @@
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-./: test{cleanup redirect status} exe{driver} $b
+./: test{cleanup redirect regex status} exe{driver} $b
test{*}: target = exe{driver}
diff --git a/tests/test/script/runner/cleanup.test b/tests/test/script/runner/cleanup.test
index 3dfd73e..ed724ee 100644
--- a/tests/test/script/runner/cleanup.test
+++ b/tests/test/script/runner/cleanup.test
@@ -56,8 +56,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup file test/1/a does not exist
EOE
: out-wd
@@ -65,8 +65,8 @@ b += --no-column
: 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[/\\]%
+ $b 2>>/EOE != 0
+ testscript:1: error: file cleanup ../../a is out of working directory test/
EOE
: in-wd
@@ -75,8 +75,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup file test/a does not exist
EOE
: not-file
@@ -84,8 +84,8 @@ b += --no-column
: Test cleanup of a directory as a file.
:
$c <'$* -d a &a';
- $b 2>>~%EOE% != 0
- %error: unable to remove file test[/\\]1[/\\]a: .+%
+ $b 2>>/~%EOE% != 0
+ %error: unable to remove file test/1/a: .+%
EOE
}
@@ -119,8 +119,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup directory test/1/a/ does not exist
EOE
: out-wd
@@ -128,8 +128,8 @@ b += --no-column
: 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[/\\]%
+ $b 2>>/EOE != 0
+ testscript:1: error: directory cleanup ../../a/ is out of working directory test/
EOE
: in-wd
@@ -138,8 +138,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup directory test/a/ does not exist
EOE
: not-empty
@@ -147,8 +147,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup directory test/1/a/ is not empty
EOE
: not-dir
@@ -156,8 +156,8 @@ b += --no-column
: Test cleanup of a file as a directory.
:
$c <'$* -f a &a/';
- $b 2>>~%EOE% != 0
- %error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+%
+ $b 2>>/~%EOE% != 0
+ %error: unable to remove directory test/1/a/: .+%
EOE
}
@@ -179,8 +179,8 @@ b += --no-column
: 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%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup wildcard test/1/a/*** doesn't match a directory
EOE
: out-wd
@@ -188,8 +188,8 @@ b += --no-column
: 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[/\\]%
+ $b 2>>/EOE != 0
+ testscript:1: error: wildcard cleanup ../../a/*** is out of working directory test/
EOE
: in-wd
@@ -199,8 +199,8 @@ b += --no-column
: directory.
:
$c <'$* &../a/***';
- $b 2>>~%EOE% != 0
- %testscript:1: error: registered for cleanup wildcard test[/\\]a[/\\]\*\*\* doesn't match a directory%
+ $b 2>>/EOE != 0
+ testscript:1: error: registered for cleanup wildcard test/a/*** doesn't match a directory
EOE
: not-dir
@@ -208,8 +208,8 @@ b += --no-column
: Test cleanup of a file as a wildcard.
:
$c <'$* -f a &a/***';
- $b 2>>~%EOE% != 0
- %error: unable to remove directory test[/\\]1[/\\]a[/\\]: .+%
+ $b 2>>/~%EOE% != 0
+ %error: unable to remove directory test/1/a/: .+%
EOE
}
@@ -225,8 +225,8 @@ $b
: Test an implicit cleanup being overwritten with the explicit one,
:
$c <'$* -o foo >>>a &!a';
-$b 2>>~%EOE% != 0
-%testscript:1: error: registered for cleanup directory test[/\\]1[/\\] is not empty%
+$b 2>>/EOE != 0
+testscript:1: error: registered for cleanup directory test/1/ is not empty
EOE
: explicit-overwrite
@@ -237,6 +237,6 @@ $c <<EOO;
$* &!a;
$* -o foo >>>a
EOO
-$b 2>>~%EOE% != 0
-%testscript:2: error: registered for cleanup directory test[/\\]1[/\\] is not empty%
+$b 2>>/EOE != 0
+testscript:2: error: registered for cleanup directory test/1/ is not empty
EOE
diff --git a/tests/test/script/runner/driver.cxx b/tests/test/script/runner/driver.cxx
index 6921e4c..ff91926 100644
--- a/tests/test/script/runner/driver.cxx
+++ b/tests/test/script/runner/driver.cxx
@@ -72,6 +72,7 @@ main (int argc, char* argv[])
optional<int> status;
char aterm ('\0'); // Abnormal termination method.
+ cin.exceptions (ostream::failbit | ostream::badbit);
cout.exceptions (ostream::failbit | ostream::badbit);
cerr.exceptions (ostream::failbit | ostream::badbit);
diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test
index 72e49b2..e2d765c 100644
--- a/tests/test/script/runner/redirect.test
+++ b/tests/test/script/runner/redirect.test
@@ -6,6 +6,9 @@
b += --no-column
+ps = ($cxx.target.class != 'windows' ? '/' : '\') # Path separator.
+psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex.
+
: null
:
{
@@ -23,279 +26,440 @@ b += --no-column
: str
:
{
- : in
+ : literal
:
- $c <'$* -i 0 <foo';
- $b
+ {
+ : in
+ :
+ $c <'$* -i 0 <foo';
+ $b
- : out
- :
- $c <'$* -o foo >foo';
- $b
+ : out
+ :
+ $c <'$* -o foo >foo';
+ $b
- : err
- :
- $c <'$* -e foo 2>foo';
- $b
+ : err
+ :
+ $c <'$* -e foo 2>foo';
+ $b
- : inout
- :
- $c <'$* -i 1 <foo >foo';
- $b
+ : inout
+ :
+ $c <'$* -i 1 <foo >foo';
+ $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
-
- : inerr
- :
- $c <'$* -i 2 <foo 2>foo';
- $b
+ : inout-fail
+ :
+ $c <'$* -i 1 <foo >bar';
+ $b 2>>/~%EOE%d != 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
- : inout-err
- :
- $c <'$* -i 1 -e bar <foo 1>foo 2>bar';
- $b
+ : inerr
+ :
+ $c <'$* -i 2 <foo 2>foo';
+ $b
- : empty
- :
- $c <'$* -o "" >""';
- $b
+ : inout-err
+ :
+ $c <'$* -i 1 -e bar <foo 1>foo 2>bar';
+ $b
- : no-newline
- :
- $c <'$* -i 1 <:"foo" >:"foo"';
- $b
+ : empty
+ :
+ $c <'$* -o "" >""';
+ $b
- : no-newline-empty
- :
- $c <'$* -i 1 <:"" >:""';
- $b
+ : no-newline
+ :
+ $c <'$* -i 1 <:"foo" >:"foo"';
+ $b
- : no-newline-fail1
+ : no-newline-empty
+ :
+ $c <'$* -i 1 <:"" >:""';
+ $b
+
+ : 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
+
+ : 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
+
+ : merge
+ :
+ $c <<EOI;
+ $* -o foo -e bar 2>>EOE 1>&2
+ foo
+ bar
+ EOE
+ EOI
+ $b
+
+ : portable-path
+ :
+ {
+ : in
+ :
+ $c <"\$* -i 1 </'foo/' >'foo$ps'";
+ $b
+
+ : out
+ :
+ $c <"\$* -i 1 <'foo$ps' >/'foo/'";
+ $b
+
+ : err
+ :
+ $c <"\$* -i 2 <'foo$ps' 2>/'foo/'";
+ $b
+ }
+ }
+
+ : regex
:
- $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-fail2
+ : Test regex matching. Note that tests that check regex parsing are located
+ : in regex.test testscript.
:
- $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
+ {
+ : match
+ :
+ $c <'$* -o foo >~/Foo?/i';
+ $b
- : merge
- :
- $c <<EOI;
- $* -o foo -e bar 2>>EOE 1>&2
- foo
- bar
- EOE
- EOI
- $b
+ : mismatch
+ :
+ $c <'$* -o fooo >~/Foo?/i';
+ $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
+ 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 the regex%
+ info: stdout: test/1/stdout
+ info: stdout regex: test/1/stdout.regex
+ info: stdin: test/1/stdin
+ 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 the regex%
+ info: stdout: test/1/stdout
+ info: stdout regex: test/1/stdout.regex
+ info: stdin: test/1/stdin
+ EOE
+ cat test/1/stdout.regex >:"%bar$psr%"
+ }
+ }
}
: doc
:
{
- : in
+ : literal
:
- $c <<EOI;
- $* -i 0 <<EOO
- foo
- bar
- EOO
- EOI
- $b
+ {
+ : in
+ :
+ $c <<EOI;
+ $* -i 0 <<EOO
+ foo
+ bar
+ EOO
+ EOI
+ $b
- : out
- :
- $c <<EOI;
- $* -o foo -o bar >>EOO
- foo
- bar
- EOO
- EOI
- $b
+ : out
+ :
+ $c <<EOI;
+ $* -o foo -o bar >>EOO
+ foo
+ bar
+ EOO
+ EOI
+ $b
- : err
- :
- $c <<EOI;
- $* -e foo -e bar 2>>EOO
- foo
- bar
- EOO
- EOI
- $b
+ : err
+ :
+ $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
+ : 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
+ : 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
+ : empty
+ :
+ $c <<EOI;
+ $* -i 1 <<EOF >>EOO
+ EOF
+ EOO
+ EOI
+ $b
- : extra-newline
- :
- $c <<EOI;
- $* -i 1 <<EOF >>EOO
+ : extra-newline
+ :
+ $c <<EOI;
+ $* -i 1 <<EOF >>EOO
- EOF
+ EOF
- EOO
- EOI
- $b
+ EOO
+ EOI
+ $b
- : no-newline
- :
- $c <<EOI;
- $* -i 1 <<:EOF >>:EOO
- foo
- EOF
- foo
- 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-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-extra-newline
- :
- $c <<EOI;
- $* -i 1 <<:EOF >>:EOO
+ : 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
- EOF
+ : no-newline-empty
+ :
+ $c <<EOI;
+ $* -i 1 <<:EOF >>:EOO
+ EOF
+ EOO
+ EOI
+ $b
- EOO
- EOI
- $b
+ : no-newline-extra-newline
+ :
+ $c <<EOI;
+ $* -i 1 <<:EOF >>:EOO
- : merge
- :
- $c <<EOI;
- $* -i 1 <<EOF -e baz >>EOO 2>&1
- foo
- bar
- EOF
- foo
- bar
- baz
- EOO
- EOI
- $b
+ EOF
+
+ EOO
+ EOI
+ $b
+
+ : merge
+ :
+ $c <<EOI;
+ $* -i 1 <<EOF -e baz >>EOO 2>&1
+ foo
+ bar
+ EOF
+ foo
+ bar
+ baz
+ EOO
+ EOI
+ $b
- : large-diff
+ : large-diff
+ :
+ : Make sure that the large (>4KB) expected/real output difference is not
+ : printed as a part of the 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%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
+ info: stdout diff: test/1/stdout.diff
+ info: stdin: test/1/stdin
+ EOE
+
+ : portable-path
+ :
+ {
+ : in
+ :
+ $c <<"EOI";
+ \$* -i 1 <</EOF >'foo$ps'
+ foo/
+ EOF
+ EOI
+ $b
+
+ : out
+ :
+ $c <<"EOI";
+ \$* -i 1 <'foo$ps' >>/EOO
+ foo/
+ EOO
+ EOI
+ $b
+
+ : err
+ :
+ $c <<"EOI";
+ \$* -i 2 <'foo$ps' 2>>/EOE
+ foo/
+ EOE
+ EOI
+ $b
+ }
+ }
+
+ : regex
:
- : Make sure that the large (>4KB) expected/real output difference is not
- : printed as a part of the diagnostics.
+ : Test regex matching. Note that tests that check regex parsing are located
+ : in regex.test testscript.
:
- $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
+ {
+ : match
+ :
+ $c <<EOI;
+ $* -o foo -o foo -o bar >>~/EOO/i
+ /FO*/*
+ bar
+ /*
+ EOO
+ EOI
+ $b
+
+ : match-empty
+ :
+ $c <<EOI;
+ $* >>:~/EOO/
+ /.{0}
+ EOO
+ EOI
+ $b
+
+ : mismatch
+ :
+ $c <<EOI;
+ $* -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
+ EOE
+
+ : mismatch-icase
+ :
+ $c <<EOI;
+ $* -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
+ EOE
+ }
}
: file
@@ -336,52 +500,6 @@ b += --no-column
$b
}
-: 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/regex.test b/tests/test/script/runner/regex.test
new file mode 100644
index 0000000..f4863b1
--- /dev/null
+++ b/tests/test/script/runner/regex.test
@@ -0,0 +1,321 @@
+# file : tests/test/script/runner/regex.test
+# copyright : Copyright (c) 2014-2017 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
+ :
+ {
+ : out
+ :
+ $c <'cat <foo >~/fo./';
+ $b
+
+ : err
+ :
+ $c <'cat <foo 1>&2 2>~/fo./';
+ $b
+
+ : no-newline
+ :
+ $c <'cat <:foo >:~/fo./';
+ $b
+
+ : malformed
+ :
+ : Note that old versions of libc++ (for example 1.1) do not detect some
+ : regex errors. For example '*' is parsed successfully.
+ :
+ $c <'$* -o foo >~/foo[/';
+ $b 2>>~/EOE/ != 0
+ /testscript:1:13: error: invalid stdout regex redirect.*/
+ info: regex: '/foo[/'
+ EOE
+ }
+
+ : doc
+ :
+ {
+ : out
+ :
+ $c <<EOI;
+ cat <foo >>~/EOO/
+ /foo/
+ EOO
+ EOI
+ $b
+
+ : err
+ :
+ $c <<EOI;
+ cat <foo 1>&2 2>>~/EOO/
+ /fo./
+ EOO
+ EOI
+ $b
+
+ : no-newline
+ :
+ $c <<EOI;
+ cat <:foo >>:~/EOO/
+ /fo./
+ EOO
+ EOI
+ $b
+
+ : line-char
+ :
+ $c <<EOI;
+ cat <<EOF >>~/EOO/
+ foo
+ bar
+ baz
+ baz
+ Biz
+ Fox
+ fox
+
+
+
+
+ EOF
+ foo
+ /?
+ /bar/
+ /baz/+
+ /biz/i
+ /fox/i+
+
+ //
+ //{2}
+ EOO
+ EOI
+ $b
+
+ : expansion
+ :
+ $c <<EOI;
+ s="O*/i
+ bar
+ ";
+ cat <<EOF >>~"/EOO/"
+ foo
+ bar
+
+ baz
+ EOF
+ /f$(s)
+ baz
+ EOO
+ EOI
+ $b
+
+ : invalid-syntax-char
+ :
+ $c <<EOI;
+ $* -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 <<EOI;
+ $* -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 <<EOI;
+ $* -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
+ }
+}
+
+:flags
+:
+{
+ : str
+ :
+ {
+ : i
+ :
+ $c <'cat <Foo >~/foo/i';
+ $b
+
+ : d
+ :
+ {
+ : escaped-dot
+ :
+ : Escaped dot becomes syntax dot and matches any character ('i' in our
+ : case).
+ :
+ $c <'cat <fio >~/f\\.o/d';
+ $b
+
+ : syntax-dot
+ :
+ : Syntax dot becomes escaped dot and matches only '.' and so we fail.
+ :
+ $c <'cat <fio >~/f.o/d';
+ $b 2>>~/EOE/ != 0
+ testscript:1:1: error: cat stdout doesn't match the regex
+ /.+
+ EOE
+ }
+ }
+
+ : doc
+ {
+ : i
+ :
+ $c <<EOI;
+ cat <Foo >>~/EOO/
+ /foo/i
+ EOO
+ EOI
+ $b
+
+ : d
+ :
+ : All the reasonings for the /flags/str/d test group are valid for the
+ : current one.
+ :
+ {
+ : escaped-dot
+ :
+ $c <<EOI;
+ cat <fio >>~/EOO/
+ /f\.o/d
+ EOO
+ EOI
+ $b
+
+ : syntax-dot
+ :
+ $c <<EOI;
+ cat <fio >>~/EOO/
+ /f.o/d
+ EOO
+ EOI
+ $b 2>>~/EOE/ != 0
+ testscript:1:1: error: cat stdout doesn't match the regex
+ /.+
+ EOE
+ }
+
+ : global
+ :
+ {
+ : i
+ :
+ $c <<EOI;
+ cat <Foo >>~/EOO/i
+ /foo/
+ EOO
+ EOI
+ $b
+
+ : d
+ :
+ {
+ : escaped-dot
+ :
+ $c <<EOI;
+ cat <fio >>~/EOO/d
+ /f\.o/
+ EOO
+ EOI
+ $b
+
+ : syntax-dot
+ :
+ $c <<EOI;
+ cat <fio >>~/EOO/d
+ /f.o/
+ EOO
+ EOI
+ $b 2>>~/EOE/ != 0
+ testscript:1:1: error: cat stdout doesn't match the regex
+ /.+
+ EOE
+ }
+ }
+ }
+}
+
+: portable-path
+:
+{
+ ps = ($cxx.target.class != 'windows' ? '/' : '\')
+
+ : str
+ :
+ {
+ : out
+ :
+ $c <"cat <'foo$ps' >/~%foo/%";
+ $b
+
+ : err
+ :
+ $c <"cat <'foo$ps' >/~%foo/%";
+ $b
+ }
+
+ : doc
+ {
+ : out
+ :
+ $c <<"EOI";
+ cat <'foo$ps' >>/~%EOO%
+ foo/
+ EOO
+ EOI
+ $b
+
+ : err
+ :
+ $c <<"EOI";
+ cat <'foo$ps' >>/~%EOO%
+ foo/
+ EOO
+ EOI
+ $b
+ }
+}
diff --git a/tests/test/script/runner/status.test b/tests/test/script/runner/status.test
index d7a0d0d..c1df3e4 100644
--- a/tests/test/script/runner/status.test
+++ b/tests/test/script/runner/status.test
@@ -17,8 +17,8 @@ b += --no-column
: false
:
$c <'$* -s 1 == 0';
- $b 2>>~%EOE% != 0
- %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 != 0%
+ $b 2>>/~%EOE%d != 0
+ %testscript:1: error: ../../../../driver(.exe)? exit status 1 != 0%
EOE
}
@@ -33,17 +33,17 @@ b += --no-column
: false
:
$c <'$* -s 1 != 1';
- $b 2>>~%EOE% != 0
- %testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 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
-%testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? exit status 1 != 0%
-% info: stderr: test[/\\]1[/\\]stderr%
+$b 2>>/~%EOE% != 0
+%testscript:1: error: ../../../driver(.exe)? exit status 1 != 0%
+ info: stderr: test/1/stderr
Error
EOE
@@ -54,9 +54,9 @@ EOE
: under Wine some extra info is printed to STDOUT.
:
$c <'$* -t m';
-$b 2>>~%EOE% != 0
+$b 2>>/~%EOE% != 0
%wine: .+%?
-%testscript:1: error: \.\.[/\\]\.\.[/\\]\.\.[/\\]driver(\.exe)? terminated abnormally%
+%testscript:1: error: ../../../driver(.exe)? terminated abnormally%d
% info: .+%
% info: stdout: test\\1\\stdout%?
EOE