MCPcopy Index your code
hub / github.com/coder/coder / Start

Function Start

pty/ptytest/ptytest.go:48–67  ·  view source on GitHub ↗

Start starts a new process asynchronously and returns a PTYCmd and Process. It kills the process and PTYCmd upon cleanup

(t *testing.T, cmd *pty.Cmd, opts ...pty.StartOption)

Source from the content-addressed store, hash-verified

46// Start starts a new process asynchronously and returns a PTYCmd and Process.
47// It kills the process and PTYCmd upon cleanup
48func Start(t *testing.T, cmd *pty.Cmd, opts ...pty.StartOption) (*PTYCmd, pty.Process) {
49 t.Helper()
50
51 ptty, ps, err := pty.Start(cmd, opts...)
52 require.NoError(t, err)
53 t.Cleanup(func() {
54 _ = ps.Kill()
55 _ = ps.Wait()
56 })
57 ex := newExpecter(t, ptty.OutputReader(), cmd.Args[0])
58
59 r := &PTYCmd{
60 outExpecter: ex,
61 PTYCmd: ptty,
62 }
63 t.Cleanup(func() {
64 _ = r.Close()
65 })
66 return r, ps
67}
68
69func newExpecter(t *testing.T, r io.Reader, name string) outExpecter {
70 // Use pipe for logging.

Callers 2

TestStartFunction · 0.92
TestStartFunction · 0.92

Calls 8

CloseMethod · 0.95
StartFunction · 0.92
newExpecterFunction · 0.85
HelperMethod · 0.65
CleanupMethod · 0.65
KillMethod · 0.65
WaitMethod · 0.65
OutputReaderMethod · 0.65

Tested by 2

TestStartFunction · 0.74
TestStartFunction · 0.74