diff options
-rw-r--r-- | build2/test/script/runner.cxx | 10 | ||||
-rw-r--r-- | tests/test/script/runner/redirect.test | 21 | ||||
-rw-r--r-- | tests/test/script/runner/regex.test | 58 |
3 files changed, 54 insertions, 35 deletions
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx index 4047b5a..ffb95e8 100644 --- a/build2/test/script/runner.cxx +++ b/build2/test/script/runner.cxx @@ -431,8 +431,7 @@ namespace build2 // // test/1/stdout.regex~di // - if (rd.type == redirect_type::here_doc_regex && - !rl.flags.empty ()) + if (rd.type == redirect_type::here_doc_regex && !rl.flags.empty ()) rp += "~" + rl.flags; // Note that if would be more efficient to directly write chunks @@ -441,10 +440,11 @@ namespace build2 // already failed. // string s; - for (const auto& l: rl.lines) + for (auto b (rl.lines.cbegin ()), i (b), e (rl.lines.cend ()); + i != e; ++i) { - if (!s.empty ()) s += '\n'; - s += line (l); + if (i != b) s += '\n'; + s += line (*i); } save (rp, s, ll); diff --git a/tests/test/script/runner/redirect.test b/tests/test/script/runner/redirect.test index 3cd6c69..b316011 100644 --- a/tests/test/script/runner/redirect.test +++ b/tests/test/script/runner/redirect.test @@ -39,8 +39,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : inout-fail : - $c <'$* -i 1 <foo >bar'; - $b 2>>/~%EOE%d != 0 + $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 @@ -61,8 +60,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : no-newline-fail1 : - $c <'$* -i 1 <:"foo" >"foo"'; - $b 2>>~/EOE/ != 0 + $c <'$* -i 1 <:"foo" >"foo"' && $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo @@ -72,8 +70,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : no-newline-fail2 : - $c <'$* -i 1 <"foo" >:"foo"'; - $b 2>>~/EOE/ != 0 + $c <'$* -i 1 <"foo" >:"foo"' && $b 2>>~/EOE/ != 0 /testscript:1: error: .+driver(\.exe)? stdout doesn't match the expected output/ /.{7} -foo @@ -107,13 +104,11 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : match : - $c <'$* -o foo >~/Foo?/i'; - $b + $c <'$* -o foo >~/Foo?/i' && $b : mismatch : - $c <'$* -o fooo >~/Foo?/i'; - $b 2>>/~%EOE%d != 0 + $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 @@ -127,8 +122,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. { : newline : - $c <"\$* -i 1 <'foo' >/~%bar/%"; - $b 2>>/~%EOE%d != 0; + $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 @@ -138,8 +132,7 @@ psr = ($cxx.target.class != 'windows' ? '/' : '\\') # Path separator in regex. : no-newline : - $c <"\$* -i 1 <'foo' >:/~%bar/%"; - $b 2>>/~%EOE%d != 0; + $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 diff --git a/tests/test/script/runner/regex.test b/tests/test/script/runner/regex.test index 413069c..c45c3a5 100644 --- a/tests/test/script/runner/regex.test +++ b/tests/test/script/runner/regex.test @@ -32,11 +32,19 @@ : 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.*/ + $c <'cat <foo >~/foo[/' && $b 2>>~/EOE/ != 0 + /testscript:1:12: error: invalid stdout regex redirect.*/ info: regex: '/foo[/' EOE + + : no-match + : + $c <'cat <foo >~/bar/' && $b 2>>/EOE != 0 + testscript:1:1: error: cat stdout doesn't match the regex + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + EOE } : doc @@ -114,36 +122,54 @@ : invalid-syntax-char : $c <<EOI && $b 2>>EOE != 0 - $* -o foo >>~/EOO/ - /x - EOO + cat <foo >>~/EOO/ + /x + EOO EOI - testscript:2:3: error: invalid syntax character 'x' in stdout regex redirect + testscript:2:1: error: invalid syntax character 'x' in stdout regex redirect info: regex line: '/x' EOE : invalid-char-regex : $c <<EOI && $b 2>>~/EOE/ != 0 - $* -o foo >>~/EOO/ - /foo[/ - EOO + cat <foo >>~/EOO/ + /foo[/ + EOO EOI - /testscript:2:3: error: invalid char-regex in stdout regex redirect.*/ + /testscript:2:1: error: invalid char-regex in stdout regex redirect.*/ info: regex line: '/foo[/' EOE : invalid-line-regex : $c <<EOI && $b 2>>/~%EOE% != 0 - $* -o foo >>~/EOO/ - a - /{ - EOO + cat <foo >>~/EOO/ + a + /{ + EOO EOI - %testscript:4:3: error: invalid stdout regex redirect.*% + %testscript:4:1: error: invalid stdout regex redirect.*% info: stdout regex: test/1/stdout.regex EOE + + : no-match + : + { + : leading-blank + : + $c <<EOI && $b 2>>/EOE != 0 + cat <foo >>~/EOO/ + + foo + EOO + EOI + testscript:1:1: error: cat stdout doesn't match the regex + info: stdout: test/1/stdout + info: stdout regex: test/1/stdout.regex + info: stdin: test/1/stdin + EOE + } } } |