tests: cover tools/stale_build.py (TEST-STALE-BUILD) #611

Merged
TuroYT merged 1 commit from upstream-pr/611 into main 2026-11-24 12:44:53 +00:00
TuroYT commented 2026-11-24 09:54:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TuroYT on 2026-11-24T09:54:06Z.


Claimed in the coordination issue as: TEST-STALE-BUILD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127995316)

tools/stale_build.py is imported by make_game.py (vk_pipeline_check) and tools/first_light.py (vk_harness) to decide whether a built runtime/test program is stale, but no test referenced it.

This adds tests/test_stale_build.py, a standard-library unittest that builds small source trees in a temporary folder and sets mtimes explicitly. It covers:

  • program_sources follows "..." includes, resolves "../src/x.h" relative to the including file, skips a missing header and a directory named like an include.
  • newer_sources reports only the sources newer than the exe; a fresh exe, a missing exe and a program with no source give [].
  • empty source file, include cycle (terminates, each file once), same header included twice (listed once, also via a different spelling), commented-out include (not followed).
  • exe mtime equal to a source mtime is not stale (pins the ">" comparison); one second older is stale.

Not covered: include directories other than the including file's folder (see the note below), Windows path separators, the caller side in make_game.py and first_light.py.

Note for the maintainers, not changed here: program_sources only resolves a quoted include relative to the including file. 76 of the 665 quoted includes in runtime/test/*.cpp are bare names resolved through the target include directories (for example runtime/test/pe_loader_test.cpp line 25, #include "pe_loader.h"; the header is runtime/src/pe_loader.h). program_sources(".", "pe_loader_test") returns only runtime/test/pe_loader_test.cpp, so an edit to runtime/src/pe_loader.h does not mark that program stale. This needs its own claim.

Tested:

  • python3 -m compileall -q tests: clean
  • python3 -I tests/test_stale_build.py: Ran 15 tests, OK
  • Mutation check on scratch copies of tools/stale_build.py: newer_sources always [] gives 4 failures; ">=" instead of ">" gives 1 failure (the equal-mtime case).
  • python3 -I tests/test_text_write_line_endings.py: Ran 3 tests, OK
  • python3 -I scripts/check_no_game_data.py tests/test_stale_build.py: rc=0

Not tested: Windows (path separators, os.utime behaviour on FAT or network drives), macOS case-insensitive volumes (not relevant to these inputs).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5469895309 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/611). Originally posted by [TuroYT](https://github.com/TuroYT) on 2026-11-24T09:54:06Z. --- Claimed in the coordination issue as: TEST-STALE-BUILD (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127995316) tools/stale_build.py is imported by make_game.py (vk_pipeline_check) and tools/first_light.py (vk_harness) to decide whether a built runtime/test program is stale, but no test referenced it. This adds tests/test_stale_build.py, a standard-library unittest that builds small source trees in a temporary folder and sets mtimes explicitly. It covers: - program_sources follows "..." includes, resolves "../src/x.h" relative to the including file, skips a missing header and a directory named like an include. - newer_sources reports only the sources newer than the exe; a fresh exe, a missing exe and a program with no source give []. - empty source file, include cycle (terminates, each file once), same header included twice (listed once, also via a different spelling), commented-out include (not followed). - exe mtime equal to a source mtime is not stale (pins the ">" comparison); one second older is stale. Not covered: include directories other than the including file's folder (see the note below), Windows path separators, the caller side in make_game.py and first_light.py. Note for the maintainers, not changed here: program_sources only resolves a quoted include relative to the including file. 76 of the 665 quoted includes in runtime/test/*.cpp are bare names resolved through the target include directories (for example runtime/test/pe_loader_test.cpp line 25, `#include "pe_loader.h"`; the header is runtime/src/pe_loader.h). program_sources(".", "pe_loader_test") returns only runtime/test/pe_loader_test.cpp, so an edit to runtime/src/pe_loader.h does not mark that program stale. This needs its own claim. Tested: - python3 -m compileall -q tests: clean - python3 -I tests/test_stale_build.py: Ran 15 tests, OK - Mutation check on scratch copies of tools/stale_build.py: newer_sources always [] gives 4 failures; ">=" instead of ">" gives 1 failure (the equal-mtime case). - python3 -I tests/test_text_write_line_endings.py: Ran 3 tests, OK - python3 -I scripts/check_no_game_data.py tests/test_stale_build.py: rc=0 Not tested: Windows (path separators, os.utime behaviour on FAT or network drives), macOS case-insensitive volumes (not relevant to these inputs). AI-assisted (Claude Code).
madvillain91 commented 2026-11-24 10:51:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-24T10:51:24Z.

Review: COMMENTED


Independent Windows 11 26H2 (26300.9711) check at e8a4ae043 against main 21625bca8, using CPython 3.12.3 and Git for Windows 2.56.0.windows.2. All 15 test_stale_build.py tests passed (0.133s), confirming Windows path separators and os.utime behavior. Clean coverage of cycles, duplicate includes, and the > mtime boundary. LGTM.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6037881352 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/611#pullrequestreview-6037881352). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-24T10:51:24Z. **Review:** COMMENTED --- Independent Windows 11 26H2 (26300.9711) check at e8a4ae043 against main 21625bca8, using CPython 3.12.3 and Git for Windows 2.56.0.windows.2. All 15 `test_stale_build.py` tests passed (0.133s), confirming Windows path separators and `os.utime` behavior. Clean coverage of cycles, duplicate includes, and the `>` mtime boundary. LGTM.
madvillain91 commented 2026-11-25 12:12:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madvillain91 on 2026-11-25T12:12:37Z.


madvillain8099

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7162065274 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/611#issuecomment-7162065274). Originally posted by [madvillain91](https://github.com/madvillain91) on 2026-11-25T12:12:37Z. --- madvillain8099
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!611
No description provided.