-
-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Description
set -e on line 287 is, currently, ineffective, due to how set -x works in subshells.
git clone https://github.com/bash-unit/bash_unit && cd bash_unit
git apply - << 'EOF'
diff --git i/bash_unit w/bash_unit
index 1afc3b7..5b1faed 100755
--- i/bash_unit
+++ w/bash_unit
@@ -287,6 +287,8 @@ run_test() {
set -e
notify_test_starting "$__bash_unit_current_test__"
"$__bash_unit_current_test__" && notify_test_succeeded "$__bash_unit_current_test__"
+ false
+ echo "THIS SHOULD NOT BE PRINTED"
}
run_teardown_suite() {
EOF
./bash_unit -p test_assert_fails_succeeds ./tests/test_core.sh # pick just one testprints
Running tests in ./tests/test_core.sh
Running test_assert_fails_succeeds ... SUCCESS ✓
THIS SHOULD NOT BE PRINTED
Overall result: SUCCESS ✓
because run_test is run in a subshell (in run_tests on line 276).
this also causes unexpected behavior when users try to use set -e in tests.
git clone https://github.com/bash-unit/bash_unit && cd bash_unit
git apply - << 'EOF'
diff --git i/tests/test_core.sh w/tests/test_core.sh
index cc3bd27..dce75d7 100644
--- i/tests/test_core.sh
+++ w/tests/test_core.sh
@@ -15,6 +15,8 @@ test_fail_fails() {
test_assert_fails_succeeds() {
(assert_fails false) || fail 'assert_fails should succeed'
+ false
+ echo "THIS SHOULD NOT BE PRINTED"
}
test_assert_fails_fails() {
EOF
./bash_unit -p test_assert_fails_succeeds ./tests/test_core.sh # pick just one testprints
Running tests in ./tests/test_core.sh
Running test_assert_fails_succeeds ... THIS SHOULD NOT BE PRINTED
SUCCESS ✓
Overall result: SUCCESS ✓
Metadata
Metadata
Assignees
Labels
No labels