From 4a4e5ad3c50619ad7653b01b562af9794c97aa80 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Nov 2016 16:35:47 +0200 Subject: Implement command-pipe, command-expr in testscript parser --- unit-tests/test/script/parser/buildfile | 4 +-- unit-tests/test/script/parser/driver.cxx | 4 +-- unit-tests/test/script/parser/exit.test | 23 ++++++++++++++ unit-tests/test/script/parser/pipe-expr.test | 47 ++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 unit-tests/test/script/parser/exit.test create mode 100644 unit-tests/test/script/parser/pipe-expr.test (limited to 'unit-tests') 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 +: +$* <>EOO +cmd == 1 +EOI +cmd == 1 +EOO + +: ne +: +$* <>EOO +cmd!=1 +EOI +cmd != 1 +EOO + +: end +: +$* <>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 +: +$* <>EOO +cmd1 | cmd2|cmd3 +EOI +cmd1 | cmd2 | cmd3 +EOO + +: log +: +$* <>EOO +cmd1 || cmd2&&cmd3 +EOI +cmd1 || cmd2 && cmd3 +EOO + +: pipe-log +: +$* <>EOO +cmd1 | cmd2 && cmd3 | cmd4 +EOI +cmd1 | cmd2 && cmd3 | cmd4 +EOO + +: exit +: +$* <>EOO +cmd1|cmd2==1&&cmd3!=0|cmd4 +EOI +cmd1 | cmd2 == 1 && cmd3 != 0 | cmd4 +EOO + +: leading +: +$* <>EOE != 0 +| cmd +EOI +testscript:1:1: error: missing program +EOE + +: trailing +: +$* <>EOE != 0 +cmd && +EOI +testscript:1:7: error: missing program +EOE -- cgit v1.1