Skip to content

make_game: tool_available parses a command line with mc_command's split_command - #5924

Open
Koro4e wants to merge 1 commit into
ItsNotRexed:mainfrom
Koro4e:tool-available-shlex
Open

Koro4e wants to merge 1 commit into
ItsNotRexed:mainfrom
Koro4e:tool-available-shlex

Conversation

@Koro4e

@Koro4e Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as this finding, from @HalpDmaGetIommuInterface's report.

What and why

make_game.py's tool_available took the head of a command line with a plain cmd.split()[0], so a quoted executable with spaces followed by arguments was misread: tool_available('"C:\Program Files\Git\bin\git.exe" --version') took C:\Program as the head and returned False, and need() then failed a tool that was installed. (A quoted path with no arguments and an unquoted path with spaces were fine, because the whole string is then the file.)

The command line now goes through mc_command.split_command, which already owns the MSVC quoting rules and which make_game imports for mc_command anyway - the same "one place owns the path rules" shape the tracker keeps asking for. A path, a PATH name and the wsl -d ... command line behave exactly as before; an invalid command line counts as not available instead of raising.

Two commits: the function, then the test.

Tested

  • python -m pytest tests/test_make_game_argparse.py -q: 37 passed, 13 subtests passed (new test_a_quoted_executable_with_spaces_and_arguments_is_true among them, with a temporary directory whose name contains a space so the case does not depend on the machine's install layout).
  • Negative control: with main's make_game.py the new test fails (... is True got False); with this branch all 37 pass.
  • Manual: the git.exe case from the finding, plus the not-installed negative.

Windows 11, Python 3.12.10, CPU only. No game files.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator changes.)

@LocranKing

Copy link
Copy Markdown
Contributor

Tested 84d28b4de on Windows 11 Home Build 26200 (Python 3.12.10, NVIDIA GeForce RTX 3060 Ti / driver 621.01): pass

  • python -I -m compileall -q make_game.py tools tests: exit 0
  • python -I make_game.py --help: exit 0
  • python -I tests/test_make_game_argparse.py -v: 37/37 passed (8.545s), including test_a_quoted_executable_with_spaces_and_arguments_is_true

AI-assisted. No game files.

@leozinhoszg

Copy link
Copy Markdown
Contributor

Tested 84d28b4d on Windows 11 Pro (26200), CPython 3.14.7, CPU only, no game files: duplicate.

Suggestion: merge one version, not three. Either land #379 and close this PR, or, if maintainers want the shared helper, rebase this change onto #379 as a follow-up and relax that test's assert_called_once_with("wsl").

AI-assisted.

@memorypressure

Copy link
Copy Markdown

Verified at your head on main 561b65a: tool_available now routes through mc_command.split_command, which is how the mc path is really resolved, and the SystemExit catch matches split_command's documented failure path on malformed quoting; test_make_game_argparse 37/37 with the new quoted-path-with-spaces cases (re-run, 1 env skip). No other callers affected. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Koro4e

Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Comparing with #5913 per the coordination thread: both fix tool_available's naive cmd.split()[0]. #5913 does an inline shlex.split (posix=(os.name != "nt")); this PR routes the command line through mc_command.split_command (the MSVC quoting rules the project already uses) and adds tests in tests/test_make_game_argparse.py for the quoted "C:\Program Files..." case. I would keep this one for the tests + project convention, but happy to close either and fold - your call.

@Koro4e

Koro4e commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (8575d36) - the conflicts with the round-44 merge were resolved locally, tests pass locally (package-gated skips unchanged). Head updated on the fork.

…t_command (finding by HalpDmaGetIommuInterface)
@YordiLorenzo

Copy link
Copy Markdown

Tested 00e2bfa on Linux, Python 3.14.4: pass

  • python -I tests/test_make_game_argparse.py: 37 OK, 1 skip (pytest the same, 13 subtests)
  • that test file on main 85ec876: the new quoted-path test fails, the rest pass
  • python -I tests/test_make_game_preflight.py, test_make_game_dry_run.py, test_mc_command.py: OK
  • compileall and make_game.py --help: OK
  • test_text_write_line_endings.py fails on tools/leonida_tui.py:753 and tools/wave_diff.py:373, the same on main, not from this PR

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.

5 participants