diff options
Diffstat (limited to 'unit-tests/test/script/parser')
-rw-r--r-- | unit-tests/test/script/parser/buildfile | 4 | ||||
-rw-r--r-- | unit-tests/test/script/parser/driver.cxx | 4 | ||||
-rw-r--r-- | unit-tests/test/script/parser/exit.test | 23 | ||||
-rw-r--r-- | unit-tests/test/script/parser/pipe-expr.test | 47 |
4 files changed, 74 insertions, 4 deletions
diff --git a/unit-tests/test/script/parser/buildfile b/unit-tests/test/script/parser/buildfile index c65dd73..60c556c 100644 --- a/unit-tests/test/script/parser/buildfile +++ b/unit-tests/test/script/parser/buildfile @@ -11,7 +11,7 @@ filesystem config/{utility init operation} dump types-parsers \ test/{target script/{token lexer parser script}} exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \ -test{cleanup command-re-parse description expansion here-document here-string \ - pre-parse redirect scope setup-teardown} +test{cleanup command-re-parse description exit expansion here-document \ + here-string pipe-expr pre-parse redirect scope setup-teardown} include ../../../../build2/ diff --git a/unit-tests/test/script/parser/driver.cxx b/unit-tests/test/script/parser/driver.cxx index 18fcdce..20e1e6a 100644 --- a/unit-tests/test/script/parser/driver.cxx +++ b/unit-tests/test/script/parser/driver.cxx @@ -81,9 +81,9 @@ namespace build2 } virtual void - run (scope&, const command& t, size_t, const location&) override + run (scope&, const command_expr& e, size_t, const location&) override { - cout << ind_ << t << endl; + cout << ind_ << e << endl; } virtual void diff --git a/unit-tests/test/script/parser/exit.test b/unit-tests/test/script/parser/exit.test new file mode 100644 index 0000000..263179b --- /dev/null +++ b/unit-tests/test/script/parser/exit.test @@ -0,0 +1,23 @@ +: eq +: +$* <<EOI >>EOO +cmd == 1 +EOI +cmd == 1 +EOO + +: ne +: +$* <<EOI >>EOO +cmd!=1 +EOI +cmd != 1 +EOO + +: end +: +$* <<EOI 2>>EOE != 0 +cmd != 1 <"foo" +EOI +testscript:1:10: error: unexpected '<' after command exit status +EOE diff --git a/unit-tests/test/script/parser/pipe-expr.test b/unit-tests/test/script/parser/pipe-expr.test new file mode 100644 index 0000000..5a6e6ab --- /dev/null +++ b/unit-tests/test/script/parser/pipe-expr.test @@ -0,0 +1,47 @@ +: pipe +: +$* <<EOI >>EOO +cmd1 | cmd2|cmd3 +EOI +cmd1 | cmd2 | cmd3 +EOO + +: log +: +$* <<EOI >>EOO +cmd1 || cmd2&&cmd3 +EOI +cmd1 || cmd2 && cmd3 +EOO + +: pipe-log +: +$* <<EOI >>EOO +cmd1 | cmd2 && cmd3 | cmd4 +EOI +cmd1 | cmd2 && cmd3 | cmd4 +EOO + +: exit +: +$* <<EOI >>EOO +cmd1|cmd2==1&&cmd3!=0|cmd4 +EOI +cmd1 | cmd2 == 1 && cmd3 != 0 | cmd4 +EOO + +: leading +: +$* <<EOI 2>>EOE != 0 +| cmd +EOI +testscript:1:1: error: missing program +EOE + +: trailing +: +$* <<EOI 2>>EOE != 0 +cmd && +EOI +testscript:1:7: error: missing program +EOE |