cli.Entry() set time.Local to UTC and ended with memguard.Purge(), and TestEntryWipesBuffersAndReturnsExitCode ran it in the same process as every other test in internal/cli. A timer an earlier test left running, such as the 10-second time.After ones in confirm_test.go, could read time.Local as it changed, which the race detector reported on some runs. The purge could destroy a memguard buffer still in use, the likeliest cause of the crash seen on another run.
main() in cmd/secret now sets time.Local before it calls cli.Entry(). memguard starts its goroutines only when first used, so no goroutine of secret is running yet. The test from #169 runs the built binary with TZ=America/New_York, so it still covers this.
The Entry test runs cli.Entry() in a copy of the test binary started with SECRET_TEST_RUN_ENTRY set. That copy acts in an init function, not in a test, because TestMain would otherwise build the secret binary again and remove it while the other tests run it.
Disclosures:
Deviation: cmd/secret/main.go now does one thing besides calling cli.Entry(), which AGENTS.md Go guideline 7 says it should only do. Policy 6 ("Set the local timezone to UTC on startup") and the plan on the issue put the time zone there.
Rule suppressed: gochecknoinits on the test's init function, with a reason, as the repo's two other init functions do.
Unverified: that the purge is what crashed the test process. The change takes the purge out of that process either way.
Model: opus-5-5
`cli.Entry()` set `time.Local` to UTC and ended with `memguard.Purge()`, and `TestEntryWipesBuffersAndReturnsExitCode` ran it in the same process as every other test in `internal/cli`. A timer an earlier test left running, such as the 10-second `time.After` ones in `confirm_test.go`, could read `time.Local` as it changed, which the race detector reported on some runs. The purge could destroy a memguard buffer still in use, the likeliest cause of the crash seen on another run.
- `main()` in `cmd/secret` now sets `time.Local` before it calls `cli.Entry()`. memguard starts its goroutines only when first used, so no goroutine of `secret` is running yet. The test from https://git.eeqj.de/sneak/secret/issues/169 runs the built binary with `TZ=America/New_York`, so it still covers this.
- The Entry test runs `cli.Entry()` in a copy of the test binary started with `SECRET_TEST_RUN_ENTRY` set. That copy acts in an `init` function, not in a test, because `TestMain` would otherwise build the `secret` binary again and remove it while the other tests run it.
Disclosures:
- Deviation: `cmd/secret/main.go` now does one thing besides calling `cli.Entry()`, which `AGENTS.md` Go guideline 7 says it should only do. Policy 6 ("Set the local timezone to UTC on startup") and the plan on the issue put the time zone there.
- Rule suppressed: `gochecknoinits` on the test's `init` function, with a reason, as the repo's two other `init` functions do.
- Unverified: that the purge is what crashed the test process. The change takes the purge out of that process either way.
Model: opus-5-5
cli.Entry() set time.Local to UTC and ended with memguard.Purge(), and
TestEntryWipesBuffersAndReturnsExitCode ran it in the same process as
the other tests. A timer left by an earlier test could read time.Local
as it changed, which the race detector reported on some runs, and the
purge could destroy a buffer still in use, the likeliest cause of a
crash seen on another run.
main() in cmd/secret now sets time.Local before it calls cli.Entry();
the test that runs the built binary with TZ=America/New_York still
covers it. The Entry test runs cli.Entry() in a copy of the test binary
started with SECRET_TEST_RUN_ENTRY set, which init picks up so that
TestMain does not run there.
Model: opus-5-5
clawbot
self-assigned this 2026-10-15 18:30:06 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
cli.Entry()settime.Localto UTC and ended withmemguard.Purge(), andTestEntryWipesBuffersAndReturnsExitCoderan it in the same process as every other test ininternal/cli. A timer an earlier test left running, such as the 10-secondtime.Afterones inconfirm_test.go, could readtime.Localas it changed, which the race detector reported on some runs. The purge could destroy a memguard buffer still in use, the likeliest cause of the crash seen on another run.main()incmd/secretnow setstime.Localbefore it callscli.Entry(). memguard starts its goroutines only when first used, so no goroutine ofsecretis running yet. The test from #169 runs the built binary withTZ=America/New_York, so it still covers this.cli.Entry()in a copy of the test binary started withSECRET_TEST_RUN_ENTRYset. That copy acts in aninitfunction, not in a test, becauseTestMainwould otherwise build thesecretbinary again and remove it while the other tests run it.Disclosures:
cmd/secret/main.gonow does one thing besides callingcli.Entry(), whichAGENTS.mdGo guideline 7 says it should only do. Policy 6 ("Set the local timezone to UTC on startup") and the plan on the issue put the time zone there.gochecknoinitson the test'sinitfunction, with a reason, as the repo's two otherinitfunctions do.Model: opus-5-5
Review passed: ready to merge into
next.Model: opus-5-5