diff options
Diffstat (limited to 'tests/recipe/buildscript/testscript')
-rw-r--r-- | tests/recipe/buildscript/testscript | 1080 |
1 files changed, 1035 insertions, 45 deletions
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript index 910ee67..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 @@ -108,7 +108,7 @@ posix = ($cxx.target.class != 'windows') $* clean 2>- } - : untracked-var + : computed-var : { cat <<EOI >=buildfile; @@ -121,9 +121,29 @@ posix = ($cxx.target.class != 'windows') }} EOI + $* 2>>EOE != 0 + buildfile:6:10: error: expansion of computed variable is only allowed in depdb preamble + info: consider using 'depdb' builtin to track its value changes + EOE + } + + : untracked-var + : + { + cat <<EOI >=buildfile; + a = a + b = b + foo: + {{ + x = true + y = $($x ? a : b) + depdb env BOGUS + echo $y >$path($>) + }} + EOI + $* 2>>~%EOE% != 0; - echo file{foo} - buildfile:6:10: error: use of untracked variable 'a' + buildfile:6:8: error: use of untracked variable 'a' info: use the 'depdb' builtin to manually track it %.+ EOE @@ -155,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 : { @@ -201,17 +240,19 @@ posix = ($cxx.target.class != 'windows') a = $process.run(cat baz) foo: bar {{ + x = true + y = $($x ? a : b) depdb hash "$a" + diag compose $> cp $path($<) $path($>) - x = true - echo "$($x ? a : b)" >>$path($>) + echo $y >>$path($>) }} EOI - $* 2>'compose file{foo.}'; + $* 2>'compose file{foo}'; cat <<<foo >>EOO; bar @@ -227,7 +268,7 @@ posix = ($cxx.target.class != 'windows') echo 'BAR' >=bar; - $* 2>'compose file{foo.}'; + $* 2>'compose file{foo}'; cat <<<foo >>EOO; BAR @@ -238,7 +279,7 @@ posix = ($cxx.target.class != 'windows') echo 'BAZ' >=baz; - $* 2>'compose file{foo.}'; + $* 2>'compose file{foo}'; cat <<<foo >>EOO; BAR @@ -335,7 +376,7 @@ posix = ($cxx.target.class != 'windows') }} EOI - $* 2>'echo file{foo.}'; + $* 2>'echo file{foo}'; $* clean 2>- } @@ -465,7 +506,7 @@ posix = ($cxx.target.class != 'windows') : normal : { - cat <<EOI >=bar.h; + cat <<EOI >=bar.h; bar EOI @@ -497,23 +538,23 @@ posix = ($cxx.target.class != 'windows') }} EOI - $* 2>>EOE; - gen h{baz.h} - gen h{foo.h} + $* 2>>EOE; + gen h{baz} + gen h{foo} EOE - cat foo.h >>EOO; - bar - baz - EOO + cat foo.h >>EOO; + bar + baz + EOO - $* clean 2>- + $* clean 2>- } : byproduct : { - cat <<EOI >=bar.h; + cat <<EOI >=bar.h; bar EOI @@ -540,17 +581,17 @@ posix = ($cxx.target.class != 'windows') }} EOI - $* 2>>EOE; - gen h{baz.h} - gen h{foo.h} + $* 2>>EOE; + gen h{baz} + gen h{foo} EOE - cat foo.h >>EOO; - bar - baz - EOO + cat foo.h >>EOO; + bar + baz + EOO - $* clean 2>- + $* clean 2>- } } } @@ -601,7 +642,7 @@ posix = ($cxx.target.class != 'windows') EOI $* test 2>>EOE; - cp file{foo} + cp file{bar} -> file{foo} test file{foo} EOE @@ -663,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 @@ -700,6 +741,30 @@ posix = ($cxx.target.class != 'windows') $* clean 2>- } +: canned-cmdline +: +{ + cat <<EOI >=buildfile; + ./: + {{ + x = echo >| + y = [cmdline] echo >| + diag update $> + $x foo + $y bar + ([cmdline] $x) baz + }} + EOI + + $* >> EOO 2>>/EOE + bar + baz + EOO + update dir{./} + >| foo + EOE +} + : timeout : if $posix @@ -723,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 @@ -748,7 +814,7 @@ if $posix EOI $* 2>>EOE; - update file{foo} + update file{bar} -> file{foo} EOE $* clean 2>- @@ -775,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 @@ -811,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 @@ -831,11 +899,933 @@ if $posix alias{~'/f(.+)/'}: alias{~'/b\1/'} {{ - diag $< $> + diag frob $< -> $> }} EOI $* 2>>EOE - alias{bar} alias{far} + frob alias{bar} -> alias{far} EOE } + +: loop +: +{ + : while + : + { + : basics + : + { + echo 'bar' >=bar; + + cat <<EOI >=buildfile; + foo: bar + {{ + p = $path($>) + while test -f $p != 0 + cp $path($<) $p + end + }} + EOI + + $* 2>'cp file{bar} -> file{foo}'; + + cat <<<foo >'bar'; + + $* 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 + : + { + : form-1 + : + : for x: ... + : + { + : basics + : + { + echo 'bar' >=bar; + echo 'baz' >=baz; + + cat <<EOI >=buildfile; + foo: bar baz + {{ + p = $path($>) + rm -f $p + + for f: $< + cat $path($f) >>$p + end + }} + EOI + + $* 2>'cat file{bar} -> file{foo}'; + + cat <<<foo >>EOO; + bar + baz + EOO + + $* 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 + : + { + : inside + : + { + echo 'bar' >=bar; + + cat <<EOI >=buildfile; + foo: bar + {{ + for f: $< + depdb hash $f + end + + p = $path($>) + rm -f $p + + for f: $< + cat $path($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 f: $< + echo $path($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 f: $< + h += $path($f) + end + + depdb hash $h + + p = $path($>) + rm -f $p + + for f: $< + cat $path($f) >>$p + end + }} + EOI + + $* 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>- + } + } + } + } +} |