diff --git a/scripts/check-affected.sh b/scripts/check-affected.sh index c6ba3b1b8e1..1c2dfae82cb 100755 --- a/scripts/check-affected.sh +++ b/scripts/check-affected.sh @@ -204,6 +204,10 @@ if [[ "$(pwd -P)" != "$tools" ]]; then export CHECK_DATA_ROOT="$PWD" # uvx would otherwise read a uv.toml or [tool.uv] index from the checked tree. export UV_NO_CONFIG=1 +else + # It names this tree, so it says nothing; the test suites build fixture + # repositories, and an inherited one would point them back here. + unset CHECK_DATA_ROOT fi gates_file="$tools/scripts/check-affected-gates.txt" diff --git a/scripts/check-affected.test.sh b/scripts/check-affected.test.sh index a86e993e5cf..4b1fa7bc7d6 100755 --- a/scripts/check-affected.test.sh +++ b/scripts/check-affected.test.sh @@ -36,6 +36,7 @@ done cat >"$repo/scripts/affected-tests.sh" <<'STUB' #!/usr/bin/env bash echo "affected-tests ran" >&2 +[[ -z "${STUB_ENV_LOG:-}" ]] || printf '%s' "${CHECK_DATA_ROOT-unset}" >"$STUB_ENV_LOG" [[ -v CHECK_DATA_ROOT ]] && { echo "affected-tests saw CHECK_DATA_ROOT" >&2; exit 1; } while (($#)); do [[ "$1" == --write-not-run ]] && printf '%s' "${STUB_NOT_RUN:-}" >"$2" @@ -125,6 +126,15 @@ run_from() { run_from "$other" --base base --tests check "run from another checkout, it lists the script's own branch's change" \ '[[ $RC == 0 && $OUT == *"over 1 changed files"* && $ERR != *"SKIP tests"* ]]' +# The ready step names the script's own tree in CHECK_DATA_ROOT from another +# checkout. The suites build fixture repositories of their own, so the variable +# must not reach them, or each one reads this tree in place of its fixture. +RC=0 +OUT="$(cd "$other" && CHECK_DATA_ROOT="$repo" STUB_ENV_LOG="$tmp/env.log" \ + bash "$repo/scripts/check-affected.sh" --base base --tests 2>"$tmp/err")" || RC=$? +ERR="$(cat "$tmp/err")" +check "CHECK_DATA_ROOT naming the script's own tree checks that tree and is not passed to the suites" \ + '[[ $RC == 0 && $OUT == *"over 1 changed files"* && $(cat "$tmp/env.log") == unset ]]' git_test_config "$repo" update-ref refs/remotes/origin/main "$(git_test_config "$repo" rev-parse base)" run_from "$other" --base origin/main --no-fetch check "an explicit --base run from another checkout still lists the change" \