Skip to content

tests: start _build.cmd as .\_build.cmd in the two batch-writer tests - #3380

Open
ezbyDev wants to merge 1 commit into
ItsNotRexed:mainfrom
ezbyDev:tests/batch-by-full-path
Open

ezbyDev wants to merge 1 commit into
ItsNotRexed:mainfrom
ezbyDev:tests/batch-by-full-path

Conversation

@ezbyDev

@ezbyDev ezbyDev commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claim: #3232 (comment) (TEST-668)

What changed and why

The tests that run a generated _build.cmd started it by a bare name (or, on current main, by its full path). Both forms break:

  • Bare name: with NoDefaultCurrentDirectoryInExePath set, cmd.exe does not search the current folder for a bare command name, so the tests fail with "_build.cmd" is not recognized even though the batch writer under test is fine. Claude Code sets this variable, so agent-driven runs on Windows hit it.
  • Full path: cmd.exe /c splits a full path that holds & (found by @Vonsek and @slint6614-dev in review).

Rebased on main aa2988cc. Since #2515, tests/test_build_llvm_mc_batch.py starts a check-console.cmd wrapper that calls _build.cmd, and the runtime half moved from test_build_runtime_fallback.py to tests/test_build_runtime_batch.py, which passes the full path. As @whattheflop found (TEST-852, released in favour of this PR), both names need qualifying:

  • tests/test_build_llvm_mc_batch.py: r".\check-console.cmd" in the Python call and call .\_build.cmd inside the wrapper, with NoDefaultCurrentDirectoryInExePath=1 set for that cmd.exe call so CI covers the case whatever the runner's environment.
  • tests/test_build_runtime_batch.py: r".\_build.cmd" instead of str(batch_path) (it already set the variable).

An explicit relative name is found with the variable set (it only blocks bare names), and both calls already run with the batch's folder as cwd. Tests only; no script, tool or game-data change.

Tests (Windows 11, Python 3.12.10, CPU only, no GPU used)

16 runs per side: TEMP as the default, a folder holding &, one holding (x) and one holding 東京; the variable set or unset in the outer environment.

  • This head: both tests pass in all 16.
  • main aa2988cc: test_build_llvm_mc_batch.py fails in all 8 runs with the variable set (failures=2, both exit-status subtests) and passes with it unset; test_build_runtime_batch.py fails in the 2 & runs (errors=1) and passes in the other 14.
  • Mutation: qualifying only the outer name (call _build.cmd in the wrapper) fails both subtests with "_build.cmd" is not recognized, so both qualifications are needed.
  • python -m compileall -q on both files: OK.

AI-assisted (Claude Code).

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Second check on Windows at 51f9fabe. With NoDefaultCurrentDirectoryInExePath set, the parent fails both batch launch tests and this head passes all six tests. This head also passes with the flag unset and with a space in the temporary root. The tests only ran generated batches with stubs.

One regression with a valid Windows temp path containing &: both tests pass on the parent with the flag unset, but both fail on this head because cmd.exe /c splits the absolute path at the ampersand. Both calls already set the batch's directory as cwd. Substituting the explicit relative argument r".\_build.cmd" in memory made all six tests pass with that temp path and the child flag still forced on.

AI-assisted.

@ezbyDev

ezbyDev commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Overlap note: #2717 (adds tests elsewhere in test_build_runtime_fallback.py, currently conflicting) and #2515 (rewrites test_build_llvm_mc_batch.py) touch the same files. Neither changes these lines; I left a repro on #2515, whose new test has the same bare-name call.

@slint6614-dev slint6614-dev 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.

Changes requested: both tests now pass the absolute temporary path through cmd.exe /c. With a valid temp root containing &, cmd.exe parses the ampersand as a command separator and both tests fail. Since each call already sets cwd to the batch directory, please pass r'.\_build.cmd' (or otherwise avoid cmd.exe parsing the path) in both tests, while keeping NoDefaultCurrentDirectoryInExePath=1 so the original case remains covered. This was reproduced on 51f9fabe; the independent check reports that the relative argument passes all six test cases with the ampersand path.

ezbyDev added a commit to ezbyDev/Leonida that referenced this pull request Nov 22, 2026
Review on ItsNotRexed#3380: `cmd.exe /c <full path>` splits a temp path that holds
` & `, which the bare name never did. An explicit `.\` relative name is still
found with NoDefaultCurrentDirectoryInExePath set (that only blocks bare
names), and both calls already run with the batch's folder as cwd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ezbyDev ezbyDev changed the title tests: run _build.cmd by full path in the two batch-writer tests tests: start _build.cmd as .\_build.cmd in the two batch-writer tests Nov 22, 2026
@ezbyDev

ezbyDev commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@Vonsek thanks, reproduced: at 51f9fabe both tests fail with a temp folder holding &, and main passes there. Fixed in 719dd1d5 with r".\_build.cmd" as you suggested. Both tests now pass with TEMP set to the default, &, (x) and 東京 folders, each with NoDefaultCurrentDirectoryInExePath set and unset, and putting the bare name back still fails both.

@ezbyDev

ezbyDev commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

@slint6614-dev thanks, that's the same case @Vonsek found. It's fixed in 719dd1d5 (pushed just after your review): both calls now pass r".\_build.cmd" and keep NoDefaultCurrentDirectoryInExePath=1. Both tests pass with TEMP as the default, &, (x) and 東京 folders, each with the variable set and unset. Could you take another look when you have a moment?

@nonverifiedperson

Copy link
Copy Markdown
Contributor

Tested 719dd1d5 on Windows 10 22H2 (19045, OEM code page 437, ANSI 1252), Python 3.15.0, with NoDefaultCurrentDirectoryInExePath=1 set by Claude Code: pass.

  • On main (f847748c), test_build_runtime_fallback.py and test_build_llvm_mc_batch.py each fail with one error: '_build.cmd' is not recognized.
  • At this head, both are OK.
  • Same cause, isolated outside the tests: cmd can't find a bare x.cmd in a Leonida 東京 folder while the variable is set, finds it when the variable is unset, and always finds it by its full path. This happens in plain ASCII folders too, so the variable is the whole cause, not the non-ASCII name.

AI-assisted (Claude Code). No game files.

@whattheflop

Copy link
Copy Markdown
Contributor

TEST-852 overlaps this fix, so I?m holding the local patch and sharing the current-main regression here. Since #2515, tests/test_build_llvm_mc_batch.py starts check-console.cmd, which calls the generated _build.cmd. Both names need explicit paths in the rebase: r".\check-console.cmd" in the Python subprocess, and call .\_build.cmd inside the wrapper. Qualifying only one still fails both expected exit statuses under NoDefaultCurrentDirectoryInExePath=1.

On native Windows with uv CPython 3.12.13, both qualifications passed alongside the runtime batch test, preserving exit 0, exit 17 and restoration to code page 437. This was checked on 4c52ce27, and the test file is unchanged at aa2988cc. TEST-852 claim. AI-assisted.

Rebased on main (aa2988c). Since ItsNotRexed#2515 the llvm-mc test starts a
check-console.cmd wrapper that calls _build.cmd, and the runtime half
moved to tests/test_build_runtime_batch.py, which passes the full path.

- test_build_llvm_mc_batch.py: r".\check-console.cmd" in Python and
  `call .\_build.cmd` in the wrapper, run with
  NoDefaultCurrentDirectoryInExePath=1. With that set, cmd.exe skips the
  current folder for a bare name; qualifying only the outer name still
  fails both exit-status subtests.
- test_build_runtime_batch.py: r".\_build.cmd" instead of the full path,
  which cmd.exe /c splits when the temp folder holds ` & `.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ezbyDev
ezbyDev force-pushed the tests/batch-by-full-path branch from 719dd1d to cd6fc07 Compare November 22, 2026 22:17
@ezbyDev

ezbyDev commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on main (aa2988cc) as cd6fc073, resolving the conflict with #2515 and the move of the runtime batch test.

Thanks @whattheflop: you were right that both names need qualifying. r".\check-console.cmd" in Python and call .\_build.cmd in the wrapper; with only the outer one, both exit-status subtests still fail under NoDefaultCurrentDirectoryInExePath=1. The new tests/test_build_runtime_batch.py passed the full path, which is the & case @slint6614-dev and @Vonsek found, so it now starts .\_build.cmd too.

Both tests pass in all 16 temp-folder × variable combinations (default / & / (x) / 東京, set / unset). On main, the llvm-mc test fails whenever the variable is set and the runtime test fails in the & folders. Details are in the updated description. Windows 11, Python 3.12.10, CPU only. AI-assisted.

@slint6614-dev, could you take another look when you have a moment?

@oVolkra

oVolkra commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 719dd1d on Windows 11 (CPU-only, tests only): the fix works, but the PR conflicts with current main.

  • This reproduces here: Claude Code's shell sets NoDefaultCurrentDirectoryInExePath=1. On main aa2988c, test_unicode_paths_exit_status_and_console_code_page fails both subtests with "check-console.cmd" no se reconoce como un comando interno o externo. With the variable unset, the same files pass (5 passed).
  • Applied on its base f847748, the PR's diff gives tests/test_build_llvm_mc_batch.py tests/test_build_runtime_fallback.py: 6 passed, with the variable still set.
  • On aa2988c it does not apply cleanly (conflicts in both files), so it needs a rebase.

AI-assisted: this test run was done with Claude Code; the numbers above are its unedited output.

@ezbyDev

ezbyDev commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @oVolkra. The rebase landed just before your run: cd6fc073 is on aa2988cc and mergeable. It also qualifies the nested call .\_build.cmd that main's new check-console.cmd wrapper needs. Test matrix is in the description. AI-assisted.

@leozinhoszg

Copy link
Copy Markdown
Contributor

Verified head cd6fc07 (Windows 11, Python 3.13, no GPU needed). Test-only change; it merges cleanly on main 03b09a0.

  • With NoDefaultCurrentDirectoryInExePath=1 in the parent environment: tests/test_build_llvm_mc_batch.py and tests/test_build_runtime_batch.py both pass. On main 03b09a0 test_build_llvm_mc_batch fails there.
  • Without the variable: both pass.
  • The & case: with TMP/TEMP set to a folder named a & b, both pass on this head. On main, test_build_runtime_batch (which runs the batch by its full path) fails there, so .\_build.cmd fixes that one too.
  • test_text_write_line_endings and test_tool_startup pass; compileall on both files is clean.

No game data. AI-assisted (Claude Code).

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown

Tested cd6fc07 on Windows 11 Home 10.0.26200 (Python 3.13.14; CPU only, no GPU involved): pass.

  • python -I tests/test_build_llvm_mc_batch.py on this head: 1 test, OK.
  • python -I tests/test_build_runtime_batch.py on this head: 1 test, OK.
  • Control on main at 03b09a08, same machine: test_build_llvm_mc_batch.py fails both subtests with 'check-console.cmd' is not recognized as an internal or external command (this machine has NoDefaultCurrentDirectoryInExePath=1 in its environment); test_build_runtime_batch.py passes there.

#4218 changes the same lines of test_build_llvm_mc_batch.py for the same failure and also passes here (8932390b).

No game files. AI-assisted (Claude Code).

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.

8 participants