-
Notifications
You must be signed in to change notification settings - Fork 440
Closed
Labels
Component: Bash CodeEverything regarding the bash codeEverything regarding the bash codePriority: CriticalBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorStatus: ConfirmedThe reproducer worked as describedThe reproducer worked as describedType: Bug
Milestone
Description
Describe the bug
When there is an error happening both inside setup_file
and teardown_file
, there will be no error reported.
Instead, it will print a message like this, with no pointers to errors:
bats warning: Executed 0 instead of expected 1 tests
1 test, 0 failures, 1 not run
To Reproduce
Save into file and bats-run the tests below:
load /usr/local/lib/bats-support/load.bash
load /usr/local/lib/bats-assert/load.bash
@test "bats prints error in setup_file" {
cat <<EOF >foo.bats
setup_file (){ false; }
$(echo @test) "foo" { true; }
EOF
run bats foo.bats
assert_output --regexp 'setup_file.*failed'
}
@test "bats prints error in teardown_file" {
cat <<EOF >foo.bats
teardown_file (){ false; }
$(echo @test) "foo" { true; }
EOF
run bats foo.bats
assert_output --regexp 'teardown_file.*failed'
}
# Currently broken, no 'failed' message reported:
@test "bats prints error in both setup_file and teardown_file" {
cat <<EOF >foo.bats
setup_file (){ false; }
teardown_file (){ false; }
$(echo @test) "foo" { true; }
EOF
run bats foo.bats
assert_output --regexp 'failed'
}
Expected behavior
A meaningful error message is returned,
akin to:
✗ setup_file failed
(from function `setup_file' in test file foo.bats, line 1)
`setup_file (){ false; }' failed
1 test, 1 failure
Environment (please complete the following information):
- Bats Version: tried 1.5 and 1.7
- OS: Fedora
- Bash version: GNU bash, version 5.0.17(1)-release (x86_64-redhat-linux-gnu)
Metadata
Metadata
Assignees
Labels
Component: Bash CodeEverything regarding the bash codeEverything regarding the bash codePriority: CriticalBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorBroken behavior in nearly all environments, e.g. wrong test results, internal bats errorStatus: ConfirmedThe reproducer worked as describedThe reproducer worked as describedType: Bug