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 7495e45 commit b6de2bbCopy full SHA for b6de2bb
1 file changed
bash_unit
@@ -276,15 +276,15 @@ run_tests() {
276
notify_test_skipped "$skipped_test"
277
done
278
279
+ local has_setup=0 has_teardown=0
280
+ declare -F | "$GREP" ' setup$' >/dev/null && has_setup=1
281
+ declare -F | "$GREP" ' teardown$' >/dev/null && has_teardown=1
282
+
283
for test in $tests_to_run
284
do
285
(
286
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.
287
- declare -F | "$GREP" ' teardown$' >/dev/null && has_teardown=1
+ ((has_setup)) && setup
288
trap '((has_teardown)) && teardown' EXIT
289
290
# NOTE: we do *not* want to use the || or && syntax with the subshell
0 commit comments