tests: quote the respawned executable path on Windows #1111

Closed
github-bot wants to merge 3 commits from gh-pr/1111/head into gh-pr/1111/base
Owner

@⁠Nawid3333 on GitHub · 2026-10-06 18:47 UTC · original
Nawid3333:tests/quote-respawned-path → main · +2 −1 · 1 files · 3 commits · closed without merging

Problem

save_data_memory_tests fails on Windows whenever the repository is checked out in a path that contains a space, for example V:\Ps5 emulator Project\KytyPS5:

SaveDataMemoryTests:583: _spawnl(_P_WAIT, ...) == 0

(ctest reports exit code 0xc0000409.)

Cause

The test re-runs its own executable in child modes through RunChild, which on Windows calls _spawnl(_P_WAIT, path, arg0, mode, nullptr). The CRT builds the child's command line by joining arg0 and mode with a space, without quoting. The child then splits that line back into argv at the spaces, so a path such as V:\Ps5 emulator Project\...\save_data_memory_tests.exe turns into several arguments, argv[1] is no longer the mode, and the child exits with an error.

Fix

Quote arg0. Only the command line needs it: the first _spawnl argument (the file to run) is passed to the OS directly and stays unquoted. The POSIX branch uses execl with a real argument array and is unchanged.

How to reproduce

On Windows, from a checkout whose path contains a space:

cmake --build _Build/windows --target save_data_memory_tests
ctest --test-dir _Build/windows --output-on-failure -R "^save_data_memory$"

On main the test fails as above; the same .exe copied to a directory without spaces passes, which isolates the cause to the path. With this PR it passes in place.

Testing

Windows 11, clang-cl 19.1.5, Release, on main 6ef40654:

  • Before / after as described above.
  • Full ctest run (53 tests, kyty_tests) on this branch vs. main: the only difference is save_data_memory (failed → passed).
  • CI on this PR: Windows, Linux and macOS builds pass. (CI doesn't build save_data_memory_tests, so it only shows nothing else is affected.)

Scope: test code only, Windows-only branch of RunChild; no emulator code changes.

AI use (per the README's AI policy): Claude (Anthropic) found the root cause while checking a CI change, wrote the fix and ran the testing above on my machine. I reviewed the change and the results before marking this PR ready.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-06 18:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1111) `Nawid3333:tests/quote-respawned-path` → `main` · +2 −1 · 1 files · 3 commits · closed without merging ## Problem `save_data_memory_tests` fails on Windows whenever the repository is checked out in a path that contains a space, for example `V:\Ps5 emulator Project\KytyPS5`: ``` SaveDataMemoryTests:583: _spawnl(_P_WAIT, ...) == 0 ``` (`ctest` reports exit code 0xc0000409.) ## Cause The test re-runs its own executable in child modes through `RunChild`, which on Windows calls `_spawnl(_P_WAIT, path, arg0, mode, nullptr)`. The CRT builds the child's command line by joining `arg0` and `mode` with a space, **without quoting**. The child then splits that line back into `argv` at the spaces, so a path such as `V:\Ps5 emulator Project\...\save_data_memory_tests.exe` turns into several arguments, `argv[1]` is no longer the mode, and the child exits with an error. ## Fix Quote `arg0`. Only the command line needs it: the first `_spawnl` argument (the file to run) is passed to the OS directly and stays unquoted. The POSIX branch uses `execl` with a real argument array and is unchanged. ## How to reproduce On Windows, from a checkout whose path contains a space: ``` cmake --build _Build/windows --target save_data_memory_tests ctest --test-dir _Build/windows --output-on-failure -R "^save_data_memory$" ``` On `main` the test fails as above; the same `.exe` copied to a directory without spaces passes, which isolates the cause to the path. With this PR it passes in place. ## Testing Windows 11, clang-cl 19.1.5, Release, on `main` 6ef40654: - Before / after as described above. - Full `ctest` run (53 tests, `kyty_tests`) on this branch vs. `main`: the only difference is `save_data_memory` (failed → passed). - CI on this PR: Windows, Linux and macOS builds pass. (CI doesn't build `save_data_memory_tests`, so it only shows nothing else is affected.) Scope: test code only, Windows-only branch of `RunChild`; no emulator code changes. **AI use** (per the README's AI policy): Claude (Anthropic) found the root cause while checking a CI change, wrote the fix and ran the testing above on my machine. I reviewed the change and the results before marking this PR ready. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
RunChild passes the unquoted executable path as argv[0] to _spawnl.
The CRT joins the arguments with spaces and no quoting, so from a
checkout path that contains a space the child re-parses its own path
as several arguments, never sees the mode argument, and exits nonzero:
save_data_memory fails with CHECK at SaveDataMemoryTests:583. Quote
argv[0]; the spawned file path itself needs no quoting.

Verified on Windows 11 at a path with a space: fails before, passes
after. The POSIX branch is unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
Brings in #1122 so the macOS build compiles again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01QJhF6gpTPKHJ9g5oQzUq3e
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:43:24 +00:00
github-bot closed this pull request 2026-11-26 09:43:24 +00:00
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-06 20:50 UTC · original

@⁠coderabbitai review

**@⁠Nawid3333** on GitHub · 2026-10-06 20:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1111#issuecomment-6025209448) @⁠coderabbitai review
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-06 20:51 UTC · original · edited 2026-10-06 20:57 UTC

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-06 20:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1111#issuecomment-6025211605) · edited 2026-10-06 20:57 UTC <!-- This is an auto-generated reply by CodeRabbit --> <!-- CodeRabbit review command invocation: v2:915ebb1cfae514d3d984947e2f1f1f3df20d47b6e95cf9cfb1b238c1541862d3 --> <details> <summary>✅ Action performed</summary> Review finished. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused. </details>
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-06 20:57 UTC · original · edited 2026-10-06 22:55 UTC

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 95d865b0-1239-4993-bade-027bce3db1b5
📥 Commits

Reviewing files that changed from the base of the PR and between 610c839b18 and 15c4556f3e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b9d51f6-b445-4417-ad30-aa69253c4761
📥 Commits

Reviewing files that changed from the base of the PR and between 199d0a9d92 and 610c839b18.

📒 Files selected for processing (1)
  • tests/SaveDataMemoryTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

On Windows, RunChild now passes a quoted executable path as _spawnl’s argv[0]. Other arguments and the non-Windows fork/exec path are unchanged.

Suggested reviewers: c0sxm0s

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 610c8

This test-only change is intended to let the Windows child test run from checkout paths containing spaces. The available evidence supports that behavior, and no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Windows executable-path quoting fix in the test code.
Description check ✅ Passed The description explains the path-with-spaces failure, its cause, the fix, and the reported testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-06 20:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1111#issuecomment-6025310088) · edited 2026-10-06 22:55 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1111?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: skip review by coderabbit.ai --> > [!IMPORTANT] > ## Review skipped > > Review was skipped as selected files did not have any reviewable changes. > > > > > > <details> > <summary>⚙️ Run configuration</summary> > > - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml > - **Review profile**: CHILL > - **Plan**: Advanced > - **Run ID**: `95d865b0-1239-4993-bade-027bce3db1b5` > > </details> > > <details> > <summary>📥 Commits</summary> > > Reviewing files that changed from the base of the PR and between 610c839b1889ae0756c2465aa0eaefb20f37d622 and 15c4556f3e9908918ec23ee14c12d14e15456ff7. > > </details> > > You can disable this status message by setting the `reviews.review_status` to `false` in the CodeRabbit configuration file. > > Use the checkbox below for a quick retry: > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: skip review by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `5b9d51f6-b445-4417-ad30-aa69253c4761` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 199d0a9d9225e560432301e39439296d57fa0e34 and 610c839b1889ae0756c2465aa0eaefb20f37d622. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/SaveDataMemoryTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough On Windows, `RunChild` now passes a quoted executable path as `_spawnl`’s `argv[0]`. Other arguments and the non-Windows `fork`/`exec` path are unchanged. **Suggested reviewers:** `c0sxm0s` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"610c839b1889ae0756c2465aa0eaefb20f37d622" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `610c8` <!-- final_review_risk_coverage:{"sourceCommitId":"610c839b1889ae0756c2465aa0eaefb20f37d622","coveredCommitId":"610c839b1889ae0756c2465aa0eaefb20f37d622","kind":"reviewed"} --> This test-only change is intended to let the Windows child test run from checkout paths containing spaces. The available evidence supports that behavior, and no actionable merge-blocking risk remains. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :--------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly describes the Windows executable-path quoting fix in the test code. | | Description check | ✅ Passed | The description explains the path-with-spaces failure, its cause, the fix, and the reported testing. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1111)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.