Kill mutate-changes' surviving mutants: test a deleted file, a mutmut results that cannot start, an interrupt's speed, and a process group already gone
This commit is contained in:
@@ -15,6 +15,7 @@ import unittest.mock
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from mutate_changes.test_mutate_changes import ended
|
||||
from test_env import isolated_env
|
||||
from mutate_changes import main
|
||||
from mutate_changes.in_diff_tools import run_cargo_mutants
|
||||
@@ -276,9 +277,8 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
launched.send_signal(signal.SIGTERM)
|
||||
self.assertEqual(launched.wait(timeout=30), 128 + signal.SIGTERM)
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "pkg"])
|
||||
sleeper = pathlib.Path(f"/proc/{started.read_text().strip()}/stat")
|
||||
for _ in range(200):
|
||||
if not sleeper.exists() or sleeper.read_text().split(") ")[1][0] == "Z":
|
||||
if ended(int(started.read_text())):
|
||||
break
|
||||
time.sleep(0.05)
|
||||
else:
|
||||
@@ -308,6 +308,14 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
ran = self.run_tool(env={"PATH": str(tools)})
|
||||
self.assertEqual((ran.returncode, ran.stdout.splitlines()[:2]), (0, PASSED), ran.stderr)
|
||||
|
||||
def test_a_mutmut_results_that_cannot_start_fails_the_run(self):
|
||||
tools = self.path_with_git()
|
||||
(tools / "mutmut").write_text(f'#!/bin/sh\n[ "$1" = run ] && {shutil.which("rm")} "$0"\nexec {sys.executable} {self.temp / "fake_mutmut.py"} {self.log} passes mutmut "$@"\n')
|
||||
(tools / "mutmut").chmod(0o755)
|
||||
ran = self.run_tool(env={"PATH": str(tools)})
|
||||
self.assertEqual(ran.returncode, 1)
|
||||
self.assertRegex(ran.stderr, "^mutmut results --all true could not start: ")
|
||||
|
||||
def test_rust_php_and_typescript_go_to_cargo_mutants_and_infection_at_the_top_and_to_stryker_by_package(self):
|
||||
self.change_rust_php_and_typescript()
|
||||
ran = self.run_tool("--base", "HEAD", "--jobs=3", "--prefix", f"python3 {self.temp / 'fake_tools.py'} {self.log} 0", cwd=self.checkout / "src")
|
||||
@@ -371,6 +379,10 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "pkg", "src", "web"])
|
||||
|
||||
def test_a_branch_that_adds_no_line_a_tool_mutates_says_so_and_names_what_it_changes(self):
|
||||
# A file the branch deletes is no longer there to mutate, so the report doesn't name it.
|
||||
(self.checkout / "pkg" / "old.md").write_text("Gone.\n")
|
||||
self.commit()
|
||||
(self.checkout / "pkg" / "old.md").unlink()
|
||||
ran = self.run_tool(*self.faked("passes"), "--base", "HEAD")
|
||||
self.assertEqual((ran.returncode, ran.stdout.splitlines()[:-1]), (0, ["No tool ran: the branch adds no line to a file that a tool mutates."]))
|
||||
(self.checkout / "README.md").write_text("Doubles.\n")
|
||||
|
||||
Reference in New Issue
Block a user