Skip to content

fix: make test suite portable across platforms#56

Merged
dkundel-openai merged 3 commits intoopenai:mainfrom
zeta987:fix/windows-test-portability
Mar 31, 2026
Merged

fix: make test suite portable across platforms#56
dkundel-openai merged 3 commits intoopenai:mainfrom
zeta987:fix/windows-test-portability

Conversation

@zeta987
Copy link
Copy Markdown
Contributor

@zeta987 zeta987 commented Mar 31, 2026

Summary

  • Replaces the hardcoded macOS path /Users/dkundel/code/codex-plugin with dynamic import.meta.url-based resolution in both test entry files.
  • Adds Windows .cmd shim creation, platform-aware PATH separators, and shell: true to spawnSync to support the test harness on Windows.
  • Improves the test pass rate on Windows from 12/64 to 59/64 (the remaining 5 failures are platform-expected edge cases).

Problem

The test suite currently has two portability issues:

  • Hardcoded absolute paths: Both commands.test.mjs and runtime.test.mjs define ROOT as "/Users/dkundel/code/codex-plugin". This path is specific to the original author's machine, causing 52 out of 64 tests to fail on any other checkout.
  • Unix-only test harness: helpers.mjs calls spawnSync without shell: true (preventing Windows from resolving .cmd shims), fake-codex-fixture.mjs hardcodes : as the PATH separator (Windows requires ;), and the fake codex binary lacks a .cmd wrapper.

Changes

  • tests/commands.test.mjs: Replaces the hardcoded ROOT with path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..").
  • tests/runtime.test.mjs: Applies the same ROOT path resolution.
  • tests/fake-codex-fixture.mjs: Generates a codex.cmd batch wrapper on Windows after writing the Unix script, and updates buildEnv to use a platform-aware PATH separator.
  • tests/helpers.mjs: Adds shell: process.platform === "win32" and windowsHide: true to spawnSync in run().

Test results

Environment Before (upstream main) After (PR A + PR B)
Windows 11 12 pass, 52 fail 59 pass, 5 fail
macOS / Linux No change expected No change expected

Related

Replace hardcoded macOS path with fileURLToPath for cross-platform
compatibility. Add .cmd wrapper creation and platform-aware PATH
separator in test fixtures so the fake codex binary is discoverable
on Windows. Add shell and windowsHide options to the test helper
run() function to match production behavior.

Test results on Windows improve from 12/64 pass to 59/64 pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zeta987 zeta987 requested a review from a team March 31, 2026 08:34
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7dad7809c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@zylar06
Copy link
Copy Markdown

zylar06 commented Mar 31, 2026

My PR #45 already fixed the hardcoded path issue, and this PR builds nicely on that to add full Windows support. Glad we’re working together to make the test suite cross-platform!

@zeta987
Copy link
Copy Markdown
Contributor Author

zeta987 commented Mar 31, 2026

My PR #45 already fixed the hardcoded path issue, and this PR builds nicely on that to add full Windows support. Glad we’re working together to make the test suite cross-platform!

Thanks for the fix in #45!
We definitely hit the exact same issue. I just took it a bit further to include the Windows-specific spawn/PATH fixes.
Happy to rebase this PR and drop the path resolution changes if yours lands first. Glad we're on the same page!

zeta987 and others added 2 commits March 31, 2026 17:31
…path breakage

When `process.execPath` resolves to a path with spaces (e.g.,
`C:\Program Files\nodejs\node.exe`), `shell: true` causes cmd.exe
to split the path at the space. Guard with `path.isAbsolute()` so
only bare command names (which need `.cmd` shim resolution) use the
shell.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dkundel-openai dkundel-openai merged commit a126634 into openai:main Mar 31, 2026
@zeta987 zeta987 deleted the fix/windows-test-portability branch April 1, 2026 13:06
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.

3 participants