From dba9cdd7edbaa51cd81279cc72c040d15a687f74 Mon Sep 17 00:00:00 2001 From: Julian Blacher Date: Sun, 8 Nov 2026 00:19:25 -0300 Subject: [PATCH] chore: stop ignoring cmd/prw, and deflake an auto-watch test .gitignore had a bare "prw" pattern, which matches any file or directory named prw, including cmd/prw: new source files there were silently ignored. Ignore only the binaries built in the repository root (/prw, /prw.exe), plus /release/. TestRun_PicksUpAutoWatchEnabledWhileRunning ran the watcher for a fixed 1.5s and expected a 1s tick inside it, which failed on a loaded machine. It now stops as soon as the auto-watched PR is in the watch list, with a 10s cap. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 6 +++++- internal/watcher/autowatch_test.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 145ab6a..49cfeaa 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ go.work # Build output /bin/ /dist/ +/release/ # IDE .idea/ @@ -35,4 +36,7 @@ Thumbs.db # Local config (for testing) .prw/ -prw \ No newline at end of file + +# Binary built in the repository root (not the cmd/prw sources) +/prw +/prw.exe diff --git a/internal/watcher/autowatch_test.go b/internal/watcher/autowatch_test.go index d08bf4e..66fa916 100644 --- a/internal/watcher/autowatch_test.go +++ b/internal/watcher/autowatch_test.go @@ -286,12 +286,21 @@ func TestRun_PicksUpAutoWatchEnabledWhileRunning(t *testing.T) { s := &fakeSearcher{results: map[string]*github.SearchResult{config.AutoWatchMine: found(2)}} s.prs = map[string]*github.PullRequest{"owner/repo/1": newPR(1, "sha1"), "owner/repo/2": newPR(2, "sha2")} - ctx, cancel := context.WithTimeout(context.Background(), 1500*time.Millisecond) + // Stop as soon as the search added PR 2, so a slow machine doesn't fail the test + // by missing a fixed deadline. + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() go func() { time.Sleep(300 * time.Millisecond) // `prw watch --mine` in another terminal. config.Update(func(c *config.Config) error { c.EnableAutoWatch(config.AutoWatchMine); return nil }) + for ctx.Err() == nil { + if c, err := config.Load(); err == nil && len(c.WatchedPRs) == 2 { + cancel() + return + } + time.Sleep(50 * time.Millisecond) + } }() New(s, cfg, &mockNotifier{}).Run(ctx)