1.9 KiB
FAIL
r1 check:
- doctor.sh:12 broken tools: fixed. With
RUSTUP_TOOLCHAIN=nonexistent-xyz, doctor printsBROKEN rustc: ...andBROKEN cargo: ...and exits 1. - doctor.sh:2 comment length: fixed. It is now nine words.
- missing exit-code test: partly fixed. tests/scripts/doctor.sh covers all-present, absent, and broken, and it passes locally. The r1 scenario "drops a tool from the list, passes unnoticed" still holds; see the first entry below.
tests/scripts/doctor.sh:15 — The test builds its stub list from the check lines in doctor.sh, then asserts output only for cmake and ninja. If a required tool is removed from doctor.sh, it also disappears from the test's expectations. C00.1 names cmake, ninja, pkg-config, and git-lfs, but nothing pins pkg-config or git-lfs.
Scenario (reproduced): delete the check pkg-config and check git-lfs lines from a copy of doctor.sh and run the test against it. It prints doctor.sh: 3 cases pass and exits 0.
Fix: hard-code the required tool list in the test. In the all-present case, assert that a version line appears for each of those tools.
tests/scripts/doctor.sh:13 — The test sets PATH to $stubs:/usr/bin:/bin, so in the "absent" case doctor still finds any real tool installed in a system directory. On Linux, apt install cmake puts it at /usr/bin/cmake. Removing the cmake stub then exposes the real cmake, doctor exits 0, and the test fails. Whether the test passes depends on the host, including the Linux and Raspberry Pi targets.
Scenario (reproduced): add a directory holding a real cmake to the test's PATH after the stubs, standing in for /usr/bin on Linux. The test prints FAIL: cmake absent: doctor exited 0 and exits 1.
Fix: give doctor a PATH that contains only the stub directory. Start doctor with an absolute bash path so the env bash lookup is not needed, and either stub or link head in the stub directory or replace head with parameter expansion in doctor.sh.