Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

report $output content when test fails #8

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libexec/bats-exec-test
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ run() {
set +e
output="$("$@" 2>&1)"
status="$?"
echo "$output" | sed -e 's/^/ #output#/' > "$BATS_OUT"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this just helped me too, thanks :)

I don't think the sed is necessary, though -- the way I see it, run should behave the same as just invoking the command normally (except that a non-zero exit doesn't fail the test, and that the status and output are captured)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although perhaps it should append to $BATS_OUT so that it doesn't overwrite the rest of the test case's output.

IFS=$'\n' lines=($output)
[ -z "$e" ] || set -e
}
Expand Down