diff options
Diffstat (limited to 'unit-tests/test/script/parser')
-rw-r--r-- | unit-tests/test/script/parser/driver.cxx | 7 | ||||
-rw-r--r-- | unit-tests/test/script/parser/redirect.test | 76 | ||||
-rw-r--r-- | unit-tests/test/script/parser/regex.test | 115 |
3 files changed, 150 insertions, 48 deletions
diff --git a/unit-tests/test/script/parser/driver.cxx b/unit-tests/test/script/parser/driver.cxx index 271fd2c..f641dc4 100644 --- a/unit-tests/test/script/parser/driver.cxx +++ b/unit-tests/test/script/parser/driver.cxx @@ -189,6 +189,13 @@ namespace build2 string (), trace)); + value& v ( + tt.assign ( + var_pool.insert<target_triplet> ( + "test.target", variable_visibility::project))); + + v = cast<target_triplet> ((*global_scope)["build.host"]); + testscript& st ( targets.insert<testscript> (work, dir_path (), diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test index 5a91354..3db684a 100644 --- a/unit-tests/test/script/parser/redirect.test +++ b/unit-tests/test/script/parser/redirect.test @@ -6,6 +6,82 @@ # @@ Does it make sense to split into separate files - one per redirect type? # +: str +: +{ + : literal + : + { + : portable-path + : + $* <<EOI >>EOO + cmd </foo >/bar 2>/baz + EOI + cmd </foo >/bar 2>/baz + EOO + } + + : regex + : + { + : portable-path + : + $* <<EOI >>EOO + cmd >/~%foo% 2>/~%bar% + EOI + cmd >/~%foo% 2>/~%bar% + EOO + } +} + +: doc +: +{ + : literal + : + { + : portable-path + : + $* <<EOI >>EOO + cmd <</EOI_ >/EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOI + cmd <</EOI_ >/EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOO + } + + : regex + : + { + : portable-path + : + $* <<EOI >>EOO + cmd >/~%EOF% 2>/~%EOE% + foo + EOF + bar + EOE + EOI + cmd >/~%EOF% 2>/~%EOE% + foo + EOF + bar + EOE + EOO + } +} + : file : { diff --git a/unit-tests/test/script/parser/regex.test b/unit-tests/test/script/parser/regex.test index f9101c9..058a5bc 100644 --- a/unit-tests/test/script/parser/regex.test +++ b/unit-tests/test/script/parser/regex.test @@ -26,12 +26,30 @@ testscript:1:7: error: no closing introducer character in stdout regex redirect EOE + : portable-path-introducer + : + $* <'cmd >/~/foo/' 2>>EOE != 0 + testscript:1:8: error: portable path modifier and '/' introducer in stdout regex redirect + EOE + : empty : $* <'cmd >~//' 2>>EOE != 0 testscript:1:7: error: stdout regex redirect is empty EOE + : no-flags + : + $* <'cmd >~/fo*/' >'cmd >~/fo*/' + + : idot + : + $* <'cmd >~/fo*/d' >'cmd >~/fo*/d' + + : icase + : + $* <'cmd >~/fo*/i' >'cmd >~/fo*/i' + : invalid-flags1 : $* <'cmd >~/foo/z' 2>>EOE != 0 @@ -44,24 +62,6 @@ testscript:1:7: error: junk at the end of stdout regex redirect EOE - : malformed - : - : Note that old versions of libc++ (for example 1.1) do not detect some - : regex errors. For example '*' is parsed successfully. - : - $* <'cmd >~/foo[/' 2>>~/EOE/ != 0 - /testscript:1:7: error: invalid stdout regex redirect.*/ - info: regex: /foo[/ - EOE - - : without-flags - : - $* <'cmd >~/fo*/' >'cmd >~/fo*/' - - : with-flags - : - $* <'cmd >~/fo*/i' >'cmd >~/fo*/i' - : no-newline : $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' @@ -106,46 +106,24 @@ testscript:1:8: error: expected here-document regex end marker EOE - : unterminated-line-char + : portable-path-introducer : $* <<EOI 2>>EOE != 0 - cmd >>~/EOO/ - / + cmd >>/~/EOO/ + foo EOO EOI - testscript:2:1: error: regex introducer without regex - info: consider changing regex introducer '/' in here-document end marker + testscript:1:5: error: portable path modifier and '/' introducer in here-document regex end marker EOE - : invalid-syntax-char + : unterminated-line-char : $* <<EOI 2>>EOE != 0 cmd >>~/EOO/ - /x - EOO - EOI - testscript:2:1: error: invalid line-regex syntax character 'x' - EOE - - : invalid-char-regex - : - $* <<EOI 2>>~/EOE/ != 0 - cmd >>~/EOO/ - /foo[/ - EOO - EOI - /testscript:2:1: error: invalid regex.*/ - EOE - - : invalid-line-regex - : - $* <<EOI 2>>~/EOE/ != 0 - cmd >>~/EOO/ - a - /{ + / EOO EOI - /testscript:4:1: error: invalid here-document regex.*/ + testscript:2:1: error: no syntax line characters EOE : empty @@ -157,7 +135,7 @@ testscript:2:1: error: empty here-document regex EOE - : valid + : no-flags : $* <<EOI >>EOO cmd 2>>~/EOE/ @@ -184,6 +162,47 @@ //* EOE EOO + + : no-newline + : + $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' + $* <<EOI >>EOO + cmd 2>>:~/EOE/ + foo + EOE + EOI + cmd 2>>:~/EOE/ + foo + EOE + EOO + + : end-marker-restore + : + { + : idot + : + $* <<EOI >>EOO + cmd 2>>~/EOE/d + foo + EOE + EOI + cmd 2>>~/EOE/d + foo + EOE + EOO + + : icase + : + $* <<EOI >>EOO + cmd 2>>~/EOE/i + foo + EOE + EOI + cmd 2>>~/EOE/i + foo + EOE + EOO + } } : stderr |