aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/recipe/buildscript/testscript71
-rw-r--r--tests/test/script/runner/for.testscript55
-rw-r--r--tests/test/script/runner/set.testscript14
3 files changed, 99 insertions, 41 deletions
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript
index 94eb665..6d33888 100644
--- a/tests/recipe/buildscript/testscript
+++ b/tests/recipe/buildscript/testscript
@@ -1332,30 +1332,63 @@ if $posix
: misuse
:
{
- echo 'bar' >=bar;
- echo 'baz' >=baz;
+ : after-var
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
- cat <<EOI >=buildfile;
- foo: bar
- {{
- diag gen ($>)
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
- p = $path($>)
- rm -f $p
+ p = $path($>)
+ rm -f $p
- echo $path($<) | for x:
- cat $f >>$p
- end
- }}
- EOI
+ echo $path($<) | for x:
+ cat $f >>$p
+ end
+ }}
+ EOI
- $* 2>>~%EOE% != 0;
- gen file{foo.}
- buildfile:8:3: error: for: ':' after variable name
- %.+
- EOE
+ $* 2>>~%EOE% != 0;
+ gen file{foo.}
+ buildfile:8:3: error: for: ':' after variable name
+ %.+
+ EOE
- $* clean 2>-
+ $* clean 2>-
+ }
+
+ : after-attrs
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for x [path]:
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ gen file{foo.}
+ <attributes>:1:7: error: whitespace required after attributes
+ <attributes>:1:1: info: use the '\[' escape sequence if this is a wildcard pattern
+ buildfile:8:3: info: while parsing attributes '[path]:'
+ %.+
+ EOE
+
+ $* clean 2>-
+ }
}
: exit
diff --git a/tests/test/script/runner/for.testscript b/tests/test/script/runner/for.testscript
index 658ff49..765b978 100644
--- a/tests/test/script/runner/for.testscript
+++ b/tests/test/script/runner/for.testscript
@@ -33,11 +33,11 @@
: special-var
:
$c <<EOI && $b 2>>EOE != 0
- for *: -a -b
- echo $* >|
+ for ~: -a -b
+ echo $~ >|
end
EOI
- testscript:1:5: error: attempt to set '*' variable directly
+ testscript:1:5: error: attempt to set '~' variable directly
EOE
: exit
@@ -109,7 +109,7 @@
: typed
:
$c <<EOI && $b >>/EOO
- echo "a b" | for -w [dir_path] x
+ echo "a b" | for -w x [dir_path]
echo $x >|
end
EOI
@@ -208,24 +208,49 @@
: special-var
:
$c <<EOI && $b 2>>EOE != 0
- echo "a b" | for -w *
+ echo "a b" | for -w ~
echo $* >|
end
EOI
- testscript:1:1: error: attempt to set '*' variable directly
+ testscript:1:1: error: attempt to set '~' variable directly
info: test id: 1
EOE
- : misuse
+ : unsep-attrs
:
$c <<EOI && $b 2>>EOE != 0
- echo "a b" | for v:
- echo $v >|
+ echo "a b" | for -w x[string]
+ echo $x >|
end
EOI
- testscript:1:19: error: expected newline instead of ':'
+ testscript:1:1: error: for: expected variable name instead of x[string]
+ info: test id: 1
EOE
+ : misuse
+ :
+ {
+ : after-var
+ :
+ $c <<EOI && $b 2>>EOE != 0
+ echo "a b" | for v:
+ echo $v >|
+ end
+ EOI
+ testscript:1:19: error: expected newline instead of ':'
+ EOE
+
+ : after-attrs
+ :
+ $c <<EOI && $b 2>>EOE != 0
+ echo "a b" | for v [string]:
+ echo $v >|
+ end
+ EOI
+ testscript:1:28: error: expected newline instead of ':'
+ EOE
+ }
+
: exit
:
$c <<EOI && $b >>EOO
@@ -343,7 +368,7 @@
: typed
:
$c <<EOI && $b >>/EOO
- for -w [dir_path] x <"a b"
+ for -w x [dir_path] <"a b"
echo $x >|
end
EOI
@@ -354,7 +379,7 @@
: typed-no-ops
:
$c <<EOI && $b >>/EOO
- for [dir_path] x <"a b"
+ for x [dir_path] <"a b"
echo $x >|
end
EOI
@@ -443,11 +468,11 @@
: special-var
:
$c <<EOI && $b 2>>EOE != 0
- for * <"a b"
- echo $* >|
+ for ~ <"a b"
+ echo $~ >|
end
EOI
- testscript:1:5: error: attempt to set '*' variable directly
+ testscript:1:5: error: attempt to set '~' variable directly
EOE
: exit
diff --git a/tests/test/script/runner/set.testscript b/tests/test/script/runner/set.testscript
index b4c8089..b22e3f0 100644
--- a/tests/test/script/runner/set.testscript
+++ b/tests/test/script/runner/set.testscript
@@ -76,7 +76,7 @@
: empty-attrs
:
- $c <"set '' baz" && $b 2>>EOE != 0
+ $c <"set baz ''" && $b 2>>EOE != 0
testscript:1:1: error: set: empty variable attributes
info: test id: 1
EOE
@@ -546,14 +546,14 @@
: dir_path
:
$c <<EOI && $b
- set [dir_path] bar <'foo';
+ set bar [dir_path] <'foo';
echo $bar >/'foo/'
EOI
: null
:
$c <<EOI && $b
- set [null] foo <-;
+ set foo [null] <-;
echo $foo >''
EOI
@@ -571,7 +571,7 @@
: empty-brackets
:
$c <<EOI && $b 2>>EOE != 0
- set -w '[]' baz <'foo bar';
+ set -w baz '[]' <'foo bar';
echo "$baz"
EOI
testscript:2:8: error: concatenating variable expansion contains multiple values
@@ -580,7 +580,7 @@
: no-left-bracket
:
$c <<EOI && $b 2>>EOE != 0
- set -w x baz
+ set -w baz x
EOI
<attributes>:1:1: error: expected '[' instead of 'x'
testscript:1:1: info: while parsing attributes 'x'
@@ -590,7 +590,7 @@
: unknown
:
$c <<EOI && $b 2>>EOE != 0
- set -w [x] baz
+ set -w baz [x]
EOI
<attributes>:1:1: error: unknown value attribute x
testscript:1:1: info: while parsing attributes '[x]'
@@ -600,7 +600,7 @@
: junk
:
$c <<EOI && $b 2>>EOE != 0
- set -w '[string] x' baz
+ set -w baz '[string] x'
EOI
<attributes>:1:10: error: trailing junk after ']'
testscript:1:1: info: while parsing attributes '[string] x'