(t *testing.T)
| 78 | } |
| 79 | |
| 80 | func TestCloseTwice(t *testing.T) { |
| 81 | ctx := context.TODO() |
| 82 | done := make(chan struct{}) |
| 83 | go func() { |
| 84 | c, err := New(ctx, "sh", "-c", "echo hello; sleep 1; exit 0") |
| 85 | assert.NilError(t, err) |
| 86 | cmdConn := c.(*commandConn) |
| 87 | assert.Check(t, processAlive(cmdConn.cmd.Process.Pid)) |
| 88 | |
| 89 | b := make([]byte, 32) |
| 90 | n, err := c.Read(b) |
| 91 | assert.Check(t, is.Equal(len("hello\n"), n)) |
| 92 | assert.NilError(t, err) |
| 93 | |
| 94 | err = cmdConn.Close() |
| 95 | assert.NilError(t, err) |
| 96 | assert.Check(t, !processAlive(cmdConn.cmd.Process.Pid)) |
| 97 | |
| 98 | err = cmdConn.Close() |
| 99 | assert.NilError(t, err) |
| 100 | assert.Check(t, !processAlive(cmdConn.cmd.Process.Pid)) |
| 101 | done <- struct{}{} |
| 102 | }() |
| 103 | |
| 104 | select { |
| 105 | case <-time.After(10 * time.Second): |
| 106 | t.Error("test did not finish in time") |
| 107 | case <-done: |
| 108 | break |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestEOFTimeout(t *testing.T) { |
| 113 | ctx := context.TODO() |
nothing calls this directly
no test coverage detected
searching dependent graphs…