diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2022-06-28 19:14:43 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2022-06-28 19:22:10 +0200 |
commit | c29b5de236525b04a852d06d53e76ff341a86fa3 (patch) | |
tree | 3496703ff445c2c9e4dfed51afdd73230ad27d77 /test/end-to-end/built-in-rules/generic_out_dirs.sh | |
parent | 684cf178ef455ee21a03e2458cdf59afa584498f (diff) | |
download | justbuild-c29b5de236525b04a852d06d53e76ff341a86fa3.tar.gz |
Generic: add support for out_dirs
Before this patch, the built-in "generic" type allowed for just output
files, listed in the field "outs". Now, the type also supports output
directories, listed in the "out_dirs" field. The output directories
are created before the command is executed.
Diffstat (limited to 'test/end-to-end/built-in-rules/generic_out_dirs.sh')
-rwxr-xr-x | test/end-to-end/built-in-rules/generic_out_dirs.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test/end-to-end/built-in-rules/generic_out_dirs.sh b/test/end-to-end/built-in-rules/generic_out_dirs.sh new file mode 100755 index 00000000..8074bdab --- /dev/null +++ b/test/end-to-end/built-in-rules/generic_out_dirs.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set -e + +touch ROOT +mkdir -p lcl-build + +cat <<EOF > TARGETS +{ "gen_out_dirs": + {"type": "generic", "cmds": ["echo foo > out/foo.txt"], "out_dirs": ["out"]} +, "read_out_dirs": + { "type": "generic" + , "cmds": ["cat out/foo.txt > bar.txt"] + , "outs": ["bar.txt"] + , "deps": ["gen_out_dirs"] + } +, "missing_outs_and_out_dirs": + {"type": "generic", "cmds": ["echo foo > out/foo.txt"]} +, "out_dirs_contains_a_file": + {"type": "generic", "cmds": ["echo foo > foo.txt"], "out_dirs": ["foo.txt"]} +, "outs_contains_a_dir": + { "type": "generic" + , "cmds": ["mkdir out", "echo foo > out/foo.txt"] + , "outs": ["out"] + } +, "collision": + { "type": "generic" + , "cmds": ["touch foo"] + , "outs": ["foo"] + , "out_dirs": ["foo"] + } +} +EOF + +echo "read_out_dirs" >&2 +bin/tool-under-test build --local-build-root lcl-build read_out_dirs +echo "done" >&2 + +echo "missing_outs_and_out_dirs" >&2 +# at least one of "outs" or "out_dirs" must be declared. we expect to fail during the analysis phase +bin/tool-under-test analyse --log-limit 0 -f test.log missing_outs_and_out_dirs && exit 1 || : +grep 'outs' test.log && grep 'out_dirs' test.log +echo "done" >&2 + +echo "out_dirs_contains_a_file" >&2 +# the directories listed in "out_dirs" are created before the cmd is exectuted +# so, we expect the shell to complain that it cannot generate file "foo.txt" +# because it is a directory. We don't grep the shell error message because it can +# varay. +# the analysis phase should run fine +bin/tool-under-test analyse out_dirs_contains_a_file +echo "analysis ok" >&2 +bin/tool-under-test build --local-build-root lcl-build out_dirs_contains_a_file && exit 1 || : +echo "done" >&2 + +echo "outs_contains_a_dir" >&2 +# we declared an output file "out", which is actually a tree +# if we don't creat directory out, the shell will also complain about nonexisting directory "out" +# anlysis should run fine +bin/tool-under-test analyse outs_contains_a_dir +echo "analysis ok" >&2 +bin/tool-under-test build --local-build-root lcl-build -f test.log outs_contains_a_dir && exit 1 || : +# grep 'ERROR' test.log | grep 'output file' +echo "done" >&2 + +echo "collision" >&2 +# we expect an error during the analysis phase because outs and out_dirs must be disjoint +bin/tool-under-test analyse --log-limit 0 -f test.log collision && exit 1 || : +grep 'disjoint' test.log +echo "done" >&2 +exit |