diff --git a/docs/changes/unreleased/2047-mac-test-assumptions.md b/docs/changes/unreleased/2047-mac-test-assumptions.md new file mode 100644 index 0000000000..5eb3b81649 --- /dev/null +++ b/docs/changes/unreleased/2047-mac-test-assumptions.md @@ -0,0 +1,13 @@ +--- +kind: internal +title: The last tests that assumed Linux pass on a Mac +pr: 2047 +surface: [build] +invalidates: [] +--- + +The cellstore socket fixtures assumed a short temporary folder that is not +reached through a link; on a Mac it is long and `/tmp` is `/private/tmp`. +The remote stamp answers assumed Linux's device and inode widths. Their +expectations now hold on both systems; no product behaviour changed. The +other Mac assumptions this branch first fixed reached app/v3 through #2099. diff --git a/internal/cellstore/daemon_test.go b/internal/cellstore/daemon_test.go index 70f43cb173..fc441a9ceb 100644 --- a/internal/cellstore/daemon_test.go +++ b/internal/cellstore/daemon_test.go @@ -103,6 +103,10 @@ func TestDaemonOfANonEngineIsUnavailable(t *testing.T) { // Two engine builds never share a daemon: the socket is named after the binary. func TestSocketIsKeyedToTheEngineBinary(t *testing.T) { + // Keep the home address short enough to assert its build-named basename too. + if runtime.GOOS != "windows" { + t.Setenv("TMPDIR", "/tmp") + } base := filepath.Dir(testSocket(t)) t.Setenv("CODEAF_HOME", base) t.Setenv("LOCALAPPDATA", base) diff --git a/internal/cellstore/socket_regression_unix_test.go b/internal/cellstore/socket_regression_unix_test.go index f34ab23a98..b24ee174ed 100644 --- a/internal/cellstore/socket_regression_unix_test.go +++ b/internal/cellstore/socket_regression_unix_test.go @@ -23,6 +23,13 @@ import ( // The lane-local temp base models a shared /tmp without involving another user. func TestR9UnixShortSocketRejectsPreclaimedDirectory(t *testing.T) { t.Setenv("XDG_RUNTIME_DIR", "") + // A short private temp base keeps this fixture in its own fallback lane on macOS. + base, err := os.MkdirTemp("/tmp", "r9-temp-") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = os.RemoveAll(base) }) + t.Setenv("TMPDIR", base) for _, kind := range []string{"writable-directory", "symlink"} { t.Run(kind, func(t *testing.T) { bin := "/engine/furrow-review-" + kind @@ -33,7 +40,7 @@ func TestR9UnixShortSocketRejectsPreclaimedDirectory(t *testing.T) { if err := os.Remove(dir); err != nil && !os.IsNotExist(err) { t.Fatal(err) } - if !strings.HasPrefix(dir, os.TempDir()+string(filepath.Separator)) || len(socket) >= maxSocketBytes { + if !strings.HasPrefix(dir, filepath.Clean(os.TempDir())+string(filepath.Separator)) || len(socket) >= maxSocketBytes { t.Fatalf("C7: fixture did not select its lane-local short fallback: %q", socket) } if _, err := os.Lstat(dir); !os.IsNotExist(err) { @@ -158,6 +165,11 @@ func TestR9UnixShortSocketOrder(t *testing.T) { t.Fatal(err) } t.Cleanup(func() { _ = os.RemoveAll(login) }) + // The home address uses the physical path, including macOS's /private/tmp. + login, err = filepath.EvalSymlinks(login) + if err != nil { + t.Fatal(err) + } t.Setenv("CODEAF_HOME", login) t.Setenv("XDG_RUNTIME_DIR", runtime) bin := "/engine/furrow-review-runtime" diff --git a/internal/remote/teams_test.go b/internal/remote/teams_test.go index 548188aff5..7fcd25ea42 100644 --- a/internal/remote/teams_test.go +++ b/internal/remote/teams_test.go @@ -51,8 +51,10 @@ func TestTheTeamsDoorsCrossFromTheEnginesProfile(t *testing.T) { if err != nil || !same.Same || same.Teams != nil { t.Fatalf("a read at the held stamp: %+v, %v", same, err) } - if raw, _ := json.Marshal(same); len(raw) > 64 { - t.Fatalf("an unchanged answer is %d bytes: %s", len(raw), raw) + // Device and inode widths vary by filesystem; only the stamp and flag cross. + stamp, _ := json.Marshal(wrote.Stamp) + if raw, _ := json.Marshal(same); string(raw) != `{"stamp":`+string(stamp)+`,"same":true}` { + t.Fatalf("an unchanged answer must carry only the held stamp and same: %s", raw) } if err := teamstore.AppendTraffic(dir, "0a0a0a0a0a0a", teamstore.Entry{Kind: teamstore.KindNote, @@ -67,8 +69,9 @@ func TestTheTeamsDoorsCrossFromTheEnginesProfile(t *testing.T) { if err != nil || len(quiet.Entries) != 0 { t.Fatalf("a quiet log after the cursor: %+v, %v", quiet, err) } - if raw, _ := json.Marshal(quiet); len(raw) > 64 { - t.Fatalf("a quiet Traffic answer is %d bytes: %s", len(raw), raw) + stamp, _ = json.Marshal(got.Stamp) + if raw, _ := json.Marshal(quiet); string(raw) != `{"stamp":`+string(stamp)+`}` { + t.Fatalf("a quiet Traffic answer must carry only the held stamp: %s", raw) } if _, err := loop.Client.TeamsTraffic("../escape", "", 1); err == nil { t.Fatal("a team id that is a path was read")