MCPcopy Create free account
hub / github.com/JordanCoin/codemap / withMainRuntimeStubs

Function withMainRuntimeStubs

main_more_test.go:48–99  ·  view source on GitHub ↗
(
	t *testing.T,
	watchFactory func(root string, verbose bool) (watchProcess, error),
	signalNotifier func(c chan<- os.Signal, sig ...os.Signal),
	cmdFactory func(name string, args ...string) *exec.Cmd,
	exePath func() (string, error),
	isRunning func(string) bool,
	stopWatch func(string) error,
	terminal func(*os.File) bool,
)

Source from the content-addressed store, hash-verified

46}
47
48func withMainRuntimeStubs(
49 t *testing.T,
50 watchFactory func(root string, verbose bool) (watchProcess, error),
51 signalNotifier func(c chan<- os.Signal, sig ...os.Signal),
52 cmdFactory func(name string, args ...string) *exec.Cmd,
53 exePath func() (string, error),
54 isRunning func(string) bool,
55 stopWatch func(string) error,
56 terminal func(*os.File) bool,
57) {
58 t.Helper()
59
60 prevWatchFactory := newWatchProcess
61 prevNotifier := notifySignals
62 prevCmdFactory := execCommand
63 prevExePath := executablePath
64 prevIsRunning := watchIsRunning
65 prevStopWatch := stopWatchDaemon
66 prevTerminal := terminalChecker
67
68 if watchFactory != nil {
69 newWatchProcess = watchFactory
70 }
71 if signalNotifier != nil {
72 notifySignals = signalNotifier
73 }
74 if cmdFactory != nil {
75 execCommand = cmdFactory
76 }
77 if exePath != nil {
78 executablePath = exePath
79 }
80 if isRunning != nil {
81 watchIsRunning = isRunning
82 }
83 if stopWatch != nil {
84 stopWatchDaemon = stopWatch
85 }
86 if terminal != nil {
87 terminalChecker = terminal
88 }
89
90 t.Cleanup(func() {
91 newWatchProcess = prevWatchFactory
92 notifySignals = prevNotifier
93 execCommand = prevCmdFactory
94 executablePath = prevExePath
95 watchIsRunning = prevIsRunning
96 stopWatchDaemon = prevStopWatch
97 terminalChecker = prevTerminal
98 })
99}
100
101func captureMainStreams(t *testing.T, fn func()) (string, string) {
102 t.Helper()

Calls

no outgoing calls

Tested by

no test coverage detected