diff options
-rw-r--r-- | test/end-to-end/actions/TARGETS | 10 | ||||
-rwxr-xr-x | test/end-to-end/actions/nested-trees.sh | 113 |
2 files changed, 122 insertions, 1 deletions
diff --git a/test/end-to-end/actions/TARGETS b/test/end-to-end/actions/TARGETS index a941906f..9575d724 100644 --- a/test/end-to-end/actions/TARGETS +++ b/test/end-to-end/actions/TARGETS @@ -5,5 +5,13 @@ , "keep": ["graph.json"] , "deps": [["test/end-to-end", "tool-under-test"]] } -, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["equality"]} +, "trees": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["trees"] + , "test": ["nested-trees.sh"] + , "keep": ["blobs.json", "trees.json", "out/index.txt"] + , "deps": [["test/end-to-end", "tool-under-test"]] + } +, "TESTS": + {"type": "install", "tainted": ["test"], "deps": ["equality", "trees"]} } diff --git a/test/end-to-end/actions/nested-trees.sh b/test/end-to-end/actions/nested-trees.sh new file mode 100755 index 00000000..70d69ee5 --- /dev/null +++ b/test/end-to-end/actions/nested-trees.sh @@ -0,0 +1,113 @@ +#!/bin/sh +set -e + +mkdir tool-root +mkdir work +cd work +touch ROOT +cat > RULES <<'EOI' +{ "2^3": + { "expression": + { "type": "let*" + , "bindings": + [ ["blob", {"type": "BLOB", "data": "Hello World"}] + , [ "two" + , { "type": "TREE" + , "$1": + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "0" + , "value": {"type": "var", "name": "blob"} + } + , { "type": "singleton_map" + , "key": "1" + , "value": {"type": "var", "name": "blob"} + } + ] + } + } + ] + , [ "four" + , { "type": "TREE" + , "$1": + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "0" + , "value": {"type": "var", "name": "two"} + } + , { "type": "singleton_map" + , "key": "1" + , "value": {"type": "var", "name": "two"} + } + ] + } + } + ] + , [ "eight" + , { "type": "TREE" + , "$1": + { "type": "map_union" + , "$1": + [ { "type": "singleton_map" + , "key": "0" + , "value": {"type": "var", "name": "four"} + } + , { "type": "singleton_map" + , "key": "1" + , "value": {"type": "var", "name": "four"} + } + ] + } + } + ] + ] + , "body": + { "type": "RESULT" + , "artifacts": + { "type": "singleton_map" + , "key": "data" + , "value": {"type": "var", "name": "eight"} + } + } + } + } +} +EOI +cat > TARGETS <<'EOI' +{ "data": {"type": "2^3"} +, "ALL": + { "type": "generic" + , "outs": ["index.txt"] + , "cmds": ["find data -type f | sort > index.txt"] + , "deps": ["data"] + } +} +EOI + +echo +echo Analysis +echo +../bin/tool-under-test analyse data \ + --dump_trees ../trees.json --dump_blobs ../blobs.json 2>&1 +echo +echo Blobs +echo +cat ../blobs.json +[ $(cat ../blobs.json | jq -acM 'length') -eq 1 ] +echo +echo Trees +echo +cat ../trees.json +[ $(cat ../trees.json | jq -acM 'length') -eq 3 ] +echo +echo Build +echo +../bin/tool-under-test install -o ../out --local_build_root ../tool-root 2>&1 +echo +echo Index +echo +cat ../out/index.txt +echo +[ $(cat ../out/index.txt | wc -l) -eq 8 ] |