aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-07-16 15:21:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-07-16 15:54:06 +0200
commit4f63afc1177021d6345502892dbd028f5d6db5eb (patch)
tree9f3919d7d6798a82deab6fd9ebfb1d1802b2030f /tests
parent55e858010b9ba53c27475d9ce6f864a84d28fa81 (diff)
Implement in module
Given test.in containing something along these lines: foo = $foo$ Now we can do: using in file{test}: in{test.in} file{test}: foo = FOO The alternative variable substitution symbol can be specified with the in.symbol variable and lax (instead of the default strict) mode with in.substitution. For example: file{test}: in.symbol = '@' file{test}: in.substitution = lax
Diffstat (limited to 'tests')
-rw-r--r--tests/in/buildfile5
-rw-r--r--tests/in/testscript96
2 files changed, 101 insertions, 0 deletions
diff --git a/tests/in/buildfile b/tests/in/buildfile
new file mode 100644
index 0000000..54d3b90
--- /dev/null
+++ b/tests/in/buildfile
@@ -0,0 +1,5 @@
+# file : tests/in/buildfile
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+./: testscript $b
diff --git a/tests/in/testscript b/tests/in/testscript
new file mode 100644
index 0000000..4cf4ebf
--- /dev/null
+++ b/tests/in/testscript
@@ -0,0 +1,96 @@
+# file : tests/in/testscript
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+crosstest = false
+test.arguments =
+
+.include ../common.test
+
++cat <<EOI >=build/root.build
+using in
+EOI
+
+: basic
+:
+cat <<EOI >=test.in;
+ foo = $foo$
+ EOI
+cat <<EOI >=buildfile;
+ file{test}: in{test}
+ file{test}: foo = FOO
+ EOI
+$* <<<buildfile;
+cat test >>EOO;
+ foo = FOO
+ EOO
+$* clean <<<buildfile
+
+: lax
+:
+cat <<EOI >=test.in;
+ $10
+ $foo bar$ baz
+ EOI
+$* <<EOI &test &test.d;
+ file{test}: in{test}
+ file{test}: in.substitution = lax
+ EOI
+cat test >>EOO
+ $10
+ $foo bar$ baz
+ EOO
+
+: rebuild
+:
+cat <'$foo$ $bar$' >=test.in;
+$* <<EOI &test &test.d;
+ foo = foo
+ bar = bar
+ file{test}: in{test}
+ EOI
+cat test >'foo bar';
+$* <<EOI;
+ foo = FOO
+ bar = bar
+ file{test}: in{test}
+ EOI
+cat test >'FOO bar';
+$* <<EOI;
+ foo = FOO
+ bar = BAR
+ file{test}: in{test}
+ EOI
+cat test >'FOO BAR';
+cat <'$fox$ $baz$' >=test.in;
+$* <<EOI;
+ fox = fox
+ baz = baz
+ file{test}: in{test}
+ EOI
+cat test >'fox baz';
+mv test.in tst.in;
+$* <<EOI;
+ fox = FOX
+ baz = BAZ
+ file{test}: in{tst.in}
+ EOI
+cat test >'FOX BAZ'
+
+: rebuild-diag
+:
+cat <<EOI >=test.in;
+ foo = $foo$
+ bar = $bar$
+ EOI
+$* <<EOI &test &test.d;
+ foo = foo
+ bar = bar
+ file{test}: in{test}
+ EOI
+$* <<EOI 2>>EOE != 0
+ foo = foo
+ file{test}: in{test}
+ EOI
+ test.in:2: error: undefined variable 'bar'
+ EOE