fix(tests): keep Git from rewriting fixture line endings on Windows - #1450
Merged
UlisesGascon merged 1 commit intoAug 24, 2026
Merged
Conversation
test/files holds opaque upload payloads whose exact byte size the suite asserts on, and nothing marked them as binary. With core.autocrlf=true, Git's default on Windows, checkout rewrites LF to CRLF in medium.dat, small0.dat, small1.dat and tiny0.dat, inflating small0.dat from 1778 to 1803 bytes and failing 11 tests across disk-storage, memory-storage, functionality, reuse-middleware and select-field on a clean clone. A .gitattributes entry marking test/files as binary is enough on its own: the committed blobs already hold exactly the LF bytes the tests expect, so suppressing the end-of-line conversion restores every fixture to its recorded size. The fixtures themselves are left untouched, which keeps the hardcoded sizes valid and the diff reviewable. Closes expressjs#181
Contributor
Author
|
For context: this supersedes #1449, which I closed after opening this. Nothing about the change differs — same commit |
This was referenced Aug 11, 2026
UlisesGascon
approved these changes
Aug 24, 2026
UlisesGascon
left a comment
Member
There was a problem hiding this comment.
Thanks @MohammedAlkindi!
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.
Closes #181
Symptom
On a clean clone on Windows,
npm testgives 12 failing / 71 passing before any code is touched:Cause
test/files/holds opaque upload payloads whose exact byte size the suite hardcodes, and nothing marked them as binary. Withcore.autocrlf=true— Git's default on Windows — checkout rewrites LF to CRLF in the text-like fixtures:medium.datsmall0.datsmall1.dattiny0.datempty.dat,tiny1.datlarge.jpgThe committed blobs already hold exactly the LF bytes the tests expect —
1778forsmall0.dat, matching everyassert.strictEqual(..., 1778). Only the checkout conversion is wrong.Fix
One
.gitattributesmarkingtest/files/**as binary. Because the blobs are already correct, suppressing the end-of-line conversion is sufficient on its own — the fixtures are not modified, so the hardcoded sizes stay valid and there is no fixture churn to review.This follows the second option @jonchurch laid out on the issue — "changing the behavior of git with a
.gitattributesfile" — rather than @LinusU's original suggestion of regenerating the fixtures as random binary data. Both stop the conversion; this one leaves the recorded sizes and the fixtures themselves untouched.binaryalso implies-diff, which is what you want for opaque payloads.I kept this to a single file on purpose: the previous attempt, #832, was closed after the feedback that it "changes too many things to be easily evaluated".
Deliberately unchanged
The 12th failure is a different bug and is not touched here.
Functionality > should rename the destination directory to a different directoryassertsreq.files[0].path.indexOf('/testforme-') >= 0, hardcoding a forward slash as the path separator, so it can never match a Windows path regardless of line endings. It fails before and after this change. It deserves its own issue and PR.Testing
Windows 11, Node v24.18.0,
core.autocrlf=true.The 11 fixed failures span
disk-storage,functionality,memory-storage,reuse-middlewareandselect-field; the 1 remaining is the path-separator assertion above.Verified end to end rather than only in place: after pushing this branch I made a fresh
git cloneof it on Windows and confirmed every fixture arrives at its committed size with no CR bytes, then rannpm install && npm testin that new clone — 79 passing, 1 failing.npm run lint(standard) is clean.I have no way to run the macOS or Linux jobs locally; those platforms do not convert line endings on checkout, so their behaviour is unchanged by this, and CI is the authority.