-
Notifications
You must be signed in to change notification settings - Fork 73
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
Assert/Refute against nonempty/empty output #15
base: master
Are you sure you want to change the base?
Conversation
if (( is_mode_nonempty )); then | ||
if [ -z "$output" ]; then | ||
echo 'expected non-empty output, but output was empty' \ | ||
| batslib_decorate 'no output' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use an additional 2 space indentation before the pipes to follow the style of existing code. If you want to change style, I'm up for debating in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong preference. I just use the formatter that comes built-in with vim, which had them not indented.
if (( is_mode_empty )); then | ||
if [ -n "$output" ]; then | ||
echo 'expected no output, but output was non-empty' \ | ||
| batslib_decorate 'unexpected output' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should show $output
here. See a few lines later in this function how to do that.
if (( is_mode_empty )); then | ||
if [ -n "$output" ]; then | ||
echo 'expected no output, but output was non-empty' \ | ||
| batslib_decorate 'unexpected output' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add 2 spaces of indentation here too, please.
run echo 'a' | ||
run assert_output <<STDIN | ||
run assert_output | ||
echo "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you may have left this in by accident. I do this a lot too.. intentionally not identing the echo
s so I will spot them before commiting, but I end up leaving them there. 😄
@test 'assert_output(): fails if output is empty' { | ||
run echo '' | ||
run assert_output | ||
echo "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another forgotten debug print.
@test 'refute_output(): succeeds if output is empty' { | ||
run echo '' | ||
run refute_output | ||
echo "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another forgotten debug print.
run echo 'a' | ||
run refute_output <<INPUT | ||
run refute_output | ||
echo "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another forgotten debug print.
Indentation fixed; debugging echos removed; improved error messaging. |
bump (changes had been made as requested) |
merged in my fork: bats-core@44c1c08 |
Closes #5; Depends on #14
Do not merge; still needs update to docs.Docs added.