feat: add --list and --dry-run flags to gomu run - #91
Merged
Merged
Conversation
Add a -l/--list flag to the run command that prints the catalog of supported mutators with one-line descriptions and exits, without discovering files or running any mutation. To back the catalog, the Mutator interface gains a Description() method (implemented by every mutator) and an exported SupportedMutators() accessor that returns the registry without constructing an analyzer. pkg/gomu re-exports this as MutatorInfo/SupportedMutators so the CLI depends only on the public API.
Add a --dry-run flag to the run command that runs the real file-selection and mutant-generation pipeline and prints which mutations would run per file, but executes nothing: no overlay build, no go test, no report, and no CI gate. Dry run reuses the existing incremental file selection, so it reflects exactly what a real run would process; pass --incremental=false to dry-run every file.
sivchari
reviewed
Jul 1, 2026
|
|
||
| // writeDryRunFile renders a file's discovered mutants as an aligned table. | ||
| func writeDryRunFile(w io.Writer, file string, mutants []mutation.Mutant) { | ||
| fmt.Fprintf(w, "\n%s (%d mutants)\n", file, len(mutants)) |
Owner
There was a problem hiding this comment.
It's better to print relative path, not absolute path.
Contributor
Author
There was a problem hiding this comment.
I chose working-directory relative paths. The issue fixed in e8a660c
Discovered files are absolute (derived from the resolved target path); display them relative to the working directory via analysis.GetRelativePath, addressing PR review feedback.
4 tasks
sivchari
added a commit
that referenced
this pull request
Jul 10, 2026
Propagate the tabwriter Flush error in writeDryRunFile instead of suppressing it with nolint, hint that --dry-run's empty result may be due to the incremental filter, and warn on stderr when --list is combined with flags that it silently ignores.
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.
Summary
Adds two discovery-only flags to
gomu run, implementing #90. Both stop short of the execution phase, so they are fast and side-effect-free.-l, --listPrints the catalog of supported mutators with one-line descriptions and exits — no path, no AST walk, no mutation.
--dry-runRuns the real file-selection and mutant-generation pipeline and prints which mutations would run per file, but executes nothing (no overlay build, no
go test, no report, no CI gate). It honors--incremental, so it reflects exactly what a real run would process;--incremental=falsepreviews every file.Implementation
Respects the existing
cmd/gomu → pkg/gomu → internal/mutationlayering.Description()to theMutatorinterface (implemented by every mutator) and an exportedSupportedMutators()that returns the registry without constructing an analyzer. No new mutator structs, soregistry.goand its generator are untouched (go generateis a no-op).MutatorInfo+SupportedMutators(); adds aDryRunoption;Run()branches to anio.Writer-based dry-run formatter right after file discovery, before any execution or reporting.--list/-land--dry-runon the run command;--listis handled first vialistMutatorsusingtext/tabwriterfor alignment.Tests
Name()/Description()SupportedMutators()mapping, and an end-to-endRun(DryRun)test asserting no report or history file is producedlistMutatorsoutputVerification
go build ./...,go vet ./...,go test ./...pass;go generate ./internal/mutationleavesregistry.gounchanged.