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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to