Skip to content

test_run_wine_tests: quote the interpreter passed as --wine so a path with spaces stays one argument - #4562

Open
Halfect wants to merge 2 commits into
ItsNotRexed:mainfrom
Halfect:test/run-wine-tests-quoted-interpreter
Open

Halfect wants to merge 2 commits into
ItsNotRexed:mainfrom
Halfect:test/run-wine-tests-quoted-interpreter

Conversation

@Halfect

@Halfect Halfect commented Nov 23, 2026 •

Copy link
Copy Markdown

Claim: #4421 (comment)

What: The four main() call sites in tests/test_run_wine_tests.py pass the Python interpreter to --wine as an unquoted sys.executable.replace(os.sep, "/"). The runner's wine_command splits the value with shlex.split, which is correct command-line behaviour, so an interpreter path that contains a space — C:\Program Files\Python314 on Windows, or any venv/CI path with a space, which includes this test machine's .../Application Support/... — is cut at the first space and the subprocess cannot start. Quoting the path keeps it one argument through the split. Same class of bug as #379 (which fixed make_game.tool_available); this one is in the test's own command-line construction — the runner itself is fine.

Tested: macOS 15.6.1 (Apple silicon), CPython 3.14, interpreter path containing spaces. CPU only, no game files. AI-assisted.

  • Before: python -I tests/test_run_wine_tests.py → 3 failures (test_main_maps_the_drive_while_the_tests_run, test_a_required_test_that_passes_exits_zero, test_the_summary_table_is_appended), each could not start /Users/<local-user>/Library/Application: No such file or directory — the path truncated at the space.
  • After: 51/51 OK, including a new regression test asserting wine_command(python_wine()) round-trips to exactly one argument. On a machine without spaces the quotes are stripped by shlex.split and behaviour is unchanged.

No overlap with #4462 (different file, scripts/run_wine_tests.py).

@Atomic258

Copy link
Copy Markdown

Tested 49449b0560 on Linux, Python 3.10, CPU only, synthetic fixtures, no game files: pass (with a note).

  • python -I tests/test_run_wine_tests.py → 51/51; tests/test_first_look_rebuild.py → 2 skipped (PowerShell-only).
  • This PR does not change scripts/run_wine_tests.py — it quotes the interpreter path in the tests and adjusts scripts/first_look.ps1. The same 51/51 also pass with main's tool, so no negative control applies; the Linux run covers the test change only.
  • first_look.ps1 not executed here (no pwsh on this box).
  • git diff --check and check_no_game_data.py clean.

AI-assisted (Devin).

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ran this at 49449b05 on Windows 11: python -I tests/test_run_wine_tests.py -> 51 tests, OK (5 skipped); git diff --check clean.

The --wine interpreter is quoted so a path with spaces stays a single argument, and the added cases cover it. No blocking issue.

@Halfect

Halfect commented Nov 23, 2026

Copy link
Copy Markdown
Author

@Atomic258 thanks for testing! One clarification: this PR touches only tests/test_run_wine_tests.py (+13/−4, single file) — it does not touch scripts/first_look.ps1; you may be thinking of #4568. Your 51/51 pass covers this PR's change on a space-free Linux path, which matches the expectation that the added quotes are stripped by shlex.split and behaviour is unchanged there.

@Atomic258

Copy link
Copy Markdown

Correction to my earlier comment: this PR touches only tests/test_run_wine_tests.py (+13/−4) and does not touch scripts/first_look.ps1 — that belongs to #4568, and my mention of it here was a mix-up. The results stand as run on head 49449b05601c73a1284c8ebab32995a74c47fa29: python -I tests/test_run_wine_tests.py → 51/51. Because the PR changes no tool code, the same 51/51 pass with main's tool too, so no negative control applies; the Linux run covers the test change only. AI-assisted (Devin).

@whattheflop whattheflop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI-assisted Windows x64 verification at 49449b05, uv CPython 3.12.13, with a real disposable interpreter path. With an ordinary spaced path, Windows could still launch the child after shlex.split() split the unquoted interpreter. In a path with two adjacent spaces, unquoted launch failed whereas python_wine() kept the exact path as one argument and the child launched with the same interpreter and version.

On that two-space path, base d0835dd9 had 43 passes, 5 skips and 2 failures. #4562 had 46 passes and 5 skips. The clean scratch integration with #4558 e7ac88ea had 48 passes and 5 skips. Both added scheduler tests already call the quoted helper through run_main(). The integration used a Python stand-in for Wine.

@tupacfan04

Copy link
Copy Markdown
Contributor

SOUND (test-only). The premise checks out: scripts/run_wine_tests.py:214 uses shlex.split, so an unquoted C:/Program Files/... splits into two args and the quoted form round-trips to one; backslash paths survive POSIX quoting too. tests/test_run_wine_tests.py gives 46 passed / 5 skipped / 44 subtests, compileall clean, and the merge is clean.

One weakness: the negative control cannot fail here because sys.executable has no spaces - reverting the helper to unquoted still passes. The new test (:525) only asserts the quoted round-trip, never that unquoted spaced input splits. A case that feeds a synthetic C:\Program Files\wine string through the same helper (asserting one argument after quoting and two without) would make the guard real on every platform.

Approve with that. AI-assisted review, no game files, no GPU.

@Halfect

Halfect commented Nov 23, 2026

Copy link
Copy Markdown
Author

@tupacfan04 good point — done in 1b79ac92: test_an_unquoted_spaced_wine_splits_but_the_quoted_form_does_not feeds a synthetic C:/Program Files/Python314/python.exe through wine_command and pins both sides (unquoted splits into two arguments, quoted stays one), so the guard now fails on any platform if the quoting is dropped, not just where the interpreter's path has a space. python -I tests/test_run_wine_tests.py → 52/52 OK here (macOS 15.6.1, CPython 3.12, spaced interpreter path).

@kapitche

kapitche commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 1b79ac9 merged with main d0835dd on WSL2 Ubuntu, Python 3.12.16: pass.

  • python -I tests/test_run_wine_tests.py: 52 tests OK. The PR only changes this test file, so the negative control is a mutation: shlex.split(text) -> text.split() in scripts/run_wine_tests.py::wine_command gives 7 failures, including both new tests (test_python_wine_command_line_stays_one_argument, test_an_unquoted_spaced_wine_splits_but_the_quoted_form_does_not) and the existing quoting tests.
  • Read: python_wine() quotes sys.executable once and all the --wine call sites use it. No issue found.

Windows 11 (Python 3.13.1, PowerShell 5.1): 52 tests OK (5 skipped). I did not check which tests are among the 5 skips.

@Halfect

Halfect commented Nov 23, 2026

Copy link
Copy Markdown
Author

Overlap check for the queue: #4558 also edits tests/test_run_wine_tests.py (adds fixture-ordering tests around the old line 418). I applied this PR's diff on top of #4558's head e7ac88ea — the changes touch different regions, apply cleanly, and the combined file passes 52/52 (macOS 15.6.1, CPython 3.12). No rebase needed between these two PRs in either order.

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.

6 participants