From 01cd69692f8dc09a06e3e0b04dcc1e412452404a Mon Sep 17 00:00:00 2001 From: Lemon-miaow Date: Tue, 29 Sep 2026 02:28:50 +0800 Subject: [PATCH] =?UTF-8?q?test(watchdog):=20=E7=8A=B6=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=85=88=E6=8B=A8=E5=9B=9E=E4=B8=8A=E4=B8=80=E8=BD=AE?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E9=97=B4=EF=BC=8CLinux=20=E7=B2=97=E7=B2=92?= =?UTF-8?q?=E5=BA=A6=20mtime=20=E4=B8=8B=E5=A4=87=E7=94=A8=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E5=86=8D=E5=92=8C=E5=AE=83=E5=90=8C=E5=88=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/watchdog/watchdog_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/watchdog/watchdog_test.go b/internal/watchdog/watchdog_test.go index de04f76..5ec70e6 100644 --- a/internal/watchdog/watchdog_test.go +++ b/internal/watchdog/watchdog_test.go @@ -262,6 +262,13 @@ func TestSaveStateOr(t *testing.T) { if got := NewestState(path, fallback); got != path { t.Fatalf("no fallback yet: NewestState = %q, want the file", got) } + // An earlier run wrote the file, minutes before this one. Linux stamps files + // from a coarse clock, so two writes a test makes back to back can share an + // mtime, and a tie reads the file. + earlier := time.Now().Add(-time.Hour) + if err := os.Chtimes(path, earlier, earlier); err != nil { + t.Fatal(err) + } mailed := &State{Recipients: []string{"owner@example.com"}} run(mailed, Report{Findings: []Finding{finding("memory", Warning, 0)}}, t0)