From 70e095024ab33404ba0cf20c184a7a9560bca5f0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 18 Jan 2022 10:54:23 +0200 Subject: Add dynamic prerequisites to $< unless --adhoc is specified Also add a few tests for depdb-dyndep. --- tests/recipe/buildscript/testscript | 209 ++++++++++++++++++++++++++---------- 1 file changed, 152 insertions(+), 57 deletions(-) (limited to 'tests') diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript index 12c5717..910ee67 100644 --- a/tests/recipe/buildscript/testscript +++ b/tests/recipe/buildscript/testscript @@ -250,6 +250,97 @@ posix = ($cxx.target.class != 'windows') $* 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>- + } + } + : string : { @@ -368,94 +459,98 @@ posix = ($cxx.target.class != 'windows') } } - : preamble + : dyndep : { - : valid + : normal : { - echo 'bar' >=bar; + cat <=bar.h; + bar + EOI cat <=buildfile; - s = $process.run(cat bar) - foo: - {{ - depdb clear + define h: file + h{*}: extension = h - s1 = 'abc' - s2 = 'xyz' + ./: h{foo baz} - if echo "$s" >>>? 'bar' - v = "$s1" - else - echo "$s2" | set v - end + h{foo}: + {{ + # Note that strictly speaking we should return $out_base/baz.h + # on the second invocation (since it now exists). But our dyndep + # machinery skips the entry which it has already seen, so this + # works for now. + # + depdb dyndep "-I$out_base" --what=header --default-type=h -- \ + echo "$out_base/foo.h: $src_base/bar.h baz.h" - depdb string "$v" + diag gen $> - echo "$v" >$path($>) + cat $path($<) >$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: + h{baz}: {{ - v = 'abc' - echo "$v" >$path($>) - depdb string "$v" + diag gen $> + echo baz >$path($>) }} 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 - %.+ + $* 2>>EOE; + gen h{baz.h} + gen h{foo.h} EOE - $* clean 2>- + cat foo.h >>EOO; + bar + baz + EOO + + $* clean 2>- } - : temp-dir + : byproduct : { + cat <=bar.h; + bar + EOI + cat <=buildfile; - foo: + define h: file + h{*}: extension = h + + h{foo}: h{baz} {{ - touch $~/f | set dummy + o = $path($>) + t = $path($>).t - if test -f $~/f - v = "yes" - else - v = "no" - end + depdb dyndep --byproduct --what=header --default-type=h --file $t - depdb string "$v" - diag echo $> + diag gen $> + cat $src_base/bar.h $out_base/baz.h >$o + echo "$out_base/foo.h: $src_base/bar.h $out_base/baz.h" >$t + }} - test -f $~/f - echo "$v" >$path($>) + h{baz}: + {{ + diag gen $> + echo baz >$path($>) }} EOI - $* 2>'echo file{foo.}'; + $* 2>>EOE; + gen h{baz.h} + gen h{foo.h} + EOE - $* clean 2>- + cat foo.h >>EOO; + bar + baz + EOO + + $* clean 2>- } } } -- cgit v1.1