-
Notifications
You must be signed in to change notification settings - Fork 30
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
failed assert_file_exist reports as not executed when teardown() with load #40
Comments
Can you post the output with |
Here is the output:
|
This was with load enabled? |
It was not -- my apologies!
|
Okay, that is not a formatter issue. It is very likely not even bats-file related. Does the same behavior occur when you replace the assertion with |
Sadly it does. Replacing the third test with the following:
results in this output:
Test 3a (the original) is not executed, test 3b (replacing Thanks! |
Well thats really interesting. Additional Details: I used this test script:
Which generates the following output with bash 5.1:
As you can see |
That's very esoteric -- thanks for digging into it! I agree, that's a Bash bug that can be worked around rather than a Bats issue to be fixed. Will you log the Bash bug or should I do it (using your test case)? |
Feel free to submit the report. I am not done investigating a workaround. Even if this is fixed, we need to support older bash versions. |
I think this behavior is intended (or at least expected). From the Bash manual:
(emphasis mine) It's surprising that children of the function can see local variables, but given that, the behavior makes sense (for some definition of the word sense). |
Yes, for true recursion that behavior is expected. However, in the script above, |
Hm, I dug a bit deeper and it gets more confusing:
Does not trigger any error. I think this is not a contradiction to your quote, since
So to summarize: EXIT trap + |
OS: MacOS 11.6.1
Bash: 5.1.12(1) (from MacPorts)
Bats: da56a30 (2022-01-05)
Bats-File: 17fa557 (2020-04-29)
This one took me hours to come up with a reproducible example; I didn't also have the fortitude to dig into the code and figure out the cause or a fix, too -- sorry!
If my program calls
assert_file_exist
and fails, instead of reporting a failure it will report the test as not being executed, but only when there's ateardown
function with aload
call in it. Here's a test case; commentary follows:The
foofoo.bash
file is zero bytes; it just needs to exist.When run, this produces the following output:
Notice that one of the tests is shown as not being run, and test #3 does in fact not show up in the output. If you watch the output closely, though, you'll see it is reported, it's just overwritten -- if you move test #3 to be the last test, its line won't get overwritten and you'll see it in the output:
If you remove the
teardown
function (by either deleting it or renaming it), test #3 will properly show as executing and failing:The same results can be achieved by removing the
load
line, e.g.I replicated this aberrant behavior with one or two other
assert_*
commands frombats-file
, but I did not test each one.The text was updated successfully, but these errors were encountered: