summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-23 15:10:43 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2022-02-23 15:41:19 +0100
commit68f3bfc6989b7ad8ca40e18538ff15fb7b72e33a (patch)
tree59f0cd7638ac49678ca9fd87a2a466d86f7fb5f8 /test
parent42f55fd30b4b1bbb375924b762655cd318ca841a (diff)
downloadjustbuild-68f3bfc6989b7ad8ca40e18538ff15fb7b72e33a.tar.gz
Add a first end-to-end test for action equality
This test also demonstrates the notion of equality used in our action graph: actions are considered equal, if they are defined in the same way (regardless of where they are defined); when looking up actions in cache, however, the inputs are considered extensionally. The test also verifies that if one dumps the action graph, the origins of an action (as the same action can be defined in many places) are reported correctly.
Diffstat (limited to 'test')
-rw-r--r--test/TARGETS3
-rw-r--r--test/end-to-end/TARGETS8
-rw-r--r--test/end-to-end/actions/TARGETS9
-rwxr-xr-xtest/end-to-end/actions/action-equality.sh60
4 files changed, 79 insertions, 1 deletions
diff --git a/test/TARGETS b/test/TARGETS
index ed206b74..27a269d4 100644
--- a/test/TARGETS
+++ b/test/TARGETS
@@ -11,6 +11,7 @@
, "dirs":
[ [["./", "buildtool", "TESTS"], "buildtool"]
, [["./", "utils", "TESTS"], "utils"]
+ , [["./", "end-to-end", "TESTS"], "end-to-end"]
]
}
, "ALL":
@@ -21,4 +22,4 @@
, "arch": [{"type": "var", "name": "ARCH", "default": "x86_64"}]
, "target": ["TESTS"]
}
-} \ No newline at end of file
+}
diff --git a/test/end-to-end/TARGETS b/test/end-to-end/TARGETS
new file mode 100644
index 00000000..b7e03a0d
--- /dev/null
+++ b/test/end-to-end/TARGETS
@@ -0,0 +1,8 @@
+{ "tool-under-test":
+ {"type": "install", "files": {"bin/tool-under-test": [".", "just"]}}
+, "TESTS":
+ { "type": "install"
+ , "tainted": ["test"]
+ , "dirs": [[["./", "actions", "TESTS"], "actions"]]
+ }
+}
diff --git a/test/end-to-end/actions/TARGETS b/test/end-to-end/actions/TARGETS
new file mode 100644
index 00000000..a941906f
--- /dev/null
+++ b/test/end-to-end/actions/TARGETS
@@ -0,0 +1,9 @@
+{ "equality":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["equality"]
+ , "test": ["action-equality.sh"]
+ , "keep": ["graph.json"]
+ , "deps": [["test/end-to-end", "tool-under-test"]]
+ }
+, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["equality"]}
+}
diff --git a/test/end-to-end/actions/action-equality.sh b/test/end-to-end/actions/action-equality.sh
new file mode 100755
index 00000000..f0ce86b3
--- /dev/null
+++ b/test/end-to-end/actions/action-equality.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+set -e
+
+mkdir .tool-root
+touch ROOT
+cat > TARGETS <<'EOI'
+{ "foo":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["echo Hello World > out.txt"]
+ }
+, "bar":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["echo Hello World > out.txt"]
+ }
+, "baz":
+ { "type": "generic"
+ , "outs": ["out.txt"]
+ , "cmds": ["echo -n Hello > out.txt && echo ' World' >> out.txt"]
+ }
+, "foo upper":
+ { "type": "generic"
+ , "deps": ["foo"]
+ , "outs": ["upper.txt"]
+ , "cmds": ["cat out.txt | tr a-z A-Z > upper.txt"]
+ }
+, "bar upper":
+ { "type": "generic"
+ , "deps": ["bar"]
+ , "outs": ["upper.txt"]
+ , "cmds": ["cat out.txt | tr a-z A-Z > upper.txt"]
+ }
+, "baz upper":
+ { "type": "generic"
+ , "deps": ["baz"]
+ , "outs": ["upper.txt"]
+ , "cmds": ["cat out.txt | tr a-z A-Z > upper.txt"]
+ }
+, "ALL":
+ { "type": "install"
+ , "files":
+ {"foo.txt": "foo upper", "bar.txt": "bar upper", "baz.txt": "baz upper"}
+ }
+}
+EOI
+
+
+bin/tool-under-test build -J 1 --local_build_root .tool-root 2>log
+cat log
+echo
+grep '4 actions' log
+grep '1 cache hit' log
+
+echo
+bin/tool-under-test analyse --dump_graph graph.json
+echo
+matching_targets=$(cat graph.json | jq -acM '.actions | [ .[] | .origins | [ .[] | .target]] | sort')
+echo "${matching_targets}"
+[ "${matching_targets}" = '[[["@","","","bar"],["@","","","foo"]],[["@","","","bar upper"],["@","","","foo upper"]],[["@","","","baz"]],[["@","","","baz upper"]]]' ]