Subject: Re: "test_atexit" v.s. "test_when_finished"

From: Junio C Hamano <[email-masked]>
Date: Fri, 09 Dec 2022 13:46:04 +0900

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

> On failure we'll skip the cleanup for the current test that just failed,
> but we're not distracted by scratch files from earlier tests, those
> would have already been cleaned up if they used the same
> "test_when_finished" pattern.

Yup.

A big benefit of using test_when_finished is that the knowledge of
what cruft needs to be cleaned is isolated to the exact test piece
that would create the cruft.  Instead of test_when_finished, We
could use the other convention to clear what others may have left
behind to give yourself a clean slate, but that requires you to be
aware of what other tests that came before you did, which will
change over time and will add to the maintenance burden.  And to
some degree, the same downside is shared by the approach to use
test_atexit.