Skip to content

test_text_write_line_endings: scan viewer/ and all of runtime/, not only runtime/test/shaders (EGEN-TEXTWRITE-RUNTIMETEST) - #7690

Open
evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-write-newlines
Open

evilclanker9000 wants to merge 2 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-write-newlines

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Summary

tests/test_text_write_line_endings.py (BUILD-468) is the guard that keeps every text writer in the repository naming its line ending, so the same input gives the same bytes on Windows, Linux and macOS. It walked tools/, scripts/, make_game.py and only runtime/test/shaders, which left the other Python checks under runtime/test — the ones that write the Vulkan loader's settings file, logs and reports — outside the guard. One of them already broke the rule:

  • runtime/test/check_sparse_queue_family.py:83 wrote vk_layer_settings.txt with Path.write_text(..., encoding="utf-8") and no newline=, so it was CRLF on Windows and LF elsewhere.

Two commits: pin that write (newline="\n"), then widen SCAN to runtime/ and viewer/ so a new writer in either tree is caught instead of passing silently. docs/testing.md/AGENTS.md already state the convention; nothing else changes.

Test

CPU only, Windows 11, CPython 3.14.3. No GPU, no game files.

Red without the fix — this branch with the writer's newline= reverted (so only the SCAN change is in play):

$ python -I tests/test_text_write_line_endings.py
FAILED (failures=1)
- ['tools\\leonida_tui.py:753',
-  'tools\\wave_diff.py:373',
-  'runtime\\test\\check_sparse_queue_family.py:83'] : text writes without newline= (CRLF on Windows, LF elsewhere):
  tools\leonida_tui.py:753, tools\wave_diff.py:373, runtime\test\check_sparse_queue_family.py:83

Green with it — runtime\test\check_sparse_queue_family.py:83 is gone from the list:

$ python -I tests/test_text_write_line_endings.py
FAILED (failures=1)
+ [] : text writes without newline= (CRLF on Windows, LF elsewhere): tools\leonida_tui.py:753, tools\wave_diff.py:373
Ran 3 tests in 21.133s

The two tools/ entries are not mine: main is red for them today and #7589 pins both. With those two lines applied on top of this branch, locally and uncommitted, the whole test passes:

$ python -I tests/test_text_write_line_endings.py
...
Ran 3 tests in 14.704s
OK

The flag changes the bytes it is there to change (CPython on Windows):

>>> p.write_text('a\nb\n', encoding='utf-8'); p.read_bytes()
b'a\r\nb\r\n'
>>> p.write_text('a\nb\n', encoding='utf-8', newline='\n'); p.read_bytes()
b'a\nb\n'

The touched script still runs and its test is green (python -I runtime/test/check_sparse_queue_family.py --help prints its usage; python -I tests/test_check_sparse_queue_family.py → 20 tests, OK). python -m compileall on both files and python -I scripts/check_no_game_data.py <both files> are clean.

Notes

  • SCAN names runtime rather than runtime/test so the C++ side's Python helpers are covered too; python_files() already skips __pycache__, build and dot-directories, and runtime/ is the only place the wider scan found a writer (it checks out already for runtime/test/shaders/build.py).
  • viewer/ has no writers today; naming it costs nothing and covers serve.py if it ever writes one.
  • tests/ stays out of the scan on purpose: those files write throwaway fixtures.
  • I did not touch tools/leonida_tui.py or tools/wave_diff.py; tools, workflows: reconfigure stdout error handling and pin text write newlines #7589 owns those two lines and I left them alone to avoid the conflict.

Depends on: #7589

No GPU needed; no game files.

AI-assisted.

…e's line ending

The `vk_layer_settings.txt` the test hands the Vulkan loader was written with `Path.write_text` and no `newline=`,
so the same run gave CRLF on Windows and LF on Linux and macOS. AGENTS.md asks every text writer to name its line
ending for that reason. `newline="\n"` makes it LF everywhere; the loader reads both.
…nly runtime/test/shaders

The guard only walked `runtime/test/shaders`, so the Python checks that write the loader's settings file, logs and
reports for the runtime tests were never scanned: `runtime/test/check_sparse_queue_family.py` could write a CRLF
settings file and this test stayed green. `SCAN` now covers the whole `runtime/` tree and `viewer/`; the one writer
the wider scan finds was pinned in the previous commit.
@morodirule

Copy link
Copy Markdown

Tested 401749c on Arch Linux, Python 3.14.10, CPU only: the widening itself is clean, but the suite is red through base drift. The widened runtime/+viewer scan adds zero new findings; the 1 failure names 2 pre-existing violations (leonida_tui.py:753 from #1797, wave_diff.py:373 from #3592), reproduced identically on current main with the old test. Negative control both directions: new test + base check_sparse_queue_family.py catches runtime/test/check_sparse_queue_family.py:83; base narrow test misses the runtime file. So the pin is correct and the scan gap is real — but this branch needs a rebase past #1797/#3592 to go green. No game files. AI-assisted.

@slint6614-dev

Copy link
Copy Markdown
Contributor

Checked on Linux: merged onto main dde82f2 (merges cleanly).

tests/test_text_write_line_endings.py still fails here, but main already fails with the same two hits: tools/leonida_tui.py:753 and tools/wave_diff.py:373. Neither comes from this PR; #7033 (leonida_tui) and #7188 (wave_diff) fix them and are still open.

  • Widening the scan to viewer/ and all of runtime/ adds no new hit beyond the one this PR fixes.
  • Negative control: with runtime/test/check_sparse_queue_family.py reverted, a third hit appears (check_sparse_queue_family.py:83), so the wider scan catches it.

So this change is fine; it goes green once #7033 and #7188 are in (Depends on: #7033, #7188).

@memorypressure

Copy link
Copy Markdown

Tested head 401749c merged onto main dde82f2 (tree a89235203). test_text_write_line_endings on the PR tree: Ran 3, FAILED (1) — and on a clean-main worktree the same Ran 3, FAILED (1) with the identical entry list [tools/leonida_tui.py:753, tools/wave_diff.py:373]; both are main-side known-reds, so your widened scan adds zero new entries on current main. The pin commit is non-vacuous: removing newline="\n" from check_sparse_queue_family.py:90 makes the widened scanner newly flag :83; restored md5-verified. The one-line pin is correct and the vk_layer_settings.txt CRLF bug on Windows is genuinely fixed. CI pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

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