diff options
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r-- | unit-tests/test/script/lexer/buildfile | 2 | ||||
-rw-r--r-- | unit-tests/test/script/lexer/command-expansion.test | 134 | ||||
-rw-r--r-- | unit-tests/test/script/lexer/command-line.test | 146 | ||||
-rw-r--r-- | unit-tests/test/script/lexer/driver.cxx | 22 | ||||
-rw-r--r-- | unit-tests/test/script/lexer/script-line.test | 134 |
5 files changed, 219 insertions, 219 deletions
diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile index ac833e4..63f5743 100644 --- a/unit-tests/test/script/lexer/buildfile +++ b/unit-tests/test/script/lexer/buildfile @@ -9,7 +9,7 @@ src = token lexer diagnostics utility variable name b-options types-parsers \ test/script/{token lexer} exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \ -test{script-line command-line first-token second-token variable-line \ +test{command-line first-token second-token command-expansion variable-line \ description-line variable} include ../../../../build2/ diff --git a/unit-tests/test/script/lexer/command-expansion.test b/unit-tests/test/script/lexer/command-expansion.test new file mode 100644 index 0000000..f113846 --- /dev/null +++ b/unit-tests/test/script/lexer/command-expansion.test @@ -0,0 +1,134 @@ +test.arguments = command-expansion + +$* <:"0<+" >>EOO # in-pass-redirect +'0' +<+ +EOO + +$* <:"0 <+" >>EOO # arg-in-pass-redirect +'0 ' +<+ +EOO + +$* <:"1>+" >>EOO # out-pass-redirect +'1' +>+ +EOO + +$* <:"1 >+" >>EOO # arg-out-pass-redirect +'1 ' +>+ +EOO + +$* <:"0<-" >>EOO # in-null-redirect +'0' +<- +EOO + +$* <:"0 <-" >>EOO # arg-in-null-redirect +'0 ' +<- +EOO + +$* <:"1>-" >>EOO # out-null-redirect +'1' +>- +EOO + +$* <:"1 >-" >>EOO # arg-out-null-redirect +'1 ' +>- +EOO + +$* <:"1>&2" >>EOO # merge-redirect +'1' +>& +'2' +EOO + +$* <:"1 >&2" >>EOO # arg-merge-redirect +'1 ' +>& +'2' +EOO + +$* <:"0<a b" >>EOO # in-str-redirect +'0' +< +'a b' +EOO + +$* <:"1>a b" >>EOO # out-str-redirect +'1' +> +'a b' +EOO + +$* <:"0<:a b" >>EOO # in-str-nn-redirect +'0' +<: +'a b' +EOO + +$* <:"1>:a b" >>EOO # out-str-nn-redirect +'1' +>: +'a b' +EOO + +$* <:"0<<E O I" >>EOO # in-doc-redirect +'0' +<< +'E O I' +EOO + +$* <:"1>>E O O" >>EOO # out-doc-redirect +'1' +>> +'E O O' +EOO + +$* <:"0<<:E O I" >>EOO # in-doc-nn-redirect +'0' +<<: +'E O I' +EOO + +$* <:"1>>:E O O" >>EOO # out-doc-nn-redirect +'1' +>>: +'E O O' +EOO + +$* <:"0<<<a b" >>EOO # in-file-redirect +'0' +<<< +'a b' +EOO + +$* <:"1>>>a b" >>EOO # out-file-redirect +'1' +>>> +'a b' +EOO + +$* <:"1>>>&a b" >>EOO # out-file-app-redirect +'1' +>>>& +'a b' +EOO + +$* <:"&file" >>EOO # cleanup-always +& +'file' +EOO + +$* <:"&?file" >>EOO # cleanup-maybe +&? +'file' +EOO + +$* <:"&!file" >>EOO # cleanup-never +&! +'file' +EOO diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test index 38e5954..0040cfe 100644 --- a/unit-tests/test/script/lexer/command-line.test +++ b/unit-tests/test/script/lexer/command-line.test @@ -1,134 +1,134 @@ test.arguments = command-line -$* <:"0<+" >>EOO # in-pass-redirect -'0' -<+ +$* <"cmd;" >>EOO # semi +'cmd' +; +<newline> EOO -$* <:"0 <+" >>EOO # arg-in-pass-redirect -'0 ' -<+ +$* <"cmd ;" >>EOO # semi-separated +'cmd' +; +<newline> EOO -$* <:"1>+" >>EOO # out-pass-redirect -'1' ->+ +$* <";" >>EOO # semi-only +; +<newline> EOO -$* <:"1 >+" >>EOO # arg-out-pass-redirect -'1 ' ->+ +$* <"cmd: dsc" >>EOO # colon +'cmd' +: +'dsc' +<newline> EOO -$* <:"0<-" >>EOO # in-null-redirect -'0' -<- +$* <"cmd :dsc" >>EOO # colon-separated +'cmd' +: +'dsc' +<newline> EOO -$* <:"0 <-" >>EOO # arg-in-null-redirect -'0 ' -<- +$* <":" >>EOO # colon-only +: +<newline> EOO -$* <:"1>-" >>EOO # out-null-redirect +$* <"cmd <+ 1>+" >>EOO # pass-redirect +'cmd' +<+ '1' ->- +>+ +<newline> EOO -$* <:"1 >-" >>EOO # arg-out-null-redirect -'1 ' +$* <"cmd <- 1>-" >>EOO # null-redirect +'cmd' +<- +'1' >- +<newline> EOO -$* <:"1>&2" >>EOO # merge-redirect +$* <"cmd 1>&2" >>EOO # merge-redirect +'cmd' '1' >& '2' +<newline> EOO -$* <:"1 >&2" >>EOO # arg-merge-redirect -'1 ' ->& -'2' -EOO - -$* <:"0<a b" >>EOO # in-str-redirect -'0' +$* <"cmd <a 1>b" >>EOO # str-redirect +'cmd' < -'a b' -EOO - -$* <:"1>a b" >>EOO # out-str-redirect +'a' '1' > -'a b' +'b' +<newline> EOO -$* <:"0<:a b" >>EOO # in-str-nn-redirect -'0' +$* <"cmd <:a 1>:b" >>EOO # str-nn-redirect +'cmd' <: -'a b' -EOO - -$* <:"1>:a b" >>EOO # out-str-nn-redirect +'a' '1' >: -'a b' +'b' +<newline> EOO -$* <:"0<<E O I" >>EOO # in-doc-redirect -'0' +$* <"cmd <<EOI 1>>EOO" >>EOO # doc-redirect +'cmd' << -'E O I' -EOO - -$* <:"1>>E O O" >>EOO # out-doc-redirect +'EOI' '1' >> -'E O O' +'EOO' +<newline> EOO -$* <:"0<<:E O I" >>EOO # in-doc-nn-redirect -'0' +$* <"cmd <<:EOI 1>>:EOO" >>EOO # doc-nn-redirect +'cmd' <<: -'E O I' -EOO - -$* <:"1>>:E O O" >>EOO # out-doc-nn-redirect +'EOI' '1' >>: -'E O O' +'EOO' +<newline> EOO -$* <:"0<<<a b" >>EOO # in-file-redirect -'0' +$* <"cmd <<<in >>>out 2>>>&err" >>EOO # file-redirect +'cmd' <<< -'a b' -EOO - -$* <:"1>>>a b" >>EOO # out-file-redirect -'1' +'in' >>> -'a b' -EOO - -$* <:"1>>>&a b" >>EOO # out-file-app-redirect -'1' +'out' +'2' >>>& -'a b' +'err' +<newline> EOO -$* <:"&file" >>EOO # cleanup-always +$* <"cmd &file" >>EOO # cleanup-always +'cmd' & 'file' +<newline> EOO -$* <:"&?file" >>EOO # cleanup-maybe +$* <"cmd &?file" >>EOO # cleanup-maybe +'cmd' &? 'file' +<newline> EOO -$* <:"&!file" >>EOO # cleanup-never +$* <"cmd &!file" >>EOO # cleanup-never +'cmd' &! 'file' +<newline> EOO diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx index 3709191..9244e9d 100644 --- a/unit-tests/test/script/lexer/driver.cxx +++ b/unit-tests/test/script/lexer/driver.cxx @@ -29,16 +29,16 @@ namespace build2 assert (argc == 2); string s (argv[1]); - if (s == "script-line") m = lexer_mode::script_line; - else if (s == "first-token") m = lexer_mode::first_token; - else if (s == "second-token") m = lexer_mode::second_token; - else if (s == "variable-line") m = lexer_mode::variable_line; - else if (s == "command-line") m = lexer_mode::command_line; - else if (s == "here-line-single") m = lexer_mode::here_line_single; - else if (s == "here-line-double") m = lexer_mode::here_line_double; - else if (s == "description-line") m = lexer_mode::description_line; - else if (s == "variable") m = lexer_mode::variable; - else assert (false); + if (s == "command-line") m = lexer_mode::command_line; + else if (s == "first-token") m = lexer_mode::first_token; + else if (s == "second-token") m = lexer_mode::second_token; + else if (s == "variable-line") m = lexer_mode::variable_line; + else if (s == "command-expansion") m = lexer_mode::command_expansion; + else if (s == "here-line-single") m = lexer_mode::here_line_single; + else if (s == "here-line-double") m = lexer_mode::here_line_double; + else if (s == "description-line") m = lexer_mode::description_line; + else if (s == "variable") m = lexer_mode::variable; + else assert (false); } try @@ -53,7 +53,7 @@ namespace build2 m == lexer_mode::description_line || m == lexer_mode::variable); - lexer l (cin, path ("stdin"), u ? lexer_mode::script_line : m); + lexer l (cin, path ("stdin"), u ? lexer_mode::command_line : m); if (u) l.mode (m); diff --git a/unit-tests/test/script/lexer/script-line.test b/unit-tests/test/script/lexer/script-line.test deleted file mode 100644 index 7870871..0000000 --- a/unit-tests/test/script/lexer/script-line.test +++ /dev/null @@ -1,134 +0,0 @@ -test.arguments = script-line - -$* <"cmd;" >>EOO # semi -'cmd' -; -<newline> -EOO - -$* <"cmd ;" >>EOO # semi-separated -'cmd' -; -<newline> -EOO - -$* <";" >>EOO # semi-only -; -<newline> -EOO - -$* <"cmd: dsc" >>EOO # colon -'cmd' -: -'dsc' -<newline> -EOO - -$* <"cmd :dsc" >>EOO # colon-separated -'cmd' -: -'dsc' -<newline> -EOO - -$* <":" >>EOO # colon-only -: -<newline> -EOO - -$* <"cmd <+ 1>+" >>EOO # pass-redirect -'cmd' -<+ -'1' ->+ -<newline> -EOO - -$* <"cmd <- 1>-" >>EOO # null-redirect -'cmd' -<- -'1' ->- -<newline> -EOO - -$* <"cmd 1>&2" >>EOO # merge-redirect -'cmd' -'1' ->& -'2' -<newline> -EOO - -$* <"cmd <a 1>b" >>EOO # str-redirect -'cmd' -< -'a' -'1' -> -'b' -<newline> -EOO - -$* <"cmd <:a 1>:b" >>EOO # str-nn-redirect -'cmd' -<: -'a' -'1' ->: -'b' -<newline> -EOO - -$* <"cmd <<EOI 1>>EOO" >>EOO # doc-redirect -'cmd' -<< -'EOI' -'1' ->> -'EOO' -<newline> -EOO - -$* <"cmd <<:EOI 1>>:EOO" >>EOO # doc-nn-redirect -'cmd' -<<: -'EOI' -'1' ->>: -'EOO' -<newline> -EOO - -$* <"cmd <<<in >>>out 2>>>&err" >>EOO # file-redirect -'cmd' -<<< -'in' ->>> -'out' -'2' ->>>& -'err' -<newline> -EOO - -$* <"cmd &file" >>EOO # cleanup-always -'cmd' -& -'file' -<newline> -EOO - -$* <"cmd &?file" >>EOO # cleanup-maybe -'cmd' -&? -'file' -<newline> -EOO - -$* <"cmd &!file" >>EOO # cleanup-never -'cmd' -&! -'file' -<newline> -EOO |