Skip to content

Commit 9ff07bc

Browse files
committed
fix(test): make restart-path tests independent of the CI runner
GitHub Actions runs jobs under systemd, so INVOCATION_ID is set on the runner and update.IsSystemd() reports true there but false on a developer machine. The systemd branch then short-circuited before the launchd and container branches, failing six restart-path tests in CI while passing locally. Clear INVOCATION_ID in both TestMains so branch selection is deterministic; the systemd tests opt back in explicitly.
1 parent 49f1d55 commit 9ff07bc

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

internal/update/update_testmain_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import (
1111
// reaches Restart(). Tests that exercise the launchd branch override the hooks
1212
// themselves.
1313
func TestMain(m *testing.M) {
14+
// GitHub Actions runs jobs under systemd, so INVOCATION_ID is set on the
15+
// runner and IsSystemd() reports true there but not on a developer
16+
// machine. Clear it so Restart()'s branch selection is deterministic; the
17+
// systemd tests set it explicitly.
18+
os.Unsetenv("INVOCATION_ID")
19+
1420
launchdSupported = func() bool { return false }
1521
launchdInstalled = func() bool { return false }
1622
launchdLoaded = func() bool { return false }

main_testmain_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ func TestMain(m *testing.M) {
2020
os.Unsetenv("OPENCODE_HOME")
2121
os.Unsetenv("XDG_DATA_HOME")
2222

23+
// GitHub Actions runs jobs under systemd, so INVOCATION_ID is set on the
24+
// runner and update.IsSystemd() reports true there but not on a developer
25+
// machine. Clear it so the restart-path tests see the same world in both
26+
// places; the systemd test opts back in with t.Setenv.
27+
os.Unsetenv("INVOCATION_ID")
28+
2329
// Auto-start and daemon-spawn safety net: no test may shell out to
2430
// launchctl, touch the developer's real LaunchAgents directory, or start a
2531
// real onWatch daemon (which would poll live provider APIs). Tests that

0 commit comments

Comments
 (0)