# file : tests/recipe/buildscript/testscript # license : MIT; see accompanying LICENSE file +mkdir build +cat <=build/bootstrap.build project = test amalgamation = subprojects = using config using test EOI +cat <=build/root.build EOI : update : { : success : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ cp $path($<) $path($>) }} EOI $* 2>'cp file{foo}'; cat <<'bar'; # While at it, make sure there is no rebuild. # $* 2>/'info: dir{./} is up to date'; $* clean 2>- } : error : : Test that the target file is removed on error and is created on subsequent : successful update. : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ diag concat $< t = $path($>) p = $path($<) cp $p $t cat $(p).baz >>$t }} EOI $* 2>>~%EOE% != 0; concat file{bar.} %cat: unable to print '.+bar.baz': .+% buildfile:10:3: error: cat exited with code 1 %.+ EOE test -f foo != 0; echo 'baz' >=bar.baz; $* 2>'concat file{bar.}'; cat <<>EOO; bar baz EOO $* clean 2>- } : mutual-redirects : { echo 'bar' >=bar; cat <=buildfile; foo: bar % [diag=cp] {{ echo 'copying' 2>&1 cp $path($<) $path($>) }} EOI $* 2>>~%EOE% != 0; cp file{foo} buildfile:4:3: error: stdout and stderr redirected to each other %.+ EOE $* clean 2>- } : untracked-var : { cat <=buildfile; a = a b = b foo: {{ x = true echo "$($x ? a : b)" >$path($>) }} EOI $* 2>>~%EOE% != 0; echo file{foo} buildfile:6:10: error: use of untracked variable 'a' info: use the 'depdb' builtin to manually track it %.+ EOE $* clean 2>- } : depdb : { : track-var-auto : { echo 'bar' >=bar; cat <=buildfile; s = $process.run(cat bar) foo: {{ echo "$s" >$path($>) }} EOI $* 2>'echo file{foo}'; cat <<'bar'; $* 2>/'info: dir{./} is up to date'; echo 'baz' >=bar; $* 2>'echo file{foo}'; cat <<'baz'; $* clean 2>- } : track-var-manual : { echo 'bar' >=bar; echo 'baz' >=baz; cat <=buildfile; a = $process.run(cat baz) foo: bar {{ depdb hash "$a" diag compose $> cp $path($<) $path($>) x = true echo "$($x ? a : b)" >>$path($>) }} EOI $* 2>'compose file{foo.}'; cat <<>EOO; bar baz EOO $* 2>/'info: dir{./} is up to date'; # Make sure that on filesystems with a low file timestamps resolution # (for example HFS+) the file is considered as changed. # sleep 1; echo 'BAR' >=bar; $* 2>'compose file{foo.}'; cat <<>EOO; BAR baz EOO $* 2>/'info: dir{./} is up to date'; echo 'BAZ' >=baz; $* 2>'compose file{foo.}'; cat <<>EOO; BAR BAZ EOO $* 2>/'info: dir{./} is up to date'; $* clean 2>- } : string : { echo 'bar' >=bar; cat <=buildfile; s = $process.run(cat bar) foo: {{ depdb clear depdb string "$s" echo "$s" >$path($>) }} EOI $* 2>'echo file{foo}'; cat <<'bar'; $* 2>/'info: dir{./} is up to date'; echo 'baz' >=bar; $* 2>'echo file{foo}'; cat <<'baz'; $* clean 2>- } : hash : { echo 'bar' >=bar; cat <=buildfile; s = $process.run(cat bar) foo: {{ depdb clear depdb hash "$s" echo "$s" >$path($>) }} EOI $* 2>'echo file{foo}'; cat <<'bar'; $* 2>/'info: dir{./} is up to date'; echo 'baz' >=bar; $* 2>'echo file{foo}'; cat <<'baz'; $* clean 2>- } : preamble : { : valid : { echo 'bar' >=bar; cat <=buildfile; s = $process.run(cat bar) foo: {{ depdb clear s1 = 'abc' s2 = 'xyz' if echo "$s" >>>? 'bar' v = "$s1" else echo "$s2" | set v end depdb string "$v" echo "$v" >$path($>) }} EOI $* 2>'echo file{foo}'; cat <<'abc'; $* 2>/'info: dir{./} is up to date'; echo 'baz' >=bar; $* 2>'echo file{foo}'; cat <<'xyz'; $* clean 2>- } : invalid : { cat <=buildfile; foo: {{ v = 'abc' echo "$v" >$path($>) depdb string "$v" }} EOI $* 2>>~%EOE% != 0; buildfile:4:3: error: disallowed command in depdb preamble info: only variable assignments are allowed in depdb preamble buildfile:5:3: info: depdb preamble ends here %.+ EOE $* clean 2>- } : temp-dir : { cat <=buildfile; foo: {{ touch $~/f | set dummy if test -f $~/f v = "yes" else v = "no" end depdb string "$v" diag echo $> test -f $~/f echo "$v" >$path($>) }} EOI $* 2>'echo file{foo.}'; $* clean 2>- } } } } : clean : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ cp $path($<) $path($>) }} % [diag=clean] clean {{ t = $path($>) rm $t $(t).d }} EOI $* 2>-; # Rely on the cleanup machinery to verify that the build output files are # removed. # $* clean 2>'clean file{foo}' } : test : { : success : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ cp $path($<) $path($>) }} % [diag=test] test {{ cat <$path($<) >?$path($>) }} EOI $* test 2>>EOE; cp file{foo} test file{foo} EOE $* clean 2>- } : depdb : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ cp $path($<) $path($>) }} % [diag=test] test {{ depdb clear cat <$path($<) >?$path($>) }} EOI $* test 2>>EOE != 0 buildfile:7:3: error: 'depdb' builtin cannot be used to perform test EOE } } : diff-label : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ echo 'baz' >? $path($<) }} EOI $* 2>>/~%EOE% != 0; %.+ %--- .+/bar% +++ stdout %.+ EOE $* clean 2>- } : timeout : if ($cxx.target.class != 'windows') { : update : { : expired : { echo 'bar' >=bar; cat <=buildfile; foo: bar % [diag=update] {{ cp $path($<) $path($>) timeout 1 ^sleep 5 }} EOI $* 2>>~%EOE% != 0; update file{foo} buildfile:6:3: error: ^sleep terminated: execution timeout expired info: while updating file{foo} %.+ EOE $* clean 2>- } : successful-timeout : { echo 'bar' >=bar; cat <=buildfile; foo: bar % [diag=update] {{ cp $path($<) $path($>) timeout --success 1 ^sleep 5 }} EOI $* 2>>EOE; update file{foo} EOE $* clean 2>- } } : test : { : expired : { echo 'bar' >=bar; cat <=buildfile; foo: bar {{ cp $path($<) $path($>) }} % [diag=test] test {{ ^sleep 5 }} EOI $* test config.test.timeout=1 2>>~%EOE% != 0; cp file{foo} test file{foo} buildfile:7:3: error: ^sleep terminated: execution timeout expired 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 info: while testing file{foo} %.+ EOE $* clean 2>- } : not-expired : { echo 'bar' >=bar; cat <=buildfile; foo: bar % [diag=cp] {{ ^sleep 4 cp $path($<) $path($>) }} % [diag=test] test {{ ^sleep 1 }} EOI $* test config.test.timeout=3 2>>EOE; cp file{foo} test file{foo} EOE $* clean 2>- } } }