Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pkgs/mcpx/internal/cli/ensuredaemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,24 @@ func TestEnsureDaemonNeverReadyStillTimesOut(t *testing.T) {
if elapsed := time.Since(start); elapsed < 900*time.Millisecond {
t.Fatalf("gave up after %v, before the 1s connect timeout", elapsed)
}
if _, statErr := os.Stat(marker); statErr != nil {
t.Fatal("the fake daemon was never spawned")
// The spawn is cmd.Start + Release (client.go): Start returns once the
// process exists, before the child has run any code, so the child's
// touch can legitimately land after EnsureDaemon returns at the
// connect timeout. Asserting the marker instantly races the child's
// scheduling — the same flake as dezren39/nix#428, in the test this
// repo's #437 port added without that pattern (dezren39/nix#445,
// origin issue for this set). The child is Setsid and Released, so it
// still runs: wait for the marker instead, and fail only if it never
// appears.
deadline := time.Now().Add(5 * time.Second)
for {
if _, statErr := os.Stat(marker); statErr == nil {
break
}
if time.Now().After(deadline) {
t.Fatal("the fake daemon was never spawned")
}
time.Sleep(10 * time.Millisecond)
}
}

Expand Down
Loading