Repository navigation
Run natively on Windows - #1
Merged
Merged
Conversation
Windows has no os.fork, so neither existing runner can work there. SpawnRunner starts a fresh Python process per mutant, hands it the mutant and its tests on stdin and reads the verdict from the exit code. It is the default on Windows; a config asking for fork or forkserver falls back to it with a warning, so a pyproject.toml shared with POSIX users keeps working. Timeouts are wall-clock only, as there is no RLIMIT_CPU. A worker that fails outside the tests exits 35 (suspicious) instead of Python's 1, which would count as a kill.
Remove the exit that sent Windows users to WSL. Mutant generation and coverage gathering relied on forked children inheriting state() and sys.path; under the spawn start method they are handed what they need. The my_lib segfault mutant is killed by a failing test on Windows, because ctypes turns the access violation into an OSError there. Refs boxed#397.
The default encoding there is the ANSI code page, which cannot encode the "ǁ" in mutant names, the spinner or the emoji. It went unnoticed locally because this machine runs with a UTF-8 code page; the Windows CI runner added in 92e1540 does not.
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.
mutmut refuses to start on Windows and points at WSL (boxed#397). This makes it run natively.
Approach
A third
MutantRunner,SpawnRunner, next to the fork and forkserver ones. It starts a fresh Python process per mutant (mutmut.workers.spawn_worker), hands it the mutant and its tests on stdin and reads the verdict from the exit code. One mutant per process, same as fork, so the verdicts are the same. A replacement worker is started as soon as a result comes in, so the pytest import is paid while it waits.process_isolation = "spawn"is the default on Windows.fork/forkserverin the config fall back to it with a warning there, so a pyproject.toml shared with POSIX users keeps working. On POSIX nothing changes unlessspawnis asked for.Mutant generation and coverage gathering relied on forked children inheriting
state()andsys.path... under the spawn start method they are handed what they need.Result
The whole test suite passes on Windows 11, Python 3.10, including the e2e projects with the same snapshots as on Linux. One difference: the my_lib segfault mutant is killed by a failing test, because ctypes turns the access violation into an OSError on Windows.
my_lib (111 mutants) runs at about 5 mutations/second here.
Outside the package
CI runs the test matrix on
windows-latesttoo, which doubles the test jobs. README and ARCHITECTURE no longer say POSIX only.Left out
.wtworktree here), pyrefly skips the files. Not Windows related, the same project passes elsewhere.