mirror of
https://github.com/unclebob/dryer.git
synced 2026-11-26 18:58:51 +00:00
Cover the mutation sites the report left uncovered.
A file outside the project root is not source. That branch returned false with no test, so the mutant was uncovered. check=False now sits on the git call coverage records, and a failing git is still reported as GitStatusError. Proved by test_a_file_outside_the_project_root_is_not_source. mutator on cli.py killed 64 of 64, with nothing survived and nothing uncovered. Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
co-authored by
Robert C. Martin
parent
bc42b347c5
commit
4cef42357f
+2
-6
@@ -178,12 +178,8 @@ class GitStatusError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def _git(root: Path, *args: str) -> bytes:
|
def _git(root: Path, *args: str) -> bytes:
|
||||||
result = subprocess.run(
|
command = ["git", "-C", os.fspath(root), *args]
|
||||||
["git", "-C", os.fspath(root), *args],
|
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
check=False,
|
|
||||||
)
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
message = os.fsdecode(result.stderr).strip() or "git status failed"
|
message = os.fsdecode(result.stderr).strip() or "git status failed"
|
||||||
raise GitStatusError(result.returncode, message)
|
raise GitStatusError(result.returncode, message)
|
||||||
|
|||||||
@@ -332,6 +332,14 @@ def test_changed_source_skips_unknown_and_test_files(tmp_path):
|
|||||||
assert _tracked_source(tmp_path / "target" / "app.py") is False
|
assert _tracked_source(tmp_path / "target" / "app.py") is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_a_file_outside_the_project_root_is_not_source(tmp_path):
|
||||||
|
outside = tmp_path / "outside.py"
|
||||||
|
outside.write_text("x = 1\n", encoding="utf-8")
|
||||||
|
root = tmp_path / "project"
|
||||||
|
root.mkdir()
|
||||||
|
assert _tracked_source(outside, root) is False
|
||||||
|
|
||||||
|
|
||||||
def test_test_files_and_skipped_directories_are_left_out(tmp_path):
|
def test_test_files_and_skipped_directories_are_left_out(tmp_path):
|
||||||
write_source(tmp_path, "src/app.py", "x = 1\n")
|
write_source(tmp_path, "src/app.py", "x = 1\n")
|
||||||
write_source(tmp_path, "src/foo_test.py", "x = 1\n")
|
write_source(tmp_path, "src/foo_test.py", "x = 1\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user