Repository navigation
[WIP] Run only the tests that reach the line a mutant changes - #672
Draft
MartinThoma wants to merge 2 commits into
Draft
MartinThoma wants to merge 2 commits into
MartinThoma wants to merge 2 commits into
Conversation
On Python 3.12 and later, the stats run records with sys.monitoring which lines of each mutated function every test runs, in the fork runner, the fork server and pytest-xdist workers. A mutant then gets only the tests of its function that run the statement it changes. A mutant on a line that no test runs is reported as "no tests" without starting a worker, and is run again once a new test reaches its line. A mutant still gets every test of its function on older Pythons, for a mutant in the signature, and when the function's source changed since its lines were recorded. On pypdf, the median mutant gets 20 tests instead of 57, and the test time of a surviving mutant falls by 42 %. On pagerange.py and _cmap.py, main and this change kill the same 980 mutants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No test calls Color.to_index with Color.BLUE, so on Python 3.12 and later no test reaches the line of its third return and the mutant gets "no tests" instead of surviving. Older Pythons have no sys.monitoring and keep the old verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
The description of this seems to be to do what mutmut already does. Is the issue that the current code that tries to only select tests that hit the code doesn't work? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is WIP - it seems to work for pypdf and brings down time significantly. Before AI, I would have opened an issue to discuss if this type of change is desired. With AI, it's easier to draft something that works / keep CI green and then discuss about it :-)
The idea of this change is to speed up mutmut run by executing just those parts of the test suite that have a chance of killing a mutant - preferably those first, that are fast.
The change
On Python 3.12 and later, the stats run records with sys.monitoring which lines of each mutated function every test runs, in the fork runner, the fork server and pytest-xdist workers. A mutant then gets only the tests of its function that run the statement it changes. A mutant on a line that no test runs is reported as "no tests" without starting a worker, and is run again once a new test reaches its line.
A mutant still gets every test of its function on older Pythons, for a mutant in the signature, and when the function's source changed since its lines were recorded.
On pypdf, the median mutant gets 20 tests instead of 57, and the test time of a surviving mutant falls by 42 %. On pagerange.py and _cmap.py, main and this change kill the same 980 mutants.