From bff9a57913551aa2341b009f105e33ec0027a04a Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Thu, 15 May 2025 12:41:18 +0200 Subject: extend basic profiling test Verify more keys in the profile file and also verify basic properties of the other invocation-specific files that can be requested. --- test/end-to-end/profile/basic.sh | 43 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/end-to-end/profile/basic.sh b/test/end-to-end/profile/basic.sh index 61e0ddf5..cb253138 100644 --- a/test/end-to-end/profile/basic.sh +++ b/test/end-to-end/profile/basic.sh @@ -30,7 +30,12 @@ readonly RC="${ETC_DIR}/rc.json" cat > "${RC}" < data.txt cat > rc.json <<'EOF' {"invocation log": {"project id": "first-run"}} EOF -"${JUST_MR}" --rc "${RC}" build upper 2>&1 +MY_CONTEXT=TeStCoNtExT "${JUST_MR}" --rc "${RC}" build upper 2>&1 INVOCATION_DIR="$(ls -d "${LOG_DIR}"/first-run/*)" PROFILE="${INVOCATION_DIR}/profile.json" cat "${PROFILE}" +echo +[ $(jq '."exit code"' "${PROFILE}") -eq 0 ] +[ $(jq -r '."subcommand"' "${PROFILE}") = "build" ] +[ $(jq -r '."target" | .[3]' "${PROFILE}") = "upper" ] [ $(jq '.actions | .[] | .cached' "${PROFILE}") = "false" ] OUT_ARTIFACT=$(jq -r '.actions | .[] | .artifacts."upper.txt"' "${PROFILE}") @@ -84,9 +93,34 @@ STDERR=$(jq -r '.actions | .[] | .stderr' "${PROFILE}") "${JUST_MR}" --rc "${RC}" install-cas -o "${OUT}/stderr" "${STDERR}" 2>&1 grep StdOuT "${OUT}/stdout" grep StdErR "${OUT}/stderr" + +ARTIFACTS="${INVOCATION_DIR}/artifacts.json" +cat "${ARTIFACTS}" +echo +[ $(jq -r '."upper.txt".id' "${ARTIFACTS}") = "${OUT_ARTIFACT}" ] + +META="${INVOCATION_DIR}/meta.json" +cat "${META}" +echo +[ $(jq -r '.cmdline | .[0]' "${META}") = "${JUST}" ] +[ $(jq -r '.context."MY_CONTEXT"' "${META}") = "TeStCoNtExT" ] + +TO_BUILD="${INVOCATION_DIR}/to-build.json" +cat "${TO_BUILD}" echo +[ $(jq -r '."upper.txt".type' "${TO_BUILD}") = "ACTION" ] +ACTION_ID="$(jq -r '."upper.txt".data.id' "${TO_BUILD}")" -# Build again, this time the action should be cached; +GRAPH="${INVOCATION_DIR}/graph.json" +cat "${GRAPH}" +echo +[ $(jq -r '.actions."'"${ACTION_ID}"'".input."data.txt".type' "${GRAPH}") = "LOCAL" ] +[ $(jq -r '.actions."'"${ACTION_ID}"'".output | .[0]' "${GRAPH}") = "upper.txt" ] + +echo + +# Build again, this time the action should be cached; graph and artifact to +# build should not have changed # again abuse the project id to distingush the runs cat > rc.json <<'EOF' {"invocation log": {"project id": "second-run"}} @@ -98,4 +132,9 @@ PROFILE="${INVOCATION_DIR}/profile.json" cat "${PROFILE}" [ $(jq '.actions | .[] | .cached' "${PROFILE}") = "true" ] +TO_BUILD="${INVOCATION_DIR}/to-build.json" +cat "${TO_BUILD}" +echo +[ $(jq -r '."upper.txt".data.id' "${TO_BUILD}") = "${ACTION_ID}" ] + echo OK -- cgit v1.2.3