Skip to content

fix(tests): make the suite pass on Windows - #1694

Merged
manuc66 merged 2 commits into
masterfrom
fix/windows-tests
Aug 31, 2026
Merged

fix(tests): make the suite pass on Windows#1694
manuc66 merged 2 commits into
masterfrom
fix/windows-tests

Conversation

@manuc66

@manuc66 manuc66 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

The test suite was red on Windows. Three root causes and the README snapshot CRLF:

Root causes

  1. README help snapshot (CRLF) — a checkout on Windows under core.autocrlf converts the README to CRLF while the generated help uses LF, so test/readme.test.ts failed for every command. The test now normalizes line endings before comparing.
  2. ~ home expansionPathHelper.getOutputFolder("~/x") only replaced the prefix, producing C:\Users\me/someFolder (mixed separators). It now goes through path.join.
  3. Read-only folder checkcheckIfFolderIsWritable used fs.access(folder, W_OK), which ignores ACLs and the read-only attribute on Windows (verified empirically: even an icacls /deny or attrib +R still reports writable). It now probes with a real temporary file (create + delete), which is also more accurate on POSIX; the tests set an icacls (WD,AD) deny on Windows (ACLs) and keep the chmod approach on POSIX.

Also

  • The timestamp-formatting case producing : in a file name is skipped on Windows: is invalid there, so the scenario cannot be exercised (the calculation itself is still covered by the HHMMss variant).

Result

npm test on Windows: 615 passing, 1 pending, 0 failing (the pending is the skipped : case). No behavior change on POSIX.

Note: this PR intentionally does not touch the post-command feature (PR #1693) nor the discovered Windows limitation that timestamp patterns containing : produce invalid file names — flagged for a separate decision.

- 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.
@manuc66
manuc66 merged commit 28d0583 into master Aug 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant