diff --git a/accounts_plugin_cli_test.go b/accounts_plugin_cli_test.go index b6c4abe33..1dae1f3d3 100644 --- a/accounts_plugin_cli_test.go +++ b/accounts_plugin_cli_test.go @@ -3,7 +3,6 @@ package main import ( "context" "encoding/json" - "os/exec" "path/filepath" "strings" "testing" @@ -16,10 +15,7 @@ import ( // magpie accounts lists, switches and forgets a plugin's accounts by its // provider's id, as a built-in subscription's. func TestAccountsOfAPlugin(t *testing.T) { - bun, err := exec.LookPath("bun") - if err != nil { - t.Skip("no bun on PATH") - } + bun := pathBun(t) home := t.TempDir() t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) diff --git a/plugin_login_cli_test.go b/plugin_login_cli_test.go index 06b7be7eb..ae279d558 100644 --- a/plugin_login_cli_test.go +++ b/plugin_login_cli_test.go @@ -101,10 +101,7 @@ func TestPluginLoginReadsUsageAfresh(t *testing.T) { // plugin (FakeCo) added, as TestAccountsOfAPlugin sets one up. func fakeCoHome(t *testing.T) context.Context { t.Helper() - bun, err := exec.LookPath("bun") - if err != nil { - t.Skip("no bun on PATH") - } + bun := pathBun(t) home := t.TempDir() t.Setenv("HOME", home) t.Setenv("USERPROFILE", home) @@ -125,6 +122,21 @@ func fakeCoHome(t *testing.T) context.Context { return ctx } +// pathBun is the bun on PATH, run once before the caller opens its +// one-minute context. A bun just installed or upgraded hasn't run on this +// machine yet, and macOS checks a program before its first exec, which can +// take tens of seconds on a busy machine: that check must not eat the +// minute the plugin calls have (ggbdpq, #1306; 7ddea2c2 for the copied bun). +func pathBun(t *testing.T) string { + t.Helper() + bun, err := exec.LookPath("bun") + if err != nil { + t.Skip("no bun on PATH") + } + exec.Command(bun, "--version").Run() + return bun +} + // noBrowser has the sign-in pages magpie opens go nowhere. It swaps the // opener rather than putting a do-nothing open first on PATH: a script // written now is a program macOS checks on its first run, which took 25 to