summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-03-09 16:40:35 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-03-09 16:40:35 +0100
commiteddf9107720bbcce6e2cebf4b7cfa63e8e7ede2c (patch)
tree8ca2e8dc43689c42b25a0af14bdc0f60782cd0ec
parentb194d9d4e2b4a52f103c7bad548852d91563bd09 (diff)
downloadjustbuild-eddf9107720bbcce6e2cebf4b7cfa63e8e7ede2c.tar.gz
Add a test demonstrating nested trees
-rw-r--r--test/end-to-end/actions/TARGETS10
-rwxr-xr-xtest/end-to-end/actions/nested-trees.sh113
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 ]