Skip to content

test: cover util/escape and util/resolveCommand - #189

Closed
nococn wants to merge 2 commits into
moxystudio:masterfrom
nococn:patch-1
Closed

nococn wants to merge 2 commits into
moxystudio:masterfrom
nococn:patch-1

Conversation

@nococn

@nococn nococn commented Nov 9, 2026 •

Copy link
Copy Markdown

Summary

Adds unit tests for the two previously untested utilities in lib/util:

  • escape.test.js - covers escape.command / escape.argument: meta-char caret escaping, quoting, backslash runs before quotes and at the end of the argument, non-string input, and the doubleEscapeMetaChars option. The backslash-run cases assert the current implementation's behavior (deliberately altered in fix: disable regexp backtracking #160 to avoid regex backtracking) as regression coverage.
  • resolveCommand.test.js - covers resolution from the ambient PATH, nonexistent commands, a custom env PATH, and custom-cwd switching/restoring, using temp-dir fixtures.

Coverage for lib/util goes from ~43% lines (escape 23%, resolveCommand 21%) to 100%.

Test plan

  • npx jest --env node: 81 passed, 6 failed - the 6 failures (should emit error/close ... non-existing cwd/command, should fail with ENOENT ...) fail identically on a clean checkout in this environment: the sandbox surfaces EACCES instead of ENOENT for missing commands. All 13 new tests pass.
  • npx eslint lib/util/escape.test.js lib/util/resolveCommand.test.js: clean.

@nococn nococn closed this Nov 9, 2026
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