mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1516] tests: test_mutations copies tools/ once and runs only the test each mutation must break (TEST-MUTATIONS-COST) #1547
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1547
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1516
Author: @milk4sale
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:tests/mutations-one-copy📝 Commits (1)
a94c7e0tests: test_mutations copies tools/ once and runs only the test each mutation must break (TEST-MUTATIONS-COST)📊 Changes
1 file changed (+26 additions, -12 deletions)
View changed files
📝
tests/semantic/test_mutations.py(+26 -12)📄 Description
Claimed in the coordination issue as: TEST-MUTATIONS-COST (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7150964147)
What and why
tests/semantic/test_mutations.pywas the last file still running in all 23semantic-tests (windows-latest)runs measured for #1462, and in the 14 of them that were cancelled at the 10-minute limit it was the only file still running. For each of its 14 runs oftest_ps_semantics.py(the baseline and 13 mutations) it copiedtools/(332 files, 8.6 MB) into a new temporary folder, deleted it afterwards, and ran the whole file.Now
test_each_mutation_is_caughtmakes one copy for all 13 mutations. Each mutation starts from the original translator and writes it back in afinally, so withtest_baseline_copy_passes's own copy, 14 copies oftools/become 2: about 660 files written and deleted instead of about 4,650. Each mutation runs only the test it must break,test_ps_semantics.TranslatorSemantics.<test>, so the 13 mutation runs translate 13 shaders instead of 78.failed_testsnow counts only failures reported forTranslatorSemantics. A test name the class does not have fails too, asERROR: test_x (unittest.loader._FailedTest.test_x), so with one test per run the old pattern would have counted a misspelled expected test as caught (checked below).What the file checks stays the same: the whole of
test_ps_semantics.pypasses on an unmutated copy, each anchor must match exactly once, each mutation must make its test fail,test_anchors_match_crlf_translator_copiesis untouched, and the repository's owntools/is never written. The children keepPYTHONDONTWRITEBYTECODE=1. Now that the translator is rewritten in place, that also stops a.pycof one mutant being run for a later mutant of the same size written in the same second. A comment says so.Why I expect it to help on Windows (a hypothesis, not measured there)
Per-file times of the two legs of the same run, from the job logs of the 9 runs in #1462's table that ran to their end (the
Ran N tests in X sof each file):test_mutationsWindowsThe rest of the suite took 0.76-1.61 times as long on Windows as on Linux;
test_mutationstook 5.8-11.1 times as long. Most of what its children do is the same CPU work the other files do (compiling and running the translator), so I expect most of the difference to come from what only this file does: writing and deleting about 330 files 14 times, and starting 14 Python processes that each import the translator from a folder created just before. This change removes 12 of the 14 copies. It keeps the 14 processes and their 14 compiles of the 1.1 MB translator, which are the main cost on Linux. Only a Windows run can confirm it. The Windows leg runs on the first push tomainafter this merges; GitHub blocked my fork's Actions on 25 November, so I could not dispatch one.Tested
On Linux (Ryzen 9 7900X, 24 threads, Python 3.14.10; CI uses 3.12), with
mainatf78385646and this change on top of it, each exported to its own folder, alternating between the two in every round:mainrun_semantic_tests.py tests/semantic -p test_mutations.py, median of 8 (load average 6-12)test_each_mutation_is_caught(unittest --durations), median of 6test_anchors_match_crlf_translator_copies(unchanged)test_baseline_copy_passes(unchanged)The gain on Linux is small: copying
tools/takes about 16 ms here, and a child spends about 0.19 s of its 0.25 s import compilingrdna2spirv.py(-X importtime). Most of the time the file still takes goes into 27 compiles of the translator, 14 in the children and 13 in the CRLF test.sext()) changed, run against this branch's file andmain's: a misspelled expected test (test_ps_sdwz), a real test that mutation does not break (test_ps_ops), a replacement that changes nothing, and an anchor that no longer matches. Every one fails on both, with only that subtest failing and the other 12 mutations passing. With the oldfailed_testspattern put back, the misspelled name passes on this branch; that is why the pattern now names the class.test_each_mutation_is_caught. Each of the 13 children saw the original translator with only its own mutation applied (13 different texts), and the copy's translator was byte-identical totools/rdna2spirv.pybefore each mutation and at the end.python -I scripts/run_semantic_tests.py tests/semanticon this branch (onmainatb07b9ecb0): 487 files, 6,279 tests, 0 files failed in 69 s with 24 jobs.python -I scripts/check_no_game_data.py tests/semantic/test_mutations.py: clean.python -I tests/test_text_write_line_endings.py: passes.GPUs tested: n/a (one test file)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase). No open pull request changestests/semantic/test_mutations.py.docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.