From b02d75bebc7f1a0755a424b977029ff4b093b257 Mon Sep 17 00:00:00 2001 From: Abir Abbas Date: Mon, 2 Nov 2026 18:37:32 -0500 Subject: [PATCH] tests: sync fixtures keep their socket homes short on macOS and wait for branch publication Rebased onto app/v3, where #2178 and #2183 already cover most of this branch: the engine-backed fixtures and the hosted take-back's resumed-hold proof. What is left: - the hosted move rig and the drive rig's default daemon keep their homes under /tmp on Unix, because macOS's temporary folder leaves a workspace socket only a few bytes under the address limit; - the L12 death-branches test waits for A's branch row to hold its three orphan turns before it reads them. Co-Authored-By: Claude Opus 5.5 --- cmd/codeaf/hosted_takeback_test.go | 10 +++++++++- docs/changes/unreleased/2032-sync-engine-fixtures.md | 5 +++++ internal/syncsetup/drive_test.go | 10 ++++++++++ internal/syncsetup/twohomes_test.go | 4 ++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 docs/changes/unreleased/2032-sync-engine-fixtures.md diff --git a/cmd/codeaf/hosted_takeback_test.go b/cmd/codeaf/hosted_takeback_test.go index 993a2cef0b..3eef5ae626 100644 --- a/cmd/codeaf/hosted_takeback_test.go +++ b/cmd/codeaf/hosted_takeback_test.go @@ -15,6 +15,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "slices" "strings" "sync" @@ -67,7 +68,14 @@ func (m moveRenewals) RenewalChanges() <-chan struct{} { return m.changes } func newHostedMoveRig(t *testing.T, wrap ...func(http.Handler) http.Handler) *hostedMoveRig { t.Helper() cfg, c := doorChat(t) - short, err := os.MkdirTemp("", "cf-move-") + // The workspace host's socket lives under this home. macOS's temporary + // folder leaves it only a few bytes under the socket limit, and none once + // that folder is spelled through /private, so Unix homes start at /tmp. + base := "" + if runtime.GOOS != "windows" { + base = "/tmp" + } + short, err := os.MkdirTemp(base, "cf-move-") if err != nil { t.Fatal(err) } diff --git a/docs/changes/unreleased/2032-sync-engine-fixtures.md b/docs/changes/unreleased/2032-sync-engine-fixtures.md new file mode 100644 index 0000000000..49cdb18f55 --- /dev/null +++ b/docs/changes/unreleased/2032-sync-engine-fixtures.md @@ -0,0 +1,5 @@ +--- +kind: internal +title: Sync fixtures keep their socket homes short on macOS and wait for branch publication +pr: 2032 +--- diff --git a/internal/syncsetup/drive_test.go b/internal/syncsetup/drive_test.go index 195bb77478..8cab8d45a4 100644 --- a/internal/syncsetup/drive_test.go +++ b/internal/syncsetup/drive_test.go @@ -498,6 +498,16 @@ func TestDriveSideStartsAsViewerWhenHeld(t *testing.T) { // daemon's socket appearing shows the daemon, and not the spawn, served them. func TestDriveSidePublishesOverTheDefaultDaemon(t *testing.T) { r := newDriveRig(t) + if runtime.GOOS != "windows" { + // The rig has not opened an engine transport yet. A short home keeps + // its socket inside the home even with macOS's small address limit. + short, err := os.MkdirTemp("/tmp", "cds") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = os.RemoveAll(short) }) + t.Setenv(home.EnvVar, short) + } t.Setenv("CODEAF_ENGINE_DAEMON", "") r.engine.Transport = nil t.Cleanup(func() { stopDaemons(t) }) diff --git a/internal/syncsetup/twohomes_test.go b/internal/syncsetup/twohomes_test.go index e7c33fa0a3..082cae3369 100644 --- a/internal/syncsetup/twohomes_test.go +++ b/internal/syncsetup/twohomes_test.go @@ -493,6 +493,10 @@ func TestTwoHomesL12DeathBranches(t *testing.T) { h.block.set(false) waitFor(t, "A to learn it was superseded", func() bool { _, viewer := a.drive.Viewer(); return viewer }) + waitFor(t, "A's branch row to hold three orphan turns", func() bool { + branch, ok := branchRowOf(t, h.a, h.cell.ID) + return ok && branch.OrphanTurns == 3 + }) v, err := h.a.Dir.Cell(ctx, h.cell.ID) if err != nil || v.Cell.Head != parentHead || v.Cell.Lease.Device != h.b.Device.ID() {