diff --git a/internal/gateway/main_test.go b/internal/gateway/main_test.go index cb6e2ab24..9e325f358 100644 --- a/internal/gateway/main_test.go +++ b/internal/gateway/main_test.go @@ -44,6 +44,16 @@ func isolatedTests(m *testing.M) (int, error) { return 1, err } } + // The package isolates itself rather than through testenv.Run, so it + // says so as testenv does: what reads the marker (a CLI identity kept + // on disk, provider.keepsIdentities; the machine's own folders, + // proc.SystemDirs) then acts as in any isolated test binary. Without it + // an ask still going when its test ended wrote cli-identity.json into + // the next test's folder as that was removed (#1524, again after + // 9c377231 dropped this package's own switch). + if err := os.Setenv(testenv.Marker, home); err != nil { + return 1, err + } for _, name := range agentenv.Vars { if err := os.Unsetenv(name); err != nil { return 1, err @@ -82,3 +92,11 @@ func isolatedTests(m *testing.M) (int, error) { testenv.Offline() return m.Run(), nil } + +// The package's tests run as an isolated test binary: nothing the marker +// turns off (a CLI identity kept on disk, #1524) runs behind a test's back. +func TestRunsAsAnIsolatedTestBinary(t *testing.T) { + if os.Getenv(testenv.Marker) == "" { + t.Fatalf("TestMain left %s unset", testenv.Marker) + } +}