MCPcopy Create free account
hub / github.com/Shopify/goose / ExampleSupervisor_Wait

Function ExampleSupervisor_Wait

shell/shell_test.go:17–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15)
16
17func ExampleSupervisor_Wait() {
18 ctx := context.Background()
19 cmd := New(ctx, "cat")
20 stdin, _ := cmd.Cmd().StdinPipe()
21 stdout, _ := cmd.Cmd().StdoutPipe()
22
23 cmd.Start()
24 stdin.Write([]byte("foo"))
25 stdin.Close()
26
27 output, _ := io.ReadAll(stdout)
28
29 // Must call Wait _after_ interacting with pipes
30 cmd.Wait()
31
32 fmt.Println(string(output))
33 // Output:
34 // foo
35}
36
37func ExampleSupervisor_RunAndGetOutput() {
38 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.80
NewFunction · 0.70
CmdMethod · 0.65
StartMethod · 0.65
WaitMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected