fix(tests): make the suite pass on Windows - #1694
Merged
Merged
Conversation
- readme.test.ts: compare help snapshots after normalizing CRLF, so a Windows checkout (autocrlf) no longer fails the test. - PathHelper.getOutputFolder: expand ~ via path.join so the path uses the platform separator consistently. - PathHelper.checkIfFolderIsWritable: probe with a real temporary file instead of fs.access(W_OK), which ignores ACLs and the read-only attribute on Windows; the read-only tests now deny write access with icacls on Windows and keep chmod on POSIX. - Skip the timestamp-formatting case that produces a ':' in the file name (invalid on Windows). The suite now runs green on Windows (615 passing, 1 pending).
Resolve the CHANGELOG conflict: keep the [Unreleased] section with both the pattern-validation feature (master) and the Windows test fixes under one heading.
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.
The test suite was red on Windows. Three root causes and the README snapshot CRLF:
Root causes
core.autocrlfconverts the README to CRLF while the generated help uses LF, sotest/readme.test.tsfailed for every command. The test now normalizes line endings before comparing.~home expansion —PathHelper.getOutputFolder("~/x")only replaced the prefix, producingC:\Users\me/someFolder(mixed separators). It now goes throughpath.join.checkIfFolderIsWritableusedfs.access(folder, W_OK), which ignores ACLs and the read-only attribute on Windows (verified empirically: even anicacls /denyorattrib +Rstill reports writable). It now probes with a real temporary file (create + delete), which is also more accurate on POSIX; the tests set anicacls(WD,AD)deny on Windows (ACLs) and keep thechmodapproach on POSIX.Also
:in a file name is skipped on Windows —:is invalid there, so the scenario cannot be exercised (the calculation itself is still covered by theHHMMssvariant).Result
npm teston Windows: 615 passing, 1 pending, 0 failing (the pending is the skipped:case). No behavior change on POSIX.