From a83f3866667bca073c4d4c5d80b4deb5ac05906c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 11 Jan 2017 01:43:09 +0300 Subject: Add support for portable path modifer and dot character escaping inversion --- unit-tests/test/script/parser/driver.cxx | 7 ++ unit-tests/test/script/parser/redirect.test | 76 ++++++++++++++++++ unit-tests/test/script/parser/regex.test | 115 ++++++++++++++++------------ 3 files changed, 150 insertions(+), 48 deletions(-) (limited to 'unit-tests/test/script/parser') 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 ( + "test.target", variable_visibility::project))); + + v = cast ((*global_scope)["build.host"]); + testscript& st ( targets.insert (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 + : + $* <>EOO + cmd /bar 2>/baz + EOI + cmd /bar 2>/baz + EOO + } + + : regex + : + { + : portable-path + : + $* <>EOO + cmd >/~%foo% 2>/~%bar% + EOI + cmd >/~%foo% 2>/~%bar% + EOO + } +} + +: doc +: +{ + : literal + : + { + : portable-path + : + $* <>EOO + cmd </EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOI + cmd </EOO_ 2>/EOE_ + foo + EOI_ + bar + EOO_ + baz + EOE_ + EOO + } + + : regex + : + { + : portable-path + : + $* <>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 : $* <>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 : $* <>EOE != 0 cmd >>~/EOO/ - /x - EOO - EOI - testscript:2:1: error: invalid line-regex syntax character 'x' - EOE - - : invalid-char-regex - : - $* <>~/EOE/ != 0 - cmd >>~/EOO/ - /foo[/ - EOO - EOI - /testscript:2:1: error: invalid regex.*/ - EOE - - : invalid-line-regex - : - $* <>~/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 : $* <>EOO cmd 2>>~/EOE/ @@ -184,6 +162,47 @@ //* EOE EOO + + : no-newline + : + $* <'cmd >:~/fo*/' >'cmd >:~/fo*/' + $* <>EOO + cmd 2>>:~/EOE/ + foo + EOE + EOI + cmd 2>>:~/EOE/ + foo + EOE + EOO + + : end-marker-restore + : + { + : idot + : + $* <>EOO + cmd 2>>~/EOE/d + foo + EOE + EOI + cmd 2>>~/EOE/d + foo + EOE + EOO + + : icase + : + $* <>EOO + cmd 2>>~/EOE/i + foo + EOE + EOI + cmd 2>>~/EOE/i + foo + EOE + EOO + } } : stderr -- cgit v1.1