Skip to content

Commit

Permalink
Make sure the final cleanup always runs
Browse files Browse the repository at this point in the history
Even if the test exits in the middle, which for example happens in
interactive mode.

Signed-off-by: Felipe Contreras <[email protected]>
  • Loading branch information
felipec committed Apr 24, 2024
1 parent 4e8a0a2 commit 86e4ea0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions sharness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export SHARNESS_TEST_NB

die() {
code=$?
test_eval_ "$final_cleanup"
if test -n "$EXIT_OK"; then
exit $code
else
Expand Down Expand Up @@ -649,8 +650,6 @@ test_done() {
fi
say "1..$SHARNESS_TEST_NB$skip_all"

test_eval_ "$final_cleanup"

remove_trash_

exit 0 ;;
Expand All @@ -659,8 +658,6 @@ test_done() {
say_color error "# failed $test_failure among $msg"
say "1..$SHARNESS_TEST_NB"

test_eval_ "$final_cleanup"

exit 1 ;;

esac
Expand Down
1 change: 1 addition & 0 deletions test/sharness.t
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ test_expect_success 'cleanup functions run even on failure' "
> \"$HOME\"/dont-clean-final &&
(exit 1)
'
exit 1
test_done
EOF
test -e dont-clean-final &&
Expand Down

0 comments on commit 86e4ea0

Please sign in to comment.