From 096d49af6ac025637baf873558e8ffc2068c5da0 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:12:51 -0400 Subject: [PATCH] fix(scripts): keep a caller's CHECK_DATA_ROOT out of check-affected's test suites When CHECK_DATA_ROOT names the script's own tree, as the ready step's verify one-liner passes it from another checkout, check-affected left it exported, so every test suite inherited it and read the PR tree in place of its fixture repository: check-comment-hygiene.test.sh and check-affected.test.sh failed and the gate recorded fail. Unset it when it names this tree. Co-Authored-By: Claude Opus 5.5 --- scripts/check-affected.sh | 4 ++++ scripts/check-affected.test.sh | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/scripts/check-affected.sh b/scripts/check-affected.sh index a318b231f73..cfcdd7e0a86 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 17638c25c1c..59219ae8241 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" while (($#)); do [[ "$1" == --write-not-run ]] && printf '%s' "${STUB_NOT_RUN:-}" >"$2" shift @@ -124,6 +125,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" \