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)