(t *testing.T, opts ...pty.Option)
| 26 | ) |
| 27 | |
| 28 | func New(t *testing.T, opts ...pty.Option) *PTY { |
| 29 | t.Helper() |
| 30 | |
| 31 | ptty, err := newTestPTY(opts...) |
| 32 | require.NoError(t, err) |
| 33 | |
| 34 | e := newExpecter(t, ptty.Output(), "cmd") |
| 35 | r := &PTY{ |
| 36 | outExpecter: e, |
| 37 | PTY: ptty, |
| 38 | } |
| 39 | // Ensure pty is cleaned up at the end of test. |
| 40 | t.Cleanup(func() { |
| 41 | _ = r.Close() |
| 42 | }) |
| 43 | return r |
| 44 | } |
| 45 | |
| 46 | // Start starts a new process asynchronously and returns a PTYCmd and Process. |
| 47 | // It kills the process and PTYCmd upon cleanup |