Skip to content

grep: write error: Broken pipe when running tests #115

Closed
@Pamplemousse

Description

@Pamplemousse

When running tests in a "non-conventional" environment (during a nix build), I noticed that some complain about a broken pipe (but are still successful).

Running test_fail_fails ... /nix/store/11b3chszacfr9liy829xqknzp3q88iji-gnugrep-3.11/bin/grep: write error: Broken pipe
SUCCESS

I understand that 5d8953b9 addressed a similar issue.

Internet searches pointed at a potential culprit: SIGPIPE being trapped (which happens in nix build, and on - some - CI/CD environments).

And indeed, one can reproduce the complaint by manually trapping SIGPIPE:

$ trap '' SIGPIPE
$ ./bash_unit -p test_fail_fails tests/test_core.sh 
Running tests in tests/test_core.sh
        Running test_fail_fails ... /nix/store/11b3chszacfr9liy829xqknzp3q88iji-gnugrep-3.11/bin/grep: write error: Broken pipe
SUCCESS ✓ 
Overall result: SUCCESS ✓ 

It's unclear to me how this situation should be handled, especially as I am not sure which pipe(s) may break.

As far as I can tell, only the following tests behave this way:

test_assert_fails_fails
test_assert_shows_stderr_on_failure
test_assert_shows_stdout_on_failure
test_fail_fails
test_fail_prints_failure_message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions