From: Jonathan Nieder Date: Wed, 08 Jan 2014 22:01:19 GMT Subject: Re: [PATCH] merge: make merge state available to prepare-commit-msg hook Message-ID: <20140108220119.GN3881@google.com> In-Reply-To: Matthieu Moy wrote: > Jonathan's answer is an option. Another one is [...] > So if the cleanup goes wrong, one can notice. test_when_finished also makes the test fail if the cleanup failed. Another common strategy is test_expect_success 'my exciting test' ' # this test will rely on these files being absent rm -f a b c etc && ... rest of the test goes here ... ' which can be a handy way for an especially picky test to protect itself (for example with 'git clean -fdx') regardless of the state other test assertions create for it. This particular example (merge --abort) seems like a good use for test_when_finished because it is about a specific test having made a mess and needing to clean up after itself to restore sanity. Hoping that clarifies, Jonathan