Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #115 #116

Merged
merged 1 commit into from
Mar 8, 2024
Merged

Fixes #115 #116

merged 1 commit into from
Mar 8, 2024

Conversation

pgrange
Copy link
Owner

@pgrange pgrange commented Mar 8, 2024

We observed broken pipe output messages with bash_unit test in some environments: github CI and nix builds. The tests are passing but display this suspiscious error message.

@Pamplemousse has been able to reproduce them locally by 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 ✓

From man, SIGPIPE appears when a process writes on a pipe with no reader. Looking at the problematic tests, we see that they all rely on a muted bash_unit with a stacktrace output being muted.

When we look at how the stacktrace is muted, the code was like this:

  notify_stack () { : ; }

And when we look at how the stacktrace is outputed by bash_unit we see the following code:

  stacktrace | notify_stack

So we have some process run by stacktrace that is piped to a void function, that is, no process on the right of this pipe is reading which makes it a good candidate to generate a SIGPIPE.

By replacing the muted notify_stack with the following code, the issue is solved:

  notify_stack  () { $CAT >/dev/null ; }

We observed broken pipe output messages with bash_unit test in
some environments: github CI and nix builds. The tests are
passing but display this suspiscious error message.

@Pamplemousse has been able to reproduce them locally by 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 ✓

From man, SIGPIPE appears when a process writes on a pipe with
no reader. Looking at the problematic tests, we see that they
all rely on a muted bash_unit with a stacktrace output being
muted.

When we look at how the stacktrace is muted, the code was like this:

  notify_stack () { : ; }

And when we look at how the stacktrace is outputed by bash_unit we
see the following code:

  stacktrace | notify_stack

So we have some process run by stacktrace that is piped to a void
function, that is, no process on the right of this pipe is reading
which makes it a good candidate to generate a SIGPIPE.

By replacing the muted notify_stack with the following code, the
issue is solved:

  notify_stack  () { $CAT >/dev/null ; }
@pgrange pgrange merged commit 800016b into master Mar 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant