Repository navigation
test(cli): never start the background update check in package tests - #5
Merged
Merged
Conversation
The macOS race job on main (bc1c1ee) failed TestDoctorOutdatedFailsOnlyWhenALookupCouldNotRun with "race detected during execution of test". Every command runs the root PersistentPreRun, whose update check starts a goroutine that calls the real release origin, writes under HOME and reads version.Version after the command returns; a later test that set version.Version raced with it. TestMain now turns the check off, and a test proves no command reaches the release origin during package tests (it failed before this change). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
The macOS race job on main (
bc1c1ee) failedTestDoctorOutdatedFailsOnlyWhenALookupCouldNotRunwithrace detected during execution of test. The race report pointed atupdate_check.go:31(read ofversion.Versionin the background update check goroutine) againstdoctor_outdated_test.go:281(a test settingversion.Version).Cause
Every command runs the root
PersistentPreRun, which startscheckForUpdateAsync. Since the public release origin became the default, that goroutine calls the real origin during package tests, writes the check file under HOME, and outlives the command. A later test that changesversion.Versionraces with it.Fix
updateCheckEnabled(defaulttrue) gates the background check; the packageTestMainsets it tofalse. Production behavior is unchanged.TestPackageTestsNeverStartTheBackgroundUpdateCheckruns the rootPersistentPreRunagainst a counting server and fails if the release origin is called. It failed before the fix.Checks
gofmt -l .(empty),go vet ./...,go test -count=1 ./...pass.go test -race -count=1 ./internal/clipasses with no race report.🤖 Generated with Claude Code