MCPcopy Create free account
hub / github.com/Facets-cloud/flow / stubITerm

Function stubITerm

internal/app/do_test.go:48–76  ·  view source on GitHub ↗

stubITerm replaces iterm.Runner with a counter + captured-script recorder. Returns the counter pointer and a function that reads the most recent AppleScript argument passed to osascript. It also pins spawner.Override to BackendITerm so the test is not affected by an ambient $ZELLIJ env var (e.g. wh

(t *testing.T)

Source from the content-addressed store, hash-verified

46 return []byte(`{"type":"thread.started","thread_id":"` + sid + `"}`), nil
47 }
48 t.Cleanup(func() { codex.ProbeRunner = old })
49}
50
51// stubITerm replaces iterm.Runner with a counter + captured-script
52// recorder. Returns the counter pointer and a function that reads the
53// most recent AppleScript argument passed to osascript.
54//
55// It also pins spawner.Override to BackendITerm so the test is not
56// affected by an ambient $ZELLIJ env var (e.g. when the developer runs
57// the test suite from inside a zellij session).
58func stubITerm(t *testing.T) (*int64, func() string) {
59 t.Helper()
60 var count int64
61 var mu sync.Mutex
62 var lastScript string
63 old := iterm.Runner
64 iterm.Runner = func(args []string) error {
65 atomic.AddInt64(&count, 1)
66 mu.Lock()
67 if len(args) >= 2 {
68 lastScript = args[1]
69 }
70 mu.Unlock()
71 return nil
72 }
73 t.Cleanup(func() { iterm.Runner = old })
74
75 // Pin the spawner backend so ambient env vars (e.g. ZELLIJ) don't
76 // reroute SpawnTab away from iterm.Runner.
77 oldOverride := spawner.Override
78 spawner.Override = spawner.BackendITerm
79 t.Cleanup(func() { spawner.Override = oldOverride })

Calls

no outgoing calls

Tested by

no test coverage detected