aboutsummaryrefslogtreecommitdiff
path: root/tests/variable
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/variable
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/variable')
-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
5 files changed, 150 insertions, 3 deletions
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