From 554475390b6d2912614778fe50788a09f99ac6a4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Nov 2016 17:54:02 +0200 Subject: Implement testscript inclusion support --- unit-tests/test/script/parser/buildfile | 2 +- unit-tests/test/script/parser/include.test | 140 +++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 unit-tests/test/script/parser/include.test (limited to 'unit-tests') diff --git a/unit-tests/test/script/parser/buildfile b/unit-tests/test/script/parser/buildfile index 60c556c..f87f7e8 100644 --- a/unit-tests/test/script/parser/buildfile +++ b/unit-tests/test/script/parser/buildfile @@ -12,6 +12,6 @@ test/{target script/{token lexer parser script}} exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \ test{cleanup command-re-parse description exit expansion here-document \ - here-string pipe-expr pre-parse redirect scope setup-teardown} + here-string include pipe-expr pre-parse redirect scope setup-teardown} include ../../../../build2/ diff --git a/unit-tests/test/script/parser/include.test b/unit-tests/test/script/parser/include.test new file mode 100644 index 0000000..8210172 --- /dev/null +++ b/unit-tests/test/script/parser/include.test @@ -0,0 +1,140 @@ +: not-directive +: +$* <>EOO +x = +".include" foo.test +.include\$x foo.test +EOI +.include foo.test +.include foo.test +EOO + +: none +: +$* <>>foo.test; +$* <>EOO +.include foo.test +EOI +cmd +EOO + +: multiple +: +cat <"cmd foo" >>>foo.test; +cat <"cmd bar" >>>bar.test; +$* <>EOO +.include foo.test bar.test +EOI +cmd foo +cmd bar +EOO + +: once +: +cat <"cmd" >>>foo.test; +$* <>EOO +.include foo.test +x +.include --once foo.test +.include --once bar/../foo.test +y +.include ../once/foo.test +EOI +cmd +x +y +cmd +EOO + +: group-id +: +cat <>>foo.test; +{ + x = b +} +EOI +$* -s -i <>EOO +x = a +.include foo.test +EOI +{ + { # 2-foo-1 + } +} +EOO + +: test-id +: +cat <>>foo.test; +cmd +EOI +$* -s -i <>EOO +x = a +.include foo.test +EOI +{ + { # 2-foo-1 + cmd + } +} +EOO + +: var-expansion +: +cat <>>foo-$(build.version).test; +cmd +EOI +$* <>EOO +.include foo-\$\(build.version\).test +EOI +cmd +EOO + +: after-semi +: +$* <>EOE != 0 +cmd; +.include foo.test +EOI +testscript:2:1: error: directive after ';' +EOE + +: semi-after +: +$* <>EOE != 0 +.include foo.test; +cmd +EOI +testscript:1:18: error: ';' after directive +EOE + +: invalid-path +: +$* <>EOE != 0 +.include "" +EOI +testscript:1:1: error: invalid testscript include path '' +EOE + +: unable-open +: +: Note that the error message is platform specific. +: +$* <- != 0 +.include foo.test +EOI -- cgit v1.1