Repository navigation
Fix skipOnWinForEPERM: check ret.stderr, not ret.code, for EPERM - #1272
Open
hikmetba-bit wants to merge 1 commit into
Open
hikmetba-bit wants to merge 1 commit into
hikmetba-bit wants to merge 1 commit into
Conversation
skipOnWinForEPERM tests /EPERM:/ against ret.code, but ret.code is
just the numeric exit code (e.g. 1); the actual error message text
("EPERM: operation not permitted, symlink ...") is on ret.stderr (see
ShellString in src/common.js). The regex against a number can never
match, so on a non-admin Windows machine (where creating a symlink
raises EPERM) the helper never detects it and falls through to run
testCase() anyway, against a symlink that was never created -- exactly
the class of local Windows test failures reported in shelljs#867.
Reproduced live on this Windows machine: shell.ln('-s', ...) fails
with EPERM as expected, ret.code is 1 (never matches), ret.stderr
contains the full "EPERM: ..." message.
Fixing the check surfaces a second, previously-unobservable bug: once
skipOnWinForEPERM actually skips testCase(), the test runs zero
assertions, which AVA treats as a failure. Give skipOnWinForEPERM the
test's `t` so it can call t.pass() on the skip path, and update all 7
call sites (test/ln.js, test/cp.js) to pass it.
Fixes shelljs#867.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
nfischer
approved these changes
Oct 4, 2026
| function skipOnWinForEPERM(action, t, testCase) { | ||
| const ret = action(); | ||
| const error = ret.code; | ||
| // ret.code is the numeric exit code; the EPERM message text is on |
Member
There was a problem hiding this comment.
You can remove this comment. I think the commit message is the better place to document this since it's about comparing the before/after effect of your PR.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1272 +/- ##
=======================================
Coverage 97.10% 97.10%
=======================================
Files 36 36
Lines 1518 1518
=======================================
Hits 1474 1474
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #867.
skipOnWinForEPERMtests/EPERM:/againstret.code, butret.codeis just the numeric exit code (e.g.1); the actual error message text ("EPERM: operation not permitted, symlink ...") is onret.stderr(seeShellStringinsrc/common.js:that.stderr = stderr; that.code = code;). The regex against a number can never match, so on a non-admin Windows machine (where creating a symlink raisesEPERM) the helper never detects it and falls through to runtestCase()anyway, against a symlink that was never created — exactly the class of local Windows test failures reported in the issue.Reproduced live on this Windows machine:
Second bug this surfaces
Once
skipOnWinForEPERMactually detects EPERM and skipstestCase(), the test runs zero assertions — which AVA treats as a failure (Test finished without running any assertions). This was never observable before, since the detection never worked.Gave
skipOnWinForEPERMthe test'stso it can callt.pass()on the skip path, and updated all 7 call sites (test/ln.js×4,test/cp.js×3) to pass it.Testing
ret.code→ret.stderrline and confirmedtest/ln.jsfails with the same real assertion failures the issue reports (Value is not truthy: falseonfs.existsSync(...)), not just a skip.npx ava test/ln.js test/cp.js— all pass, withGot EPERM when testing symlinks on Windows. Assuming non-admin environment and skipping test.printed and the test correctly marked passed (not "0 assertions" failed).npx ava: 1 pre-existing, unrelated failure (find › -L flag, folder is symlinked— a checked-in symlink test fixture that isn't a real symlink after a Windowsgit checkout; reproduced identically on unmodifiedmain), everything else green.npx eslinton the changed files: clean.🤖 Generated with Claude Code