Skip to content

Commit df126ca

Browse files
sunshinecogitster
authored andcommitted
t3400: make test clean up after itself
This test intentionally creates a file which causes rebase to fail, thus it is important that this file be deleted before subsequent tests are run which are not expecting such a failure. In the past, the common way to ensure cleanup (regardless of whether the test succeeded or failed) was either for the next test to perform the previous test's cleanup as its first step or to do the cleanup at global scope outside of any tests. With the introduction of 'test_when_finished', however, tests can be responsible for their own cleanup. Therefore, update this test to clean up after itself. A bit of history: This 'rm' invocation was moved from within the body of the following test to global scope by bffd750 (rebase: improve error message when upstream argument is missing, 2010-05-31), which postdates, by about a month, introduction of 'test_when_finished' in 3bf7886 (test-lib: Let tests specify commands to be run at end of test, 2010-05-02). Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0654dc commit df126ca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

t/t3400-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ test_expect_success 'setup: recover' '
143143

144144
test_expect_success 'Show verbose error when HEAD could not be detached' '
145145
>B &&
146+
test_when_finished "rm -f B" &&
146147
test_must_fail git rebase topic 2>output.err >output.out &&
147148
test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" output.err &&
148149
test_i18ngrep B output.err
149150
'
150-
rm -f B
151151

152152
test_expect_success 'fail when upstream arg is missing and not on branch' '
153153
git checkout topic &&

0 commit comments

Comments
 (0)