Skip to content

Fix wildcard mutant patterns selecting no tests for the clean run - #594

Open
Ishaan400 wants to merge 1 commit into
boxed:mainfrom
Ishaan400:fix-592-wildcard-clean-tests
Open

Ishaan400 wants to merge 1 commit into
boxed:mainfrom
Ishaan400:fix-592-wildcard-clean-tests

Conversation

@Ishaan400

Copy link
Copy Markdown

Problem

When running mutmut with a targeted pattern such as pkg.mod.x_f__mutmut_*, the "Running clean tests" step can run the entire test suite instead of only the relevant tests. This can make targeted runs unnecessarily slow.

Cause

The pattern includes the __mutmut_* mutant suffix, but the clean-test selection logic matches patterns against function-name keys without that suffix. This can result in an empty test selection, causing pytest to run the entire suite.

Fix

Match the pattern's function portion, before __mutmut_, against the function-name keys when selecting clean tests.

Selecting some additional relevant tests is safe for this sanity check: the goal is to verify that the relevant tests pass against the unmutated code. Running a few extra tests is preferable to selecting no tests and accidentally running the entire suite.

Tests

  • Added regression tests covering the wildcard pattern behavior. They fail without the fix and pass with it.
  • Full test suite: 457 passed, 4 skipped.
  • Ruff, Ruff format, and mypy checks pass.
  • End-to-end verification confirmed that an unrelated test_g ran once before the fix and zero times after it during a targeted run of f's mutants.

Fixes #592

A pattern such as pkg.mod.x_f__mutmut_* never matched the function-name
keys in tests_by_mangled_function_name, so the clean-test step got an
empty selection and ran the whole test suite. Match the pattern's
function part instead.

Fixes boxed#592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run with a name__mutmut_* pattern runs the whole test suite in the clean-test check

1 participant