test: make the prepare-release fixture Windows-safe - #89
Merged
Merged
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
pnpm run testis red on Windows at72fee95: 17 of the 20 cases intests/prepare-release.test.tsfail, i.e. 17 of 380 tests overall. Everything else is green (
tsc --noEmitclean, all 17 other testfiles pass). The failures are all the same shape — the spawned script's git call dies, so the assertion
lands on the process status instead of on the behaviour under test:
and the underlying crash, visible in the captured stderr:
Why
The fixture controls git with an extensionless
#!/bin/shshim written to<fixture>/bin/git(
tests/prepare-release.test.ts:88) and put onPATH. Two Windows-only defects stop that from working:PATHis built with a hardcoded:(:100).path.delimiteris;on win32, so the shimdirectory is not added as a PATH entry at all — it is glued onto the front of the first real entry:
Windows cannot execute that shim even when it is on
PATH. Node's PATH search needs aPATHEXTextension, so
spawnSync('git', …)skips the extensionless file and runs the realgit.exe:prepare-release.mjsusesexecFileSync('git', …)(:24), which never goes through a shell, so a.cmdshim does not help either —spawnSync('git.cmd', …)returnsEINVAL. Inside the fixture,which is deliberately not a repository, the real git then exits 128.
Three cases currently pass on Windows only because version validation rejects the input before any git
call is reached; the other 17 fail, and one of them passes the
expected 1half of its assertion for thewrong reason.
Change
PATHwithpath.delimiterinstead of':'(:100). On POSIX this produces a byte-identicalstring, so Linux CI is unaffected.
describeindescribe.skipIf(process.platform === 'win32')with a comment explaining why thefixture cannot run there, instead of reporting 17 failures that say nothing about the script.
Why the whole file and not 17 cases
All 20 cases call the same
runScript()fixture, so there is no sub-set that avoids the broken shim:the 3 that currently pass on Windows do so because version validation rejects the input before
prepare-release.mjsreaches git, not because they use a different seam. A per-case skip would draw aline that does not exist in the code.
No coverage is lost in CI either: all three workflows in this repository run on
ubuntu-latestonly, andprocess.platformislinuxthere, soskipIfis a no-op and those 3 cases keep running. The skip onlystops a local Windows run from reporting 17 failures that describe the fixture rather than the script.
Restoring real Windows coverage needs a non-PATH seam — for example letting
scripts/prepare-release.mjsread the git command from an environment variable, with the fixture pointing it at a Node script. That
touches shipped code, so I did not assume it here.
Validation (Windows 11, Node v24.21.0, pnpm 12.5.1)
The two Windows mechanisms above were reproduced standalone with a throwaway fixture that mirrors
makeFixture/runScriptexactly.