Answer product-owner round 2: 0 🔴, 1 🟡 (0 misread); run Stryker only where a package.json is above a file, and name the files with none in a Not mutated line
This commit is contained in:
@@ -149,9 +149,10 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
|
||||
def change_rust_php_and_typescript(self):
|
||||
"""Commit a Rust, a PHP and a TypeScript file, then change them: Rust's line 2 in the index, PHP's line 2 with a byte that is
|
||||
not UTF-8, and TypeScript's lines 1 and 4. Also change line 1 of a TypeScript file in web/, which holds a package.json."""
|
||||
not UTF-8, and TypeScript's lines 1 and 4. Also change line 1 of a TypeScript file in web/. The top and web/ each hold a package.json."""
|
||||
(self.checkout / "src").mkdir()
|
||||
(self.checkout / "web" / "src").mkdir(parents=True)
|
||||
(self.checkout / "package.json").write_text("{}\n")
|
||||
(self.checkout / "web" / "package.json").write_text("{}\n")
|
||||
(self.checkout / "web" / "src" / "app.ts").write_text("export const two = 2;\n")
|
||||
(self.checkout / "src" / "lib.rs").write_text("pub fn add(a: i32, b: i32) -> i32 {\n\ta + b\n}\n")
|
||||
@@ -329,7 +330,16 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
self.assertEqual(infection, f"\nvendor/bin/infection --git-diff-lines --git-diff-base={self.git('rev-parse', 'HEAD').strip()} --threads=3 --show-mutations=max --no-progress\n")
|
||||
self.assertEqual(stryker, "\nnpx --no stryker run --mutate src/calc.ts:1-1,src/calc.ts:4-4 --concurrency 3 --reporters clear-text\n")
|
||||
self.assertEqual(web, "/web\nnpx --no stryker run --mutate src/app.ts:1-1 --concurrency 3 --reporters clear-text\n")
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "pkg", "src", "web"])
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "package.json", "pkg", "src", "web"])
|
||||
|
||||
def test_a_javascript_file_with_no_package_json_above_it_is_named_and_not_mutated(self):
|
||||
(self.checkout / "presentation").mkdir()
|
||||
(self.checkout / "presentation" / "render.js").write_text("export const one = 1;\n")
|
||||
self.git("add", "presentation/render.js")
|
||||
ran = self.run_tool(*self.faked("passes"))
|
||||
skipped = "Not mutated, as no package.json is above them: presentation/render.js."
|
||||
self.assertEqual((ran.returncode, ran.stdout.splitlines()[:-1], ran.stderr), (0, [*PASSED, skipped, *NOT_MUTATED], ""))
|
||||
self.assertNotIn("npx", self.log.read_text())
|
||||
|
||||
def test_a_stryker_or_infection_run_that_exits_nonzero_fails_the_run(self):
|
||||
self.change_rust_php_and_typescript()
|
||||
@@ -376,7 +386,7 @@ class MutateChangesRuns(unittest.TestCase):
|
||||
ran = self.run_tool("--base", "HEAD", "--prefix", f"python3 {self.temp / 'fake_tools.py'} {self.log} 0", env={"CAUGHT_UNREADABLE": "1"})
|
||||
self.assertEqual(ran.returncode, 1)
|
||||
self.assertRegex(ran.stderr, rf"^could not hand cargo-mutants the diff or read its outcomes in {re.escape(str(self.checkout.resolve()))}/\.mutate-changes-\w+: ")
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "pkg", "src", "web"])
|
||||
self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "package.json", "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.
|
||||
|
||||
Reference in New Issue
Block a user