From 37e5115503299bc75cd0ad439b274d009a5a7045 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 21 Jun 2023 12:22:32 +0200 Subject: Extend action-equality-timeout test to also test the generic rule --- test/end-to-end/actions/TARGETS | 9 +++- test/end-to-end/actions/action-equality-timeout.sh | 52 +++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) (limited to 'test') 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 -- cgit v1.2.3