Verify the correct error if one command in the pipeline exits before reading all of its predecessor's output. Note that the amount of unread output in this case *does not fit* within the OS-level pipe buffer.
(t *testing.T)
| 332 | // amount of unread output in this case *does not fit* within the |
| 333 | // OS-level pipe buffer. |
| 334 | func TestIgnoredSIGPIPE(t *testing.T) { |
| 335 | if runtime.GOOS == "windows" { |
| 336 | t.Skip("FIXME: test skipped on Windows: 'seq' unavailable") |
| 337 | } |
| 338 | |
| 339 | t.Parallel() |
| 340 | |
| 341 | p := pipe.New() |
| 342 | p.Add( |
| 343 | pipe.IgnoreError(pipe.Command("seq", "100000"), pipe.IsSIGPIPE), |
| 344 | pipe.Command("echo", "foo"), |
| 345 | ) |
| 346 | |
| 347 | ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) |
| 348 | defer cancel() |
| 349 | out, err := p.Output(ctx) |
| 350 | assert.NoError(t, err) |
| 351 | assert.EqualValues(t, "foo\n", out) |
| 352 | } |
| 353 | |
| 354 | func TestFunction(t *testing.T) { |
| 355 | t.Parallel() |
nothing calls this directly
no test coverage detected