Skip to content

ci(tests): re-enable CLI / examples suites on Windows via shared helpers#36

Merged
ggulpari merged 3 commits into
mainfrom
ci/windows-re-enable
Apr 23, 2026
Merged

ci(tests): re-enable CLI / examples suites on Windows via shared helpers#36
ggulpari merged 3 commits into
mainfrom
ci/windows-re-enable

Conversation

@Slashmsu
Copy link
Copy Markdown
Collaborator

Four test suites previously skipped on win32 now run across the full ubuntu/windows/macos matrix:

  • tests/cli-program.test.ts
  • tests/cli-run-modules.test.ts
  • tests/examples.test.ts
  • tests/cli.test.ts

Introduces tests/helpers/paths.ts with three small cross-platform helpers that sidestep the actual Windows failure modes:

  • canonicalTmpDir(prefix): wraps fs.mkdtempSync with fs.realpathSync, collapsing the 8.3 short-name form that os.tmpdir() can return on Windows runners into the canonical long form. No-op on Linux/macOS.
  • runCli(args, opts): thin execFileSync wrapper that invokes the built CLI via process.execPath and an argv array, bypassing cmd.exe quoting of paths with backslashes.
  • buildCliOnce(): memoised npm run build per Jest worker, with shell: true on win32 so the npm.cmd shim resolves.

Removes the coverage-gate carve-out in jest.config.js. Now that the previously-skipped suites execute on Windows the global thresholds apply unconditionally.

No production code changes.

🎉 Pull Request

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality
    to not work as expected)
  • 📚 Documentation update
  • 🔧 Configuration/build changes
  • ✅ Test improvements
  • ♻️ Code refactoring (no functional changes)

Related Issue

Fixes #(issue number)

Changes Made

Testing

  • All existing tests pass (npm test)
  • Added new tests for the changes
  • Tested manually with examples
  • Linting passes (npm run lint)
  • Type checking passes (npm run type-check)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Context


📋 License Information

SomonScript is open source software licensed under the MIT License.

By submitting this pull request, you agree that your contributions will be
licensed under the MIT License.

For contribution guidelines, please review:


Thank you for contributing to SomonScript! 🚀

Four test suites previously skipped on win32 now run across the full
ubuntu/windows/macos matrix:

- tests/cli-program.test.ts
- tests/cli-run-modules.test.ts
- tests/examples.test.ts
- tests/cli.test.ts

Introduces tests/helpers/paths.ts with three small cross-platform
helpers that sidestep the actual Windows failure modes:

- canonicalTmpDir(prefix): wraps fs.mkdtempSync with fs.realpathSync,
  collapsing the 8.3 short-name form that os.tmpdir() can return on
  Windows runners into the canonical long form. No-op on Linux/macOS.
- runCli(args, opts): thin execFileSync wrapper that invokes the built
  CLI via process.execPath and an argv array, bypassing cmd.exe
  quoting of paths with backslashes.
- buildCliOnce(): memoised npm run build per Jest worker, with
  shell: true on win32 so the npm.cmd shim resolves.

Removes the coverage-gate carve-out in jest.config.js. Now that the
previously-skipped suites execute on Windows the global thresholds
apply unconditionally.

No production code changes.
@github-actions
Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

…plicit cwd

Two cascading failures blocked the Windows matrix on PR #36:

1. tests/cli-program.test.ts init subtests call process.chdir(tempDir).
   On Windows you cannot rmdir the current working directory, so
   afterEach's fs.rmSync raised EBUSY before reaching
   process.chdir(originalCwd). The cwd leaked into the next suite.

2. tests/helpers/paths.ts buildCliOnce() ran npm without an explicit
   cwd, inheriting the leaked temp-dir path. npm then tried to open
   package.json from a deleted directory and exited ENOENT, which
   cascaded into every cli-run-modules / cli.test.ts test via their
   beforeAll hook. ~30 tests down.

Fixes:

- afterEach restores cwd first, wraps both chdir and rmSync in try /
  catch so one failure doesn't abort the rest of the teardown.
- buildCliOnce resolves to PROJECT_ROOT via __dirname and only runs
  'npm run build' when dist/cli.js is missing. The CI pipeline already
  builds in a dedicated step, so the test path is now a cheap exists()
  check rather than a subprocess that inherits process.cwd().

Linux remains green (855 passed). Real verification is the Windows
matrix on this commit.
@github-actions
Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

path.join('modules', 'x.som') emits backslashes on Windows, so the
.includes('modules/') filter produced an empty array and Jest's
test.each bailed with 'called with an empty Array of table data'.
Match either separator.
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

@ggulpari ggulpari merged commit f583700 into main Apr 23, 2026
15 checks passed
@ggulpari ggulpari deleted the ci/windows-re-enable branch April 23, 2026 06:49
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.

2 participants