Symptom
Two bats tests in scripts/tests/setup-linux.bats fail when run on a macOS dev host (they pass in CI on Linux):
install_docker_engine: Amazon Linux -> dnf docker
install_docker_engine: RHEL clone (#719) -> docker-ce dnf repo
Root cause
install_docker_engine() in scripts/lib/setup-linux.sh gated the Amazon Linux and AlmaLinux/Rocky branches with [[ -f /etc/os-release ]] && grep -qi ... /etc/os-release. The test mocked grep to simulate os-release content per $TEST_DISTRO, but a bash builtin file-test ([[ -f /etc/os-release ]]) cannot be intercepted by a function mock. On macOS /etc/os-release does not exist, so both branches short-circuited and the function fell through to the get.docker.com path — the expected strings were never recorded and the asserts failed.
The pacman/zypper/ubuntu branches passed because they gate on has <cmd> (mockable via PRESENT_CMDS), not a file-test.
CI was unaffected: the unit-bash job runs on ubuntu (os-release present), and the real RHEL/Amazon docker paths are independently exercised by the distro-prereqs matrix in actual almalinux/amazonlinux containers.
Fix (Option 2 — keep coverage on macOS dev machines)
Make the os-release lookup mockable: install_docker_engine reads from ${TB_OS_RELEASE_FILE:-/etc/os-release} for both the [[ -f ]] test and the grep. The bats setup() writes a real os-release fixture per $TEST_DISTRO to a temp file and exports TB_OS_RELEASE_FILE, so distro detection (real [[ -f ]] + real grep) is exercised on every dev host. Default behaviour is unchanged when the env var is unset (production / CI).
Acceptance criteria
Symptom
Two
batstests inscripts/tests/setup-linux.batsfail when run on a macOS dev host (they pass in CI on Linux):install_docker_engine: Amazon Linux -> dnf dockerinstall_docker_engine: RHEL clone (#719) -> docker-ce dnf repoRoot cause
install_docker_engine()inscripts/lib/setup-linux.shgated the Amazon Linux and AlmaLinux/Rocky branches with[[ -f /etc/os-release ]] && grep -qi ... /etc/os-release. The test mockedgrepto simulate os-release content per$TEST_DISTRO, but a bash builtin file-test ([[ -f /etc/os-release ]]) cannot be intercepted by a function mock. On macOS/etc/os-releasedoes not exist, so both branches short-circuited and the function fell through to the get.docker.com path — the expected strings were never recorded and the asserts failed.The pacman/zypper/ubuntu branches passed because they gate on
has <cmd>(mockable viaPRESENT_CMDS), not a file-test.CI was unaffected: the
unit-bashjob runs on ubuntu (os-release present), and the real RHEL/Amazon docker paths are independently exercised by thedistro-prereqsmatrix in actual almalinux/amazonlinux containers.Fix (Option 2 — keep coverage on macOS dev machines)
Make the os-release lookup mockable:
install_docker_enginereads from${TB_OS_RELEASE_FILE:-/etc/os-release}for both the[[ -f ]]test and thegrep. The batssetup()writes a real os-release fixture per$TEST_DISTROto a temp file and exportsTB_OS_RELEASE_FILE, so distro detection (real[[ -f ]]+ realgrep) is exercised on every dev host. Default behaviour is unchanged when the env var is unset (production / CI).Acceptance criteria
bats scripts/tests/setup-linux.bats— all 20 tests pass on macOS.TB_OS_RELEASE_FILEis unset (production / Linux CI).