Repository navigation
ub check: run each mutant's importing tests first, full suite only for survivors; hide mutant-count warning - #16
Merged
Merged
Conversation
…cus for uncovered files
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ub checkran the whole test suite for every mutant. Now each Python mutant first runs the test modules that import its module. Only a mutant those tests leave alive reruns the full suite. The per-fileWARNING: N covered mutations selectedline now prints only with--verbose.Before / after
All runs on the same 10-core Mac,
rm -rf .metrics targetfirst,TEST='uv run -q --no-project --python 3.11 --with-editable . python -m unittest discover -s tests -q'.ub checkon main'ssrcub checkon main'ssrcsrc(the done-criteria command)Running the branch on main's
srcgives the same 273 killed and 0 survived as main. On its ownsrcthe count rises to 314 only because the self-gate also mutates the code this PR adds tocheck.py.Approaches weighed
{file}/{module}placeholder in--test-command. Rejected. Every user would have to rewrite their command, and the done-criteria command has no placeholder.uv run ... python -c passtakes 0.09 s, against a 4.5–9 s suite. The cost is in the tests, not the startup.How focus works (
src/ub_cli/check.py)python_importsparses every project.pyfile withast(all import statements, including ones inside functions). It skipsSKIP_LINKdirectories, dot directories andnode_modules.affected_testswalks that graph out from the mutated module and groups thetest*.pyimporters by import distance._focuserbuilds one command per test module: the user's command plus-f -k '*test_x.*'. It runs each command once on the original code and drops any that fail. It orders them nearest distance first, thentest_<stem>, then fastest baseline.FocusedRunnerruns a mutant through those commands. The first failure or timeout kills the mutant. If every focused command passes, the full command runs. Baseline runs (no timeout) bypass focus.unittest discoverwith no shell operators, no comment and no short flag containingk. Such a flag would OR its pattern with ours and widen the user's selection. Any other command (make test, pytest,python -c ...) behaves exactly as before.signature.pymutants hang and hold a ~45 s tail, which is most of the remaining time.Limit of "equals the full-suite result": a focused failure is a kill without a full run. A test that passes in the full suite but fails when run alone under the mutant (an order-dependent test) could turn a full-suite survivor into a kill. The baseline check catches order-dependence on the original code only.
Tests (
tests/test_check.py::FocusTests)node_modulestrees are excluded.-k,-kslow,-qk, quoted-k,# comment,2>&1,&&, pytest, unbalanced quote.FocusedRunnerstops at the first failing focus and skips focus for baselines.importlib(so it is not selected) is still reported killed, after[focused, full]runs.--verbose.make test: OK. The gate's own mutation run overcheck.pykills every mutant of the new code (0 survived above).Not covered
import_moduleor a subprocess are not followed. They cost a full rerun, never a wrong verdict.-kthat matches nothing exits 0, which wastes a run but cannot change a verdict.