Skip to content

Tests: run the batch file by path, not by bare name - #4218

Open
Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:test/llvm-mc-batch-path
Open

Ayinaki wants to merge 1 commit into
ItsNotRexed:mainfrom
Ayinaki:test/llvm-mc-batch-path

Conversation

@Ayinaki

@Ayinaki Ayinaki commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as this item.

What and why

tests/test_build_llvm_mc_batch.py writes check-console.cmd and runs it as cmd.exe /d /c check-console.cmd with cwd set to the temp folder. cmd resolves that name only by searching the current directory, so wherever NoDefaultCurrentDirectoryInExePath is set — it is 1 in this environment, and cmd /c echo %NoDefaultCurrentDirectoryInExePath% shows the value reaching the child — both subtests die with:

'check-console.cmd' is not recognized as an internal or external command,
operable program or batch file.

That says nothing about what the test checks (the batch writer build_llvm_mc.ps1 keeps the caller's exit status and console code page through the bat). The generated script has the same weakness one level down: it calls _build.cmd by bare name.

The change passes the file's path to the outer subprocess.run, and has the generated script reach _build.cmd through %~dp0, so both levels work in a shell that does not search the current directory. Nothing else changes: cwd stays set, so the cd /d line the writer emits is still exercised, and the assertions on the written batch are untouched.

Tested

Windows 11 26200, Python 3.14.6, CPU only; no GPU, no game files.

command result
py -3 -m pytest tests/test_build_llvm_mc_batch.py -q on main aa2988cc, variable set as here 2 failed, 1 passed — SUBFAILED(exit_code=0) and SUBFAILED(exit_code=17), both with the message above
same command on this branch 1 passed, 2 subtests passed
same command with NoDefaultCurrentDirectoryInExePath unset, on main and on this branch 1 passed, 2 subtests passed both times
py -3 -m pytest tests --ignore=tests/semantic -q on aa2988cc 6 failed, 6465 passed, 97 skipped, 7640 subtests passed
py -3 -m unittest discover -s tests/semantic -q on aa2988cc Ran 7456 tests, FAILED (failures=7, errors=2, skipped=1, expected failures=1)
py -3 -m compileall -q make_game.py tools tests exit 0
node --test tests/test_viewer_streaming.cjs 47 pass, 0 fail

The other five failures in the pytest run are separate items that already have open PRs, and this change touches none of them: test_check_no_game_data.py::test_default_mode_reads_tracked_files_only (PermissionError unlinking a read-only git object during teardown, #3897), test_saves.py::AtomicPackTest::test_destination_symlinks_update_the_target_and_remain_links (the link reads back with a \?\ prefix, #3983), and test_u16_high_half.py::test_d16_buffer_store_no_redundant_extract_after_shr16 (#3902). The tests/semantic failures are the three red files every translator PR shows: test_cmp_class_f64 (2, #3948/#3885), test_mutations (2, #3883), test_loop_ballot_barrier (3 failures + 2 errors, #3995).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), in the change or in this description.
  • No translator rule is added, so docs/design.md is unchanged.

Depends on: nothing.

test_build_llvm_mc_batch invokes check-console.cmd as a bare name with cwd
set, so cmd finds it only by searching the current directory. With
NoDefaultCurrentDirectoryInExePath set, which some shells and hardened
environments export, both subtests fail with "'check-console.cmd' is not
recognized as an internal or external command" — nothing to do with the exit
status and console code page they test. Pass the file's path, and let the
generated script reach _build.cmd through %~dp0 for the same reason.

@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 8932390b on Windows 11: python -I tests/test_build_llvm_mc_batch.py -> 1 test, OK; git diff --check clean.

The test's check-console.cmd now calls "%~dp0_build.cmd" and is invoked by its absolute path, so it no longer depends on the current directory being searched for a bare batch name. That is the safer form and matches how the generated build scripts are meant to be called. No blocking issue.

@sds-228 sds-228 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.

Code review of 8932390: no issues found. The generated batch script is invoked by absolute path and reaches its child through its own directory. Targeted suite: 1 test OK; compileall and diff check clean.

AI-assisted (OpenCode).

@Etr0p

Etr0p commented Nov 23, 2026

Copy link
Copy Markdown

Tested 8932390 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.
  • Control on main at 03b09a08, same machine: both subtests fail with 'check-console.cmd' is not recognized as an internal or external command. This machine has NoDefaultCurrentDirectoryInExePath=1 in its environment, which is why the bare name is not found.

#3380 changes the same lines for the same failure and also passes here (cd6fc073).

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.

4 participants