-
Notifications
You must be signed in to change notification settings - Fork 455
Open
Labels
Component: Bash CodeEverything regarding the bash codeEverything regarding the bash codePriority: HighBroken behavior in specific environments like in parallel mode or only on some operating systemsBroken behavior in specific environments like in parallel mode or only on some operating systemsSize: MediumChanges in the same fileChanges in the same fileStatus: ConfirmedThe reproducer worked as describedThe reproducer worked as describedType: BugType: Enhancement
Milestone
Description
Describe the bug
The run changed resets the set -e that change the behaviors of the function.
To Reproduce
- Here is an example script that should fail without print anything to console:
set -e
function main() {
my_command
}
function my_command() {
false # failing command
echo 'FOOBAR'
}
if [ "${BASH_SOURCE[0]}" == "$0" ]; then
main
fi- But this test will fail, because the
set -eis not set as the source :
setup() {
source my_script.sh
}
@test "test my_command" {
run my_command
[ "$output" != '' ]
}Expected behavior
The sourced set flags have to be set under testing too.
Environment (please complete the following information):
- Bats version: 1.8.2
- OS: Linux (nixos)
- Bash version: 5.1.16
Additional context
I use run to have $status and $output.
I have read the https://bats-core.readthedocs.io/en/stable/writing-tests.html#when-not-to-use-run part of the documentation, that mentions the code will run with set -e in a subshell. This would be right for me, but my function works differently.
Metadata
Metadata
Assignees
Labels
Component: Bash CodeEverything regarding the bash codeEverything regarding the bash codePriority: HighBroken behavior in specific environments like in parallel mode or only on some operating systemsBroken behavior in specific environments like in parallel mode or only on some operating systemsSize: MediumChanges in the same fileChanges in the same fileStatus: ConfirmedThe reproducer worked as describedThe reproducer worked as describedType: BugType: Enhancement