We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b7b59d commit ca72321Copy full SHA for ca72321
1 file changed
bash_unit
@@ -274,15 +274,15 @@ run_tests() {
274
notify_test_skipped "$skipped_test"
275
done
276
277
+ local has_setup=0 has_teardown=0
278
+ declare -F | "$GREP" ' setup$' >/dev/null && has_setup=1
279
+ declare -F | "$GREP" ' teardown$' >/dev/null && has_teardown=1
280
+
281
for test in $tests_to_run
282
do
283
(
284
local status=0
- declare -F | "$GREP" ' setup$' >/dev/null && setup
- # make sure teardown runs even if the test fails
- local has_teardown=0
- # shellcheck disable=SC2034 # foo appears unused. Verify it or export it.
285
- declare -F | "$GREP" ' teardown$' >/dev/null && has_teardown=1
+ ((has_setup)) && setup
286
trap '((has_teardown)) && teardown' EXIT
287
288
# NOTE: we do *not* want to use the || or && syntax with the subshell
0 commit comments