aboutsummaryrefslogtreecommitdiff
path: root/tests/recipe/buildscript/testscript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/recipe/buildscript/testscript')
-rw-r--r--tests/recipe/buildscript/testscript886
1 files changed, 841 insertions, 45 deletions
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript
index 0ac5d5a..cded5ea 100644
--- a/tests/recipe/buildscript/testscript
+++ b/tests/recipe/buildscript/testscript
@@ -31,7 +31,7 @@ posix = ($cxx.target.class != 'windows')
}}
EOI
- $* 2>'cp file{foo}';
+ $* 2>'cp file{bar} -> file{foo}';
cat <<<foo >'bar';
@@ -65,9 +65,9 @@ posix = ($cxx.target.class != 'windows')
EOI
$* 2>>~%EOE% != 0;
- concat file{bar.}
+ concat file{bar}
%cat: unable to print '.+bar.baz': .+%
- buildfile:10:3: error: cat exited with code 1
+ buildfile:10:3: error: builtin cat exited with code 1
%.+
EOE
@@ -75,7 +75,7 @@ posix = ($cxx.target.class != 'windows')
echo 'baz' >=bar.baz;
- $* 2>'concat file{bar.}';
+ $* 2>'concat file{bar}';
cat <<<foo >>EOO;
bar
@@ -100,7 +100,7 @@ posix = ($cxx.target.class != 'windows')
EOI
$* 2>>~%EOE% != 0;
- cp file{foo}
+ cp file{bar} -> file{foo}
buildfile:4:3: error: stdout and stderr redirected to each other
%.+
EOE
@@ -175,13 +175,32 @@ posix = ($cxx.target.class != 'windows')
EOI
$* test 2>>EOE;
- cp exe{foo}
- test exe{foo.}
+ cp file{bar} -> exe{foo}
+ test exe{foo}
EOE
$* clean 2>-
}
+ : diag
+ :
+ {
+ cat <<EOI >=buildfile;
+ foo:
+ {{
+ v1 = foo
+ echo bar | set v2
+ diag echo "$v1 $v2" -> $>
+ echo "$v1 $v2" >$path($>)
+ }}
+ EOI
+
+ $* 2>'echo foo bar -> file{foo}';
+ cat <<<foo >'foo bar';
+
+ $* clean 2>-
+ }
+
: depdb
:
{
@@ -233,7 +252,7 @@ posix = ($cxx.target.class != 'windows')
}}
EOI
- $* 2>'compose file{foo.}';
+ $* 2>'compose file{foo}';
cat <<<foo >>EOO;
bar
@@ -249,7 +268,7 @@ posix = ($cxx.target.class != 'windows')
echo 'BAR' >=bar;
- $* 2>'compose file{foo.}';
+ $* 2>'compose file{foo}';
cat <<<foo >>EOO;
BAR
@@ -260,7 +279,7 @@ posix = ($cxx.target.class != 'windows')
echo 'BAZ' >=baz;
- $* 2>'compose file{foo.}';
+ $* 2>'compose file{foo}';
cat <<<foo >>EOO;
BAR
@@ -357,7 +376,7 @@ posix = ($cxx.target.class != 'windows')
}}
EOI
- $* 2>'echo file{foo.}';
+ $* 2>'echo file{foo}';
$* clean 2>-
}
@@ -520,8 +539,8 @@ posix = ($cxx.target.class != 'windows')
EOI
$* 2>>EOE;
- gen h{baz.h}
- gen h{foo.h}
+ gen h{baz}
+ gen h{foo}
EOE
cat foo.h >>EOO;
@@ -563,8 +582,8 @@ posix = ($cxx.target.class != 'windows')
EOI
$* 2>>EOE;
- gen h{baz.h}
- gen h{foo.h}
+ gen h{baz}
+ gen h{foo}
EOE
cat foo.h >>EOO;
@@ -623,7 +642,7 @@ posix = ($cxx.target.class != 'windows')
EOI
$* test 2>>EOE;
- cp file{foo}
+ cp file{bar} -> file{foo}
test file{foo}
EOE
@@ -685,7 +704,7 @@ posix = ($cxx.target.class != 'windows')
EOI
$* test 2>>EOE;
- cp file{foo}
+ cp file{bar} -> file{foo}
test file{foo}
bar
EOE
@@ -730,18 +749,18 @@ posix = ($cxx.target.class != 'windows')
{{
x = echo >|
y = [cmdline] echo >|
- diag update
+ diag update $>
$x foo
$y bar
([cmdline] $x) baz
}}
EOI
- $* >> EOO 2>>EOE
+ $* >> EOO 2>>/EOE
bar
baz
EOO
- update
+ update dir{./}
>| foo
EOE
}
@@ -769,8 +788,9 @@ if $posix
EOI
$* 2>>~%EOE% != 0;
- update file{foo}
- buildfile:6:3: error: ^sleep terminated: execution timeout expired
+ update file{bar} -> file{foo}
+ buildfile:6:3: error: process ^sleep terminated: execution timeout expired
+ info: command line: sleep 5
info: while updating file{foo}
%.+
EOE
@@ -794,7 +814,7 @@ if $posix
EOI
$* 2>>EOE;
- update file{foo}
+ update file{bar} -> file{foo}
EOE
$* clean 2>-
@@ -821,16 +841,18 @@ if $posix
EOI
$* test config.test.timeout=1 2>>~%EOE% != 0;
- cp file{foo}
+ cp file{bar} -> file{foo}
test file{foo}
- buildfile:7:3: error: ^sleep terminated: execution timeout expired
+ buildfile:7:3: error: process ^sleep terminated: execution timeout expired
+ info: command line: sleep 5
info: while testing file{foo}
%.+
EOE
$* test config.test.timeout=/1 2>>~%EOE% != 0;
test file{foo}
- buildfile:7:3: error: ^sleep terminated: execution timeout expired
+ buildfile:7:3: error: process ^sleep terminated: execution timeout expired
+ info: command line: sleep 5
info: while testing file{foo}
%.+
EOE
@@ -857,7 +879,7 @@ if $posix
EOI
$* test config.test.timeout=3 2>>EOE;
- cp file{foo}
+ cp file{bar} -> file{foo}
test file{foo}
EOE
@@ -877,38 +899,173 @@ if $posix
alias{~'/f(.+)/'}: alias{~'/b\1/'}
{{
- diag $< $>
+ diag frob $< -> $>
}}
EOI
$* 2>>EOE
- alias{bar} alias{far}
+ frob alias{bar} -> alias{far}
EOE
}
-: flow-control-construct
+: loop
:
{
: while
:
{
- echo 'bar' >=bar;
+ : basics
+ :
+ {
+ echo 'bar' >=bar;
- cat <<EOI >=buildfile;
- foo: bar
- {{
- p = $path($>)
- while test -f $p != 0
- cp $path($<) $p
- end
- }}
- EOI
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ while test -f $p != 0
+ cp $path($<) $p
+ end
+ }}
+ EOI
- $* 2>'cp file{foo}';
+ $* 2>'cp file{bar} -> file{foo}';
- cat <<<foo >'bar';
+ cat <<<foo >'bar';
- $* clean 2>-
+ $* clean 2>-
+ }
+
+ : exit
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ while test -f $p != 0
+ touch $p
+ exit
+ cp $path($<) $p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+
+ cat <<<foo >:'';
+
+ $* clean 2>-
+ }
+
+ : error
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ while test -f $p != 0
+ touch $p
+ exit 'fed up'
+ cp $path($<) $p
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ gen file{foo}
+ buildfile:8:5: error: fed up
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : depdb
+ :
+ {
+ : inside
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ while test -f $p != 0
+ depdb hash $p
+ cp $path($<) $p
+ end
+ }}
+ EOI
+
+ $* 2>>EOE != 0
+ buildfile:5:5: error: 'depdb' call inside flow control construct
+ EOE
+ }
+
+ : after-commands
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ while test -f $p != 0
+ cp $path($<) $p
+ end
+
+ depdb hash $p
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ buildfile:5:5: error: disallowed command in depdb preamble
+ info: only variable assignments are allowed in depdb preamble
+ buildfile:8:3: info: depdb preamble ends here
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : after-vars
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($<)
+
+ h =
+ while test -f $p != 0
+ h += $p
+ end
+
+ depdb hash $p
+
+ cat $p >$path($>)
+ }}
+ EOI
+
+ $* 2>'cat file{bar} -> file{foo}';
+ $* clean 2>-
+ }
+ }
}
: for
@@ -937,7 +1094,7 @@ if $posix
}}
EOI
- $* 2>'cat file{foo}';
+ $* 2>'cat file{bar} -> file{foo}';
cat <<<foo >>EOO;
bar
@@ -947,6 +1104,119 @@ if $posix
$* clean 2>-
}
+ : pair
+ :
+ {
+ mkdir -p src/build;
+ echo 'bar' >=src/bar;
+ echo 'baz' >=src/baz;
+
+ echo 'project =' >=src/build/bootstrap.build;
+
+ cat <<EOI >=src/buildfile;
+ foo: file{bar}@./ file{baz}@./
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ end
+ }}
+ EOI
+
+ $* src/@out/ 2>>/EOE;
+ mkdir fsdir{out/}
+ cat src/file{bar} -> out/file{foo}
+ EOE
+
+ cat <<<out/foo >>EOO;
+ bar
+ baz
+ EOO
+
+ $* 'clean:' src/@out/ 2>-
+ }
+
+ : special-var
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for ~: $<
+ cat $path($f) >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>EOE != 0
+ buildfile:6:7: error: attempt to set '~' special variable
+ EOE
+ }
+
+ : exit
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ exit
+ end
+ }}
+ EOI
+
+ $* 2>'cat file{bar} -> file{foo}';
+
+ cat <<<foo >>EOO;
+ bar
+ EOO
+
+ $* clean 2>-
+ }
+
+ : error
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ exit 'fed up'
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ cat file{bar} -> file{foo}
+ buildfile:8:5: error: fed up
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
: depdb
:
{
@@ -1026,7 +1296,533 @@ if $posix
}}
EOI
- $* 2>'cat file{foo}';
+ $* 2>'cat file{bar} -> file{foo}';
+ $* clean 2>-
+ }
+ }
+ }
+
+ : form-2
+ :
+ : ... | for x
+ :
+ {
+ : basics
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar baz
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for -w f
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+
+ cat <<<foo >>EOO;
+ bar
+ baz
+ EOO
+
+ $* clean 2>-
+ }
+
+ : special-var
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for ~
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ gen file{foo}
+ buildfile:8:3: error: attempt to set '~' special variable
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : misuse
+ :
+ {
+ : after-var
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for x:
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ gen file{foo}
+ buildfile:8:3: error: for: ':' after variable name
+ %.+
+ EOE
+
+ $* 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
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for -w f
+ cat $f >>$p
+ exit
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+
+ cat <<<foo >>EOO;
+ bar
+ EOO
+
+ $* clean 2>-
+ }
+
+ : error
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for -w f
+ cat $f >>$p
+ exit 'fed up'
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ gen file{foo}
+ buildfile:10:5: error: fed up
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : depdb
+ :
+ {
+ : inside
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ echo $path($<) | for -w f
+ depdb hash $f
+ end
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for -w f
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>EOE != 0
+ buildfile:4:5: error: 'depdb' call inside flow control construct
+ EOE
+ }
+
+ : after-commands
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ echo $path($<) | for -w f
+ echo $f >-
+ end
+
+ depdb hash $p
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ buildfile:4:5: error: disallowed command in depdb preamble
+ info: only variable assignments are allowed in depdb preamble
+ buildfile:7:3: info: depdb preamble ends here
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : after-vars
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ h =
+ echo $path($<) | for -w f
+ h += $f
+ end
+
+ depdb hash $h
+
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+ $* clean 2>-
+ }
+ }
+ }
+
+ : form-3
+ :
+ : for x <...
+ :
+ {
+ : basics
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar baz
+ {{
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ for -w f <<"EOF"
+ $path($<)
+ EOF
+ cat $f >>$p
+ end
+
+ for <<"EOF" -w f
+ $path($<)
+ EOF
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+
+ cat <<<foo >>EOO;
+ bar
+ baz
+ bar
+ baz
+ EOO
+
+ $* clean 2>-
+ }
+
+ : quoting
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar baz
+ {{
+ n = 'gen'
+ diag "($n)" ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ o = -w
+ for "$o" f <<"EOF"
+ $path($<)
+ EOF
+ cat $f >>$p
+ end
+
+ o = -n
+ for "($o)" f <<"EOF"
+ $path($<)
+ EOF
+ echo $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
+
+ cat <<<foo >>~%EOO%;
+ bar
+ baz
+ %.+bar .+baz%
+ EOO
+
+ $* clean 2>-
+ }
+
+ : special-var
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for ~ <<<$path($<)
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>EOE != 0
+ buildfile:6:6: error: attempt to set '~' special variable
+ EOE
+ }
+
+ : exit
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f <<<$path($<)
+ cat $f >>$p
+ exit
+ end
+ }}
+ EOI
+
+ $* 2>'cat file{bar} -> file{foo}';
+
+ cat <<<foo >>EOO;
+ bar
+ EOO
+
+ $* clean 2>-
+ }
+
+ : error
+ :
+ {
+ echo 'bar' >=bar;
+ echo 'baz' >=baz;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f <<<$path($<)
+ cat $f >>$p
+ exit 'fed up'
+ end
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ cat file{bar} -> file{foo}
+ buildfile:8:5: error: fed up
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : depdb
+ :
+ {
+ : inside
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ for -w f <<<$path($<)
+ depdb hash $f
+ end
+
+ p = $path($>)
+ rm -f $p
+
+ echo $path($<) | for -w f
+ cat $f >>$p
+ end
+ }}
+ EOI
+
+ $* 2>>EOE != 0
+ buildfile:4:5: error: 'depdb' call inside flow control construct
+ EOE
+ }
+
+ : after-commands
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ for -w f <<<$path($<)
+ echo $f >-
+ end
+
+ depdb hash a
+ }}
+ EOI
+
+ $* 2>>~%EOE% != 0;
+ buildfile:4:5: error: disallowed command in depdb preamble
+ info: only variable assignments are allowed in depdb preamble
+ buildfile:7:3: info: depdb preamble ends here
+ %.{3}
+ EOE
+
+ $* clean 2>-
+ }
+
+ : after-vars
+ :
+ {
+ echo 'bar' >=bar;
+
+ cat <<EOI >=buildfile;
+ foo: bar
+ {{
+ h =
+ for -w f <<<$path($<)
+ h += $f
+ end
+
+ depdb hash $h
+
+ diag gen ($>)
+
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ end
+ }}
+ EOI
+
+ $* 2>'gen file{foo}';
$* clean 2>-
}
}