Verify the correct error if a command in the pipeline exits before reading all of its predecessor's output. Note that the amount of unread output in this case *does fit* within the OS-level pipe buffer.
(t *testing.T)
| 286 | // unread output in this case *does fit* within the OS-level pipe |
| 287 | // buffer. |
| 288 | func TestLittleEPIPE(t *testing.T) { |
| 289 | if runtime.GOOS == "windows" { |
| 290 | t.Skip("FIXME: test skipped on Windows: 'sleep' unavailable") |
| 291 | } |
| 292 | |
| 293 | t.Parallel() |
| 294 | |
| 295 | p := pipe.New() |
| 296 | p.Add( |
| 297 | pipe.Command("sh", "-c", "sleep 1; echo foo"), |
| 298 | pipe.Command("true"), |
| 299 | ) |
| 300 | |
| 301 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 302 | defer cancel() |
| 303 | err := p.Run(ctx) |
| 304 | assert.EqualError(t, err, "sh: signal: broken pipe") |
| 305 | } |
| 306 | |
| 307 | // Verify the correct error if one command in the pipeline exits |
| 308 | // before reading all of its predecessor's output. Note that the |