From e25dd3c531b7d9ccc3660ad0ad7902cff11a1fbd Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sat, 21 Nov 2026 00:19:24 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread);=20pin=20diff.?= =?UTF-8?q?interHunkContext=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mutate_changes/in_diff_tools.py | 5 +++-- bin/mutate_changes/main.py | 2 +- bin/mutate_changes/test_mutate_changes.py | 10 +++++----- bin/mutate_changes/test_mutate_changes_runs.py | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bin/mutate_changes/in_diff_tools.py b/bin/mutate_changes/in_diff_tools.py index 04b4299e..010b22ee 100644 --- a/bin/mutate_changes/in_diff_tools.py +++ b/bin/mutate_changes/in_diff_tools.py @@ -14,8 +14,9 @@ CARGO_FINISHED = frozenset({0, 2, 3}) CARGO_OUTCOMES = ("caught", "missed", "timeout", "unviable") GREMLINS_UNKILLED = frozenset({"LIVED", "NOT COVERED"}) # What Gremlins v0.6.0 needs of the diff it reads from git: one run of lines per hunk is all it mutates, so a hunk holds the changed -# lines and none around them; it takes each file's path after a b/; and it reads no colour codes. A user's git settings change each. -GREMLINS_GIT_SETTINGS = {"diff.context": "0", "diff.noprefix": "false", "diff.mnemonicPrefix": "false", "diff.srcPrefix": "a/", "diff.dstPrefix": "b/", "color.diff": "never"} +# lines and none around them, nor a neighbouring change; it takes each file's path after a b/; and it reads no colour codes. A user's git +# settings change each. +GREMLINS_GIT_SETTINGS = {"diff.context": "0", "diff.noprefix": "false", "diff.mnemonicPrefix": "false", "diff.srcPrefix": "a/", "diff.dstPrefix": "b/", "color.diff": "never", "diff.interHunkContext": "0"} def run_cargo_mutants(top: str, base: str, paths: list[str], run: Run, git: Git, jobs: int) -> list[str] | Failure: diff --git a/bin/mutate_changes/main.py b/bin/mutate_changes/main.py index 145cc666..2733a1d4 100644 --- a/bin/mutate_changes/main.py +++ b/bin/mutate_changes/main.py @@ -18,7 +18,7 @@ or __tests__/ folder. becomes one line for its folder, naming the error and telling you to mutate that folder's changed lines by hand. - .go: Gremlins, as `gremlins unleash --diff`, in the checkout's top, where its go.mod must be. Gremlins reads the diff from git, so the run adds settings to the GIT_CONFIG_* variables, after any the environment holds: no context lines, since Gremlins mutates - every line of a hunk; a/ and b/ as the file prefixes; and no colour. + every line of a hunk, so one hunk per change; a/ and b/ as the file prefixes; and no colour. - .rs: cargo-mutants, as `cargo mutants --in-diff`, in the checkout's top. - .cjs, .cts, .js, .jsx, .mjs, .mts, .ts, .tsx: Stryker, as `npx --no --package=@stryker-mutator/core stryker run --mutate` on the changed lines, in the nearest folder above the file that holds a package.json. A file with no package.json above it isn't diff --git a/bin/mutate_changes/test_mutate_changes.py b/bin/mutate_changes/test_mutate_changes.py index 086dd7bf..3ab5dcdf 100644 --- a/bin/mutate_changes/test_mutate_changes.py +++ b/bin/mutate_changes/test_mutate_changes.py @@ -151,16 +151,16 @@ class InDiffTools(unittest.TestCase): def test_the_git_settings_gremlins_needs_are_added_after_the_ones_the_environment_holds(self): held = {"HOME": "/h", "GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "safe.directory", "GIT_CONFIG_VALUE_0": "*"} env = with_plain_git_diff(held) - self.assertEqual(env["GIT_CONFIG_COUNT"], "7") - self.assertEqual({name: value for name, value in env.items() if name in held}, held | {"GIT_CONFIG_COUNT": "7"}) - settings = [(env[f"GIT_CONFIG_KEY_{index}"], env[f"GIT_CONFIG_VALUE_{index}"]) for index in range(1, 7)] - self.assertEqual(settings, [("diff.context", "0"), ("diff.noprefix", "false"), ("diff.mnemonicPrefix", "false"), ("diff.srcPrefix", "a/"), ("diff.dstPrefix", "b/"), ("color.diff", "never")]) + self.assertEqual(env["GIT_CONFIG_COUNT"], "8") + self.assertEqual({name: value for name, value in env.items() if name in held}, held | {"GIT_CONFIG_COUNT": "8"}) + settings = [(env[f"GIT_CONFIG_KEY_{index}"], env[f"GIT_CONFIG_VALUE_{index}"]) for index in range(1, 8)] + self.assertEqual(settings, [("diff.context", "0"), ("diff.noprefix", "false"), ("diff.mnemonicPrefix", "false"), ("diff.srcPrefix", "a/"), ("diff.dstPrefix", "b/"), ("color.diff", "never"), ("diff.interHunkContext", "0")]) def test_the_git_settings_start_at_the_first_for_an_environment_without_a_count_or_with_one_that_is_not_a_number(self): for held in ({}, {"GIT_CONFIG_COUNT": "many"}, {"GIT_CONFIG_COUNT": ""}): with self.subTest(held): env = with_plain_git_diff(held) - self.assertEqual((env["GIT_CONFIG_COUNT"], env["GIT_CONFIG_KEY_0"], env["GIT_CONFIG_KEY_5"], "GIT_CONFIG_KEY_6" in env), ("6", "diff.context", "color.diff", False)) + self.assertEqual((env["GIT_CONFIG_COUNT"], env["GIT_CONFIG_KEY_0"], env["GIT_CONFIG_KEY_6"], "GIT_CONFIG_KEY_7" in env), ("7", "diff.context", "diff.interHunkContext", False)) class MutmutSetup(unittest.TestCase): diff --git a/bin/mutate_changes/test_mutate_changes_runs.py b/bin/mutate_changes/test_mutate_changes_runs.py index b6201cd6..6e224d01 100644 --- a/bin/mutate_changes/test_mutate_changes_runs.py +++ b/bin/mutate_changes/test_mutate_changes_runs.py @@ -433,9 +433,9 @@ class MutateChangesRuns(unittest.TestCase): self.assertEqual(folder, str(self.checkout.resolve())) base = self.git("rev-parse", "HEAD").strip() self.assertRegex(command, rf"^gremlins unleash --diff {base} --output (\.mutate-changes-\w+)/report\.json --workers 3$") - keys = ["diff.context", "diff.noprefix", "diff.mnemonicPrefix", "diff.srcPrefix", "diff.dstPrefix", "color.diff"] - values = ["0", "false", "false", "a/", "b/", "never"] - self.assertEqual(config, "GIT_CONFIG_COUNT=6\n" + "".join(f"GIT_CONFIG_KEY_{n}={key}\n" for n, key in enumerate(keys)) + "".join(f"GIT_CONFIG_VALUE_{n}={value}\n" for n, value in enumerate(values))) + keys = ["diff.context", "diff.noprefix", "diff.mnemonicPrefix", "diff.srcPrefix", "diff.dstPrefix", "color.diff", "diff.interHunkContext"] + values = ["0", "false", "false", "a/", "b/", "never", "0"] + self.assertEqual(config, "GIT_CONFIG_COUNT=7\n" + "".join(f"GIT_CONFIG_KEY_{n}={key}\n" for n, key in enumerate(keys)) + "".join(f"GIT_CONFIG_VALUE_{n}={value}\n" for n, value in enumerate(values))) self.assertEqual(sorted(path.name for path in self.checkout.iterdir()), [".git", "README.md", "calc.go", "calc_test.go", "pkg"]) def test_a_gremlins_run_that_finds_no_mutant_reports_none(self):