Function
NewAttachedToInvocation
(t *testing.T, invocation *serpent.Invocation)
Source from the content-addressed store, hash-verified
| 70 | } |
| 71 | |
| 72 | func NewAttachedToInvocation(t *testing.T, invocation *serpent.Invocation) *Expecter { |
| 73 | r, w := io.Pipe() |
| 74 | invocation.Stdout = w |
| 75 | invocation.Stderr = w |
| 76 | e := New(t, r, "cmd") |
| 77 | |
| 78 | t.Cleanup(func() { |
| 79 | // Serpent doesn't handle closing stdout after running the Invocation; normally the OS does that automatically when |
| 80 | // the process exits. Close it here at the end of the test to ensure we don't leak goroutines reading from the |
| 81 | // stdout/stderr. |
| 82 | _ = w.Close() |
| 83 | e.Close("test end") |
| 84 | }) |
| 85 | return e |
| 86 | } |
| 87 | |
| 88 | func NewPiped(t *testing.T) (*Expecter, io.Writer) { |
| 89 | r, w := io.Pipe() |