Repository navigation
test(cli): restore toolCfg after validator tests so shuffled runs pass - #2226
Merged
Merged
Conversation
Validator tests assigned toolCfg = Config{} without restoring it, leaving
a zeroed config (CoverageLookbackDays 0) that later tests relying on the
flag defaults inherited under -shuffle=on. Restore via the existing
saveGlobalVars helper in t.Cleanup.
Closes #2208
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Member
Author
Independent review verdict: CLEAN at 0db56a1Reviewer: fresh Claude agent (Sonnet, high effort), not the author. Coordinator: claude-cc-reviewer. What was checked:
Gate:
|
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.
Closes #2208
Summary
Four tests in
cmd/validators_test.goset the package-leveltoolCfg = Config{}and never restored it:TestValidateNumericRangesTestValidatePaymentAndTermTestValidateFilePathsTestValidateTargetCoverageThe CLI flags bind into
&toolCfg.*with defaults set at init. When one of these four ran first, tests that rely on those defaults failed with "coverage-lookback-days must be >= 1":TestValidateFlags*,TestFilterFlagValidationandTestFilterAndAdjustRecommendations_ZeroCoverage. That only happens in a shuffled order. The default declaration order happened to hide it.Each of the four tests now registers
t.Cleanup(saveGlobalVars().restore), reusing the existing helper incmd/multi_service_test_common_test.go. The change is test-only: 4 added lines.Evidence
All runs are local on macOS with
GOTOOLCHAIN=go1.26.9.1792159022300456000with-run 'Validate|Flag|Filter' -count=2failed about 57 tests.1792159305657431000on the full package failed the five default-dependent tests.go test ./cmd/ -shuffle=on -count=3and-count=5pass.-shuffle=101,202and303.toolCfgassignment in the test files. Every other one already restores, andsaveGlobalVarssnapshotsConfigby value.make build,go vet ./...andgo test -race ./cmd/...pass.scripts/test-git-secrets-allowlist.shpasses 44/44.🤖 Generated with Claude Code
Summary by CodeRabbit