Repository navigation
Remove deleted test files from mutants/ - #636
Open
nafiurahman00 wants to merge 1 commit into
Open
nafiurahman00 wants to merge 1 commit into
nafiurahman00 wants to merge 1 commit into
Conversation
copy_also_copy_files() uses copytree(dirs_exist_ok=True), which never deletes anything. If you delete a test file, its copy stays in mutants/tests/ and pytest keeps running it, so the mutants it killed still show up as killed. After copying a directory, remove the files in the mutants/ copy that no longer exist in the project. __pycache__ is left alone, and directories that overlap the source paths are skipped.
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.
copy_also_copy_files()copiestests/intomutants/withshutil.copytree(..., dirs_exist_ok=True), which only adds and overwrites files. If you delete a test file, its copy stays inmutants/tests/, pytest keeps collecting it, and the mutants it used to kill are still reported as killed until yourm -rf mutants.To reproduce:
On main both mutants are still
killedandmutants/tests/test_strong.pyis still there. With this change they'resurvivedand the file is gone.The fix removes files (and directories) from the
mutants/copy that no longer exist in the project, right after the copy.__pycache__is left alone since Python ignores a cached.pycwithout its source, and clearing it every run would just make pytest recompile. If analso_copydirectory overlaps a source path it's skipped, becausemutants/has mutmut's generated files there.Added
tests/utils/test_file_utils.py. The two deletion tests fail on main and pass with the fix.uv run pytestpasses (482 passed, 4 skipped), and so doespre-commit run --all-files.This is related to #626: once a test change triggers a re-run, the deleted test also needs to actually stop running.