test(backend): fix Windows ENOENT in backend-tests-glob regression check#7794
Conversation
The previous version called execFileSync('npx', ...). On Windows
runners (and any Windows host where npx is installed as npx.cmd),
node's child_process.spawn does not auto-pick the .cmd shim, so
the call fails with spawnSync npx ENOENT. CI on develop went red
for "Windows without plugins" because of this — Linux passed.
Resolve mocha's JS entry directly via require.resolve and run it
under the current node process. No shell, no .cmd resolution,
identical behaviour on every platform.
Also normalise the absolute paths mocha prints to POSIX-relative
form so the toContain() assertions match on both Linux (which
emits forward slashes) and Windows (backslashes).
Verified locally that the test still fails when the package.json
glob is reverted to the broken tests/backend/specs/**.ts pattern.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Review Summary by QodoFix Windows ENOENT in backend tests glob regression check
WalkthroughsDescription• Fix Windows ENOENT error in backend tests glob regression check • Replace npx mocha with direct node invocation using require.resolve() • Normalize absolute paths to POSIX-relative form for cross-platform assertions • Handle both Unix and Windows line endings in mocha output Diagramflowchart LR
A["execFileSync npx"] -->|Windows fails| B["ENOENT error"]
C["require.resolve mocha"] -->|Direct invocation| D["process.execPath"]
D -->|Cross-platform| E["Success on all OS"]
F["Absolute paths"] -->|Normalize| G["POSIX-relative paths"]
G -->|Match assertions| H["Linux and Windows"]
File Changes1. src/tests/backend-new/specs/backend-tests-glob.test.ts
|
Code Review by Qodo
1.
|
Qodo flagged the prefix-strip + sep-split approach as brittle. On Windows runners mocha can emit paths with mixed separators or different drive-letter casing, in which case startsWith() misses the prefix and the assertions fail against absolute paths. path.relative(srcRoot, abs) handles drive-letter casing and mixed separators consistently, then a final replace([\\/]) -> '/' yields POSIX-relative paths regardless of how mocha printed them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
Summary
The backend-tests glob regression check added in #7789 (
src/tests/backend-new/specs/backend-tests-glob.test.ts) calledexecFileSync('npx', ...). Node'schild_process.spawndoes not auto-resolve.cmd/.batshims, so on Windows runners the call fails withspawnSync npx ENOENT. develop's CI went red on "Windows without plugins (24)" after #7789 merged; Linux passed.Fix
Resolve mocha's JS entry via
require.resolve('mocha/bin/mocha.js')and run it under the current node process. No shell, no platform-specific shim, identical behaviour everywhere.Also normalise the absolute paths mocha prints to POSIX-relative form so the
toContain()assertions match on both Linux (forward slashes) and Windows (backslashes).Test plan
tests/backend/specs/**.tspattern.🤖 Generated with Claude Code