summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2023-06-21 12:22:32 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-06-22 17:58:50 +0200
commit37e5115503299bc75cd0ad439b274d009a5a7045 (patch)
tree40024caa844b3a22219c9571a9dcba23910229c6 /test
parent9dd7a8cab2757dc0e7d19023442046cacfef7e5f (diff)
downloadjustbuild-37e5115503299bc75cd0ad439b274d009a5a7045.tar.gz
Extend action-equality-timeout test to also test the generic rule
Diffstat (limited to 'test')
-rw-r--r--test/end-to-end/actions/TARGETS9
-rwxr-xr-xtest/end-to-end/actions/action-equality-timeout.sh52
2 files changed, 58 insertions, 3 deletions
diff --git a/test/end-to-end/actions/TARGETS b/test/end-to-end/actions/TARGETS
index f36ed90c..08a617e6 100644
--- a/test/end-to-end/actions/TARGETS
+++ b/test/end-to-end/actions/TARGETS
@@ -9,7 +9,14 @@
{ "type": ["@", "rules", "shell/test", "script"]
, "name": ["equality-timeout"]
, "test": ["action-equality-timeout.sh"]
- , "keep": ["graph-null.json", "graph-1.json", "graph-2.json"]
+ , "keep":
+ [ "rules/graph-null.json"
+ , "rules/graph-1.json"
+ , "rules/graph-2.json"
+ , "generic/graph-null.json"
+ , "generic/graph-1.json"
+ , "generic/graph-2.json"
+ ]
, "deps": [["end-to-end", "tool-under-test"]]
}
, "equality-properties":
diff --git a/test/end-to-end/actions/action-equality-timeout.sh b/test/end-to-end/actions/action-equality-timeout.sh
index 2020086c..de7dca18 100755
--- a/test/end-to-end/actions/action-equality-timeout.sh
+++ b/test/end-to-end/actions/action-equality-timeout.sh
@@ -15,9 +15,12 @@
set -e
+readonly ROOT="$(pwd)"
readonly LBRDIR="$TMPDIR/local-build-root"
-readonly JUST="bin/tool-under-test"
+readonly JUST="${ROOT}/bin/tool-under-test"
+mkdir -p "${ROOT}/rules"
+cd "${ROOT}/rules"
touch ROOT
cat > RULES <<'EOI'
{ "":
@@ -27,7 +30,7 @@ cat > RULES <<'EOI'
, "artifacts":
{ "type": "ACTION"
, "outs": ["out.txt"]
- , "cmd": ["sh", "-c", "echo Hello > out.txt"]
+ , "cmd": ["sh", "-c", "echo Hello > out.txt\n"]
, "timeout scaling": {"type": "var", "name": "TIMEOUT"}
}
}
@@ -53,6 +56,41 @@ cat > TARGETS <<'EOI'
}
EOI
+mkdir -p "${ROOT}/generic"
+cd "${ROOT}/generic"
+touch ROOT
+cat > TARGETS <<'EOI'
+{ "flexible":
+ { "type": "generic"
+ , "arguments_config": ["TIMEOUT"]
+ , "outs": ["out.txt"]
+ , "cmds": ["echo Hello > out.txt"]
+ , "timeout scaling": {"type": "var", "name": "TIMEOUT"}
+ }
+, "fixed":
+ { "type": "configure"
+ , "target": "flexible"
+ , "config": {"type": "singleton_map", "key": "TIMEOUT", "value": 1.0}
+ }
+, "unset":
+ { "type": "configure"
+ , "target": "flexible"
+ , "config": {"type": "singleton_map", "key": "TIMEOUT", "value": null}
+ }
+, "":
+ { "type": "install"
+ , "files": {"flexible": "flexible", "fixed": "fixed", "unset": "unset"}
+ }
+}
+EOI
+
+
+for variant in rules generic
+do
+echo "Testing variant ${variant}"
+echo
+cd "${ROOT}/${variant}"
+
"${JUST}" analyse --local-build-root "${LBRDIR}" --dump-graph graph-null.json 2>&1
action_configs=$(cat graph-null.json | jq -acM '.actions | [ .[] | .origins | [ .[] | .config.TIMEOUT ]] | sort')
echo "${action_configs}"
@@ -71,4 +109,14 @@ action_configs=$(cat graph-2.json | jq -acM '.actions | [ .[] | .origins | [ .[]
echo "${action_configs}"
[ "${action_configs}" = '[[1,null],[2]]' ]
+echo "variant ${variant} OK"
+echo
+done
+
+# also verify the consistency of the generated actions
+for graph in graph-null.json graph-1.json graph-2.json
+do
+ diff -u "${ROOT}/rules/${graph}" "${ROOT}/generic/${graph}"
+done
+
echo OK