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.
Refactor the code to also support windows. Closes #397
This is still a WIP. If anyone wants to finish this PR, feel free to leave a comment and take it over :)
I probably won't get much free time in the next weeks, but wanted to share the current status.
Implementation idea
The main tasks to support Windows are (1) to support the
spawnmethod and (2) to support timeouts properly (if possible).When directly using the
spawnmethod it is much slower, because we need to startup everything from scratch for each mutant. This includes the python interpreter (I think) and the whole pytest test collection (ie importing the system under test).To improve this performance, we only create
max_childrenprocesses as "workers". These workers infinitely loop on:As such we only need to setup a limited number of processes, instead of one per mutant. To support timeouts (where we likely still want to kill processes), we need to restart workers when they time out.
TODO
spawnmethod by passing all globals as args to the new processesImplementing timeouts
Previously we used
resourceto implement timeouts:mutmut/mutmut/__main__.py
Lines 1009 to 1011 in f63029b
And also a timeout checker thread (which I assume is only the backup in case
resourcedoes not work):mutmut/mutmut/__main__.py
Lines 864 to 878 in f63029b
Windows does not support
resourceso maybe we need to only useresourceon Linux and the timeout checker on Windows.Also, we now reuse processes. So when killing a long-running process we need to ensure that we restart that worker, and that we report it as timeouted. The restarting should already work with the current implementation. But it is not reported as a result. So we likely need to track which process starts which task and then in
_remove_stopped_workerswe need to map the killed processes to the tasks they were executing, and report them as timed out (depending on the exit code).Also note that I think mutmut reports the timeouted mutant as "killed" accidentally (I did not make a MRE yet, but it seems like it).
Debugging different results
I've tested it on https://github.com/TOD-theses/traces_parser with a
# pragma: no mutateon these lines (they would run into an infinite loop as we have no timeout yet): https://github.com/TOD-theses/traces_parser/blob/49d0b9cbc6fad490bba1f8a3136b24cd964336e1/traces_parser/parser/storage/memory.py#L35-L36The main branch of mutmut outputted slightly different results than this windows-support branch of mutmut. I am not yet sure if this is due to some kind of race condition, or if it is deterministic. Maybe adding some additional logs would be useful to debug this.