-
Notifications
You must be signed in to change notification settings - Fork 516
Print the bash command that caused the test to fail #15
Conversation
Tests pass when run in-repo with bin/bats, but fail with a bats installed with homebrew. Not sure whats up with that
|
Would be cool if there was a way to see the command with variables expanded, not sure if thats possible though. Right now it looks like
|
This looks helpful! I hope the pull is considered. |
Maybe make this optional via new option? |
@ryansouza I like this patch. Would you be interested in rebasing it against the changes in master? |
In case @lzap 's idea of an option is desired, it seems we're a bit limited on the best letter to use, since Bats only parses the first letter, ie; The letters c, h, p, t, v are used. Thus it would be ambiguous to use v=verbosity (used for version), c for command (used for count), t for trace (used for tap). Perhaps letter 'd' could be used, show 'debug' information? Refs, |
I would love this feature. It would replace my helper that I use for test suites: assert() {
if ! "$@"; then
flunk "failed: $@"
fi
} ( |
Speaking about options and letters, I started different shell project some time ago and quickly ran out of letters. So I had to refactor it a bit to use external GNU getopt which works with both short and long options for checking options and pure Bash for parsing them. Just for some inspiration (not saying this is good example of how to write shell scripts :-) |
Let's keep it simple. We don't need to hide this behind a command-line option. |
I'll give the rebase a try when I get home |
Rebased, updated the pull description with a better example & pretty output |
This is looking good. It doesn't properly display failing commands in teardown functions, though. Here's a minimal test case: teardown() {
false
}
@test "truth" {
true
}
|
This is proving to be a tough bug to squash, definitely flexing my bash debug skills. Appears to be calling teardown in an if statement is swallowing the Easy way out: just not display that line if theres no |
Any update on this? Seems like a very useful feature to add to bats. |
I haven't had a chance to work on this, but if we can resolve the issue I described above, I'll be happy to merge it. |
Fair enough, thanks @sstephenson . I don't have time today, but if I do soon, I'll try and update the teardown function. |
Yeah I spent some time trying to get it to work with no luck Didn't realize its been 6 months though, oof :\ |
Closing in favor of #57 |
Includes the
$BASH_COMMAND
and exit status that caused the test failure in the pretty failure outputedit: rebased & updated (11/10)