test(tokenstore): pin the warn-writer default by descriptor, not pointer · Entire
test(tokenstore): pin the warn-writer default by descriptor, not pointer
ddbb603·
peyton-alt·yesterday·1 file·+10 added/-2 removed
Under 'go test -json' (Go 1.26, what gotestsum runs) the testing package replaces the os.Stderr variable after package init to attribute output to tests, so the init-captured default no longer compares equal to os.Stderr even though it is the process's real stderr. Compare the underlying descriptor instead; io.Discard or a buffer still fails the check.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Sessions
01KXM1GDMRDQEBV5RVPVKA99QBView transcript
[?
Fix Onboarding History and Scan Cache IssuesClaude Code·Fable 5·1 step](/content/gh/entireio/cli/session/4c8ea8be-3447-426e-b8cb-07f2c8a04b71#timeline-01KXM1GDMRDQEBV5RVPVKA99QB/index.html)
Changes
1
internal/entireclient/tokenstore
- Mfile_test.go+10/-2
5 unmodified lines
6
7
8
9
10
11
12
392 unmodified lines
405
406
407
408
409
410
411
412
413
414
408
409
415
416
417
418
419
5 unmodified lines
"path/filepath"
"runtime"
"strings"
"syscall"
"testing"
)
392 unmodified lines
// changing the default to io.Discard would silently delete the feature in
// production while the whole suite stays green (verified by mutation).
// Not parallel: reads the package-global writer that other tests swap.
//
// Pinned by descriptor rather than pointer equality with os.Stderr: under
// `go test -json` (Go 1.26) the testing package replaces the os.Stderr
// variable after package init to attribute output to tests, so the default
// captured at init no longer compares equal even though it is the process's
// real stderr. io.Discard or a buffer still fails this (not an *os.File).
func TestLoosePermsWarnWriter_DefaultsToStderr(t *testing.T) {
if loosePermsWarnW != os.Stderr {
t.Fatalf("loosePermsWarnW default = %T, want os.Stderr", loosePermsWarnW)
}
f, ok := loosePermsWarnW.(*os.File)
if !ok || f.Fd() != uintptr(syscall.Stderr) {
t.Fatalf("loosePermsWarnW default = %T, want the process stderr", loosePermsWarnW)
}
}
Minternal/entireclient/tokenstore/file_test.go+10/-2