Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions docs/changes/unreleased/2047-mac-test-assumptions.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions internal/cellstore/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion internal/cellstore/socket_regression_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions internal/remote/teams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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")
Expand Down
Loading