-
Notifications
You must be signed in to change notification settings - Fork 9
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
tests: make failure message output from bats useful #43
Conversation
Let's use diff -u expected actual rather than [ "$foo" = "bar" ]. This should make bats emit something useful when tests fail rather than a simple line number in the tests that failed. Closes #42
This seems like a very good solution to the no-diagnostic-output-problem. 👍 Problem is, I still get exactly the same output as in #33
I think I managed to nail down the problem with this:
results in:
So it seems like tests are directly exited after a failed assertion comparison, and the diff is never executed for a failed test. |
Moving the status assertion below the diff call for my failing test, I'm getting output!
|
Cool! What provides /bin/sh on your system? I'll amend the branch to move the exit status assertions after the diffs. |
When exit status isn't what we expect, usually the diff will show some clues as to what's going wrong more than a failed status check.
|
Did you notice something how this could result in the test failure, or why did you want to know? ❓ 😄 It might be relevant that while /bin/sh is a bash, my login shell is actually not bash compatible (fish), so e.g. any shell script that's not properly shebanged will fail. 😉 If there's nothing more you want to do, I think this would be ready to merge. 👍 for managing to add this feature with almost no added complexity. |
Indeed - I am torn between providing convenience methods for some of this stuff, and keeping it obvious in the tests... As for why it's failing with bash: well, I tried very hard to avoid introducing any bash-isms so that alternate shells would work happily. And yet, here we are! I wrote it for dash, the default on Debian, and it seems I've done something that isn't properly emulated by bash in /bin/sh personality. Will address the "fails with bash" problem on #33, thanks again for reviewing. |
Let's use diff -u expected actual rather than [ "$foo" = "bar" ].
This should make bats emit something useful when tests fail rather
than a simple line number in the tests that failed.
Closes #42