aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-21 11:03:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-21 11:03:37 +0200
commita14daf38475a414e462708d9b0f4d651e5119b58 (patch)
treefa77c802d8bc7b16d91236c360853a164f13e761 /tests
parente4c4d8d65ea675eaa56c85661ba42e112ab70f4b (diff)
Add support for target and prerequisite specific variable blocks
For example, now instead of: lib{foo}: cxx.loptions += -static lib{foo}: cxx.libs += -lpthread We can write: lib{foo}: { cxx.loptions += -static cxx.libs += -lpthread } The same works for prerequisites as well as target type/patterns. For example: exe{*.test}: { test = true install = false }
Diffstat (limited to 'tests')
-rw-r--r--tests/directive/run.testscript2
-rw-r--r--tests/name/pattern.testscript6
-rw-r--r--tests/variable/prerequisite-specific/testscript52
-rw-r--r--tests/variable/scope-specific/testscript2
-rw-r--r--tests/variable/target-specific/testscript36
-rw-r--r--tests/variable/target-type-pattern-specific/buildfile5
-rw-r--r--tests/variable/target-type-pattern-specific/testscript58
7 files changed, 154 insertions, 7 deletions
diff --git a/tests/directive/run.testscript b/tests/directive/run.testscript
index ba4a413..88ea909 100644
--- a/tests/directive/run.testscript
+++ b/tests/directive/run.testscript
@@ -32,6 +32,6 @@ EOE
:
cat <'print run' >=buildfile;
$* <"run '$0' noop" 2>>"EOE" != 0
-<stdout>:1:4: error: executable name expected after run
+<stdout>:1:4: error: expected executable name after run
<stdin>:1:5: info: while parsing $0 output
EOE
diff --git a/tests/name/pattern.testscript b/tests/name/pattern.testscript
index 1c9d6f5..07ff863 100644
--- a/tests/name/pattern.testscript
+++ b/tests/name/pattern.testscript
@@ -45,19 +45,19 @@ EOI
: simple
:
$* <'print {*.txt +foo file{bar}}' 2>>EOE != 0
- <stdin>:1:19: error: name pattern inclusion or exclusion expected
+ <stdin>:1:19: error: expected name pattern inclusion or exclusion
EOE
: inclusion-exclusion-sign
:
$* <'print {*.txt -foo bar}' 2>>EOE != 0
- <stdin>:1:19: error: name pattern inclusion or exclusion expected
+ <stdin>:1:19: error: expected name pattern inclusion or exclusion
EOE
: inclusion-quoted
:
$* <'print {*.txt -foo "+bar"}' 2>>EOE != 0
- <stdin>:1:19: error: name pattern inclusion or exclusion expected
+ <stdin>:1:19: error: expected name pattern inclusion or exclusion
EOE
: empty-inclusion-exclusion
diff --git a/tests/variable/prerequisite-specific/testscript b/tests/variable/prerequisite-specific/testscript
index ef14cfc..ed7c60b 100644
--- a/tests/variable/prerequisite-specific/testscript
+++ b/tests/variable/prerequisite-specific/testscript
@@ -62,6 +62,58 @@ EOI
}
EOE
+: block
+:
+$* <<EOI 2>>/~%EOE%
+foo = COX
+dir{x}: foo = FOX
+dir{x}: dir{a}:
+{
+ foo = FOO
+ bar = BAR
+}
+dump dir{x}
+EOI
+<stdin>:8:1: dump:
+% .+/dir\{x/\}:%
+ {
+ foo = FOX
+ }
+% .+/dir\{x/\}: .+:dir\{a/\}:%
+ {
+ bar = BAR
+ foo = FOO
+ }
+EOE
+
+: block-multiple
+:
+$* <<EOI 2>>/~%EOE%
+dir{y}: foo = FOX
+dir{x} dir{y}: dir{a} dir{b}:
+{
+ foo += FOO
+ bar = BAR $foo
+}
+dump dir{y}
+EOI
+<stdin>:7:1: dump:
+% .+/dir\{y/\}:%
+ {
+ foo = FOX
+ }
+% .+/dir\{y/\}: .+:dir\{a/\}:%
+ {
+ bar = BAR FOX FOO
+ foo = FOX FOO
+ }
+% .+/dir\{y/\}: .+:dir\{b/\}:%
+ {
+ bar = BAR FOX FOO
+ foo = FOX FOO
+ }
+EOE
+
: chain
:
$* <<EOI 2>>/~%EOE%
diff --git a/tests/variable/scope-specific/testscript b/tests/variable/scope-specific/testscript
index 5f9a05d..13e7eca 100644
--- a/tests/variable/scope-specific/testscript
+++ b/tests/variable/scope-specific/testscript
@@ -42,7 +42,7 @@ EOO
$* <<EOI 2>>EOE != 0
foo/ [uint64] y
EOI
-<stdin>:1:16: error: variable assignment expected instead of <newline>
+<stdin>:1:16: error: expected variable assignment instead of <newline>
EOE
: unexpected-attribute
diff --git a/tests/variable/target-specific/testscript b/tests/variable/target-specific/testscript
index 497c863..8b0a846 100644
--- a/tests/variable/target-specific/testscript
+++ b/tests/variable/target-specific/testscript
@@ -1,10 +1,10 @@
-# file : tests/variable/scope-specific/testscript
+# file : tests/variable/target-specific/testscript
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
.include ../../common.testscript
-: basic-line
+: basic
:
$* <<EOI >>EOO
x = x
@@ -25,6 +25,38 @@ X
Z
EOO
+: block
+:
+$* <<EOI >>EOO
+x = x
+./:
+{
+ x = X
+ y = $x
+}
+print $(./: x)
+print $(./: y)
+EOI
+X
+X
+EOO
+
+: block-multiple
+:
+$* <<EOI >>EOO
+x = x
+file{foo} file{bar}:
+{
+ x += X
+ y = $x
+}
+print $(file{foo}: y)
+print $(file{bar}: y)
+EOI
+x X
+x X
+EOO
+
: eval-qual
:
$* <<EOI >>EOO
diff --git a/tests/variable/target-type-pattern-specific/buildfile b/tests/variable/target-type-pattern-specific/buildfile
new file mode 100644
index 0000000..efed550
--- /dev/null
+++ b/tests/variable/target-type-pattern-specific/buildfile
@@ -0,0 +1,5 @@
+# file : tests/variable/target-type-pattern-specific/buildfile
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+./: testscript $b
diff --git a/tests/variable/target-type-pattern-specific/testscript b/tests/variable/target-type-pattern-specific/testscript
new file mode 100644
index 0000000..e60dbe1
--- /dev/null
+++ b/tests/variable/target-type-pattern-specific/testscript
@@ -0,0 +1,58 @@
+# file : tests/variable/target-type-pattern-specific/testscript
+# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+# NOTE: see also old tests.
+
+.include ../../common.testscript
+
+: basic
+:
+$* <<EOI >>EOO
+x = x
+y = y
+dir{*}: x = X
+dir{*}: y += Y
+print $(./: x)
+print $(./: y)
+EOI
+X
+y Y
+EOO
+
+: block
+:
+$* <<EOI >>EOO
+x = x
+y = y
+dir{*}:
+{
+ x = X
+ y += Y
+ z = $x # Note: from scope.
+}
+print $(./: x)
+print $(./: y)
+print $(./: z)
+EOI
+X
+y Y
+x
+EOO
+
+: block-multiple
+:
+$* <<EOI >>EOO
+x = x
+y = y
+file{f*} file{b*}:
+{
+ x = X
+ y += Y
+}
+print $(file{foo}: x)
+print $(file{bar}: y)
+EOI
+X
+y Y
+EOO