mirror of
https://github.com/unclebob/mutator.git
synced 2026-11-26 18:58:50 +00:00
Do not count an unmutated worker build as a kill.
A worker that fails before any mutation was recording every mutant as killed. Run the tests once on the unmutated overlay and stop the way a failed baseline does. The tests also kill the mutants in the functions this change touches. Proved by a stand-in xcodebuild that fails only inside a worker, and by mutator on engine.py and workers.py: 140 killed, 0 survived, 0 uncovered. pytest: 139 passed, 1 skipped. Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
co-authored by
Robert C. Martin
parent
0cfa995431
commit
4fea247660
@@ -73,6 +73,44 @@ def test_delete_tree_unlinks_a_symlink_without_following_it(tmp_path):
|
||||
assert kept.read_text(encoding="utf-8") == "keep"
|
||||
|
||||
|
||||
def test_delete_tree_unlinks_a_symlink_that_vanishes(tmp_path, monkeypatch):
|
||||
real = tmp_path / "project"
|
||||
real.mkdir()
|
||||
kept = real / "important.txt"
|
||||
kept.write_text("keep", encoding="utf-8")
|
||||
link = tmp_path / "worker-link"
|
||||
link.symlink_to(real)
|
||||
original_unlink = Path.unlink
|
||||
|
||||
def unlink(self, *args, **kwargs):
|
||||
if self == link and link.is_symlink():
|
||||
original_unlink(self)
|
||||
return original_unlink(self, *args, **kwargs)
|
||||
|
||||
monkeypatch.setattr(Path, "unlink", unlink)
|
||||
delete_tree(link, attempts=1, sleep=lambda _: None)
|
||||
assert not link.exists()
|
||||
assert kept.read_text(encoding="utf-8") == "keep"
|
||||
|
||||
|
||||
def test_symlink_replaces_a_file_and_creates_a_missing_parent(tmp_path):
|
||||
from mutator.workers import symlink
|
||||
|
||||
target = tmp_path / "real.txt"
|
||||
target.write_text("keep", encoding="utf-8")
|
||||
link = tmp_path / "nested" / "link.txt"
|
||||
link.parent.mkdir()
|
||||
link.write_text("old", encoding="utf-8")
|
||||
symlink(link, target)
|
||||
other = tmp_path / "deep" / "child" / "link.txt"
|
||||
symlink(other, target)
|
||||
assert link.is_symlink()
|
||||
assert link.read_text(encoding="utf-8") == "keep"
|
||||
assert other.is_symlink()
|
||||
assert other.read_text(encoding="utf-8") == "keep"
|
||||
assert target.read_text(encoding="utf-8") == "keep"
|
||||
|
||||
|
||||
def test_delete_tree_reraises_after_the_attempts_are_exhausted(tmp_path, monkeypatch):
|
||||
tree = tmp_path / "worker"
|
||||
tree.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user