refactor: extract config/output packages and return errors from Run#31
Merged
Conversation
Splits cmd/mutest into focused packages and replaces the int exit code return with idiomatic error returns. - Move output formatting + JSON helpers to output/ package - Move CLI config struct + Validate to config/ package - Add output.Reporter that encapsulates JSON/text and verbose dispatch so run() reads as a linear pipeline - Replace init() with lazy resolveVersion() (only called on -version) - Run/run return error; expose sentinels (ErrTestsFailed, ErrInvalidConfig, ErrDiscovery, ErrDiff, ErrInstrumentation, ErrBuild) so callers and tests can identify which stage failed via errors.Is - main.go prints err to stderr and exits 1 on any non-nil err
mutest's CI runs mutation testing per-package, so reporter mutants were not killed by the cmd/mutest integration tests. Add same-package coverage for each branch in Reporter. Also drop the redundant JSON+empty early return in DryRun: DryRunJSON encodes an empty slice as "[]" too, so the early return produced no observable difference and left a permanently-surviving mutant.
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
cmd/mutestinto focused packages:config/(Config struct + Validate) andoutput/(text + JSON formatters, RelPathCache, Reporter for mode dispatch).output.Reporterthat encapsulates text vs JSON and verbose vs not, sorun()reads as a linear pipeline instead of branching oncfg.JSON/cfg.DryRunat every step.init()with a lazyresolveVersion()that only runs on-version.Run/runreturn type fromintexit code toerror. Expose sentinels (ErrTestsFailed,ErrInvalidConfig,ErrDiscovery,ErrDiff,ErrInstrumentation,ErrBuild) so tests and callers can identify which pipeline stage failed viaerrors.Is.main.gosimply prints the error and exits 1.Test plan
go test ./... -racepassesgo vet ./...passesmutest -dry-runstill lists discovered points (text +-json)mutest -workers 0still printsmutest: invalid config: ...and exits 1mutest -threshold 90exits 1 when kill rate is below thresholdmutest -versionstill prints commit/build info fromdebug.ReadBuildInfoforgo installbuilds