usage: TestClearedUsageLeavesThePages leaves no clear behind for the next test

The test ends by clearing everything up to now. readCleared keeps what it
read in clearedAs, and a test that builds a page straight from chunks
(buildRequestBlocksWithCodex) never reads the clears again, so it judged
its rows by that stale clear and hid them all: with
-run "Heatmap|Pair|Scratch|Request|Page", TestCodexRequestPageDoesNotMutateSharedCompactionChunks
(3 subtests), TestCodexRequestPageFoldsCopiesBeforeResponseMatching and
TestRequestDiskNamesItsSource failed on origin/main 49d4d0f7a ("page rows
= 0"). Bisected to this test as the only polluter. The full package's
order happened to put them before it. The test now drops clearedAs when
it ends.

Run on mote at this head (rebased on a0ba8e1f2):
- go test -count=1 -run "Heatmap|Pair|Scratch|Request|Page" ./internal/usage: ok
  (red without the cleanup, as above)
- go test -count=1 -timeout 45m ./internal/usage: ok
- go test -count=1 -timeout 45m ./internal/usage: ok
This commit is contained in:
yetone
2026-10-29 04:44:43 +08:00
parent a0ba8e1f2e
commit fb59595530
+3
View File
@@ -17,6 +17,9 @@ import (
// Visit (key spending limits, window holds) still counts them all.
func TestClearedUsageLeavesThePages(t *testing.T) {
resetUsageTest(t)
// the clears read last stay read for a test that builds a page without
// reading them again (readCleared)
t.Cleanup(func() { clearedAs.Store(nil) })
now := Clock()
at := now.Add(-2 * time.Hour)
Append(Record{Time: at, Agent: "codex", Provider: "ollama", Model: "qwen3:32b", Input: 100, Output: 10, Status: 200})