aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-03 17:54:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:37 +0200
commit554475390b6d2912614778fe50788a09f99ac6a4 (patch)
tree2cc756aa363f0697291b4cbf8e7a9365bf65629b /unit-tests/test/script
parent7ebe4aa8d07e8845f1669e2d43fbe6071d3ee463 (diff)
Implement testscript inclusion support
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r--unit-tests/test/script/parser/buildfile2
-rw-r--r--unit-tests/test/script/parser/include.test140
2 files changed, 141 insertions, 1 deletions
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
+:
+$* <<EOI >>EOO
+x =
+".include" foo.test
+.include\$x foo.test
+EOI
+.include foo.test
+.include foo.test
+EOO
+
+: none
+:
+$* <<EOI
+.include
+.include --once
+EOI
+
+: empty
+:
+touch foo.test &foo.test; #@@ TMP
+$* <<EOI
+.include foo.test
+.include --once foo.test
+EOI
+
+: one
+:
+cat <"cmd" >>>foo.test;
+$* <<EOI >>EOO
+.include foo.test
+EOI
+cmd
+EOO
+
+: multiple
+:
+cat <"cmd foo" >>>foo.test;
+cat <"cmd bar" >>>bar.test;
+$* <<EOI >>EOO
+.include foo.test bar.test
+EOI
+cmd foo
+cmd bar
+EOO
+
+: once
+:
+cat <"cmd" >>>foo.test;
+$* <<EOI >>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 <<EOI >>>foo.test;
+{
+ x = b
+}
+EOI
+$* -s -i <<EOI >>EOO
+x = a
+.include foo.test
+EOI
+{
+ { # 2-foo-1
+ }
+}
+EOO
+
+: test-id
+:
+cat <<EOI >>>foo.test;
+cmd
+EOI
+$* -s -i <<EOI >>EOO
+x = a
+.include foo.test
+EOI
+{
+ { # 2-foo-1
+ cmd
+ }
+}
+EOO
+
+: var-expansion
+:
+cat <<EOI >>>foo-$(build.version).test;
+cmd
+EOI
+$* <<EOI >>EOO
+.include foo-\$\(build.version\).test
+EOI
+cmd
+EOO
+
+: after-semi
+:
+$* <<EOI 2>>EOE != 0
+cmd;
+.include foo.test
+EOI
+testscript:2:1: error: directive after ';'
+EOE
+
+: semi-after
+:
+$* <<EOI 2>>EOE != 0
+.include foo.test;
+cmd
+EOI
+testscript:1:18: error: ';' after directive
+EOE
+
+: invalid-path
+:
+$* <<EOI 2>>EOE != 0
+.include ""
+EOI
+testscript:1:1: error: invalid testscript include path ''
+EOE
+
+: unable-open
+:
+: Note that the error message is platform specific.
+:
+$* <<EOI 2>- != 0
+.include foo.test
+EOI