t7610: run 'git reset --hard' after each test to clean up
authorRichard Hansen <hansenr@google.com>
Tue, 10 Jan 2017 20:41:55 +0000 (15:41 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Jan 2017 21:22:20 +0000 (13:22 -0800)
Use test_when_finished to run 'git reset --hard' after each test so
that the repository is left in a saner state for the next test.

This is a step toward making the tests more independent so that if one
test fails it doesn't cause subsequent tests to fail.

Signed-off-by: Richard Hansen <hansenr@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7610-mergetool.sh
index 79545ec662083581e9cab6c1ae91cb0c3ae10058..df6b4c579c3a7b8bc9d6b28993074125b09eb9ca 100755 (executable)
@@ -127,6 +127,7 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'custom mergetool' '
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        test_must_fail git merge master >/dev/null 2>&1 &&
@@ -170,6 +171,7 @@ test_expect_success 'mergetool crlf' '
 '
 
 test_expect_success 'mergetool in subdir' '
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        (
@@ -181,6 +183,7 @@ test_expect_success 'mergetool in subdir' '
 '
 
 test_expect_success 'mergetool on file in parent dir' '
+       test_when_finished "git reset --hard" &&
        git reset --hard &&
        git submodule update -N &&
        (
@@ -214,6 +217,7 @@ test_expect_success 'mergetool skips autoresolved' '
 '
 
 test_expect_success 'mergetool merges all from subdir' '
+       test_when_finished "git reset --hard" &&
        test_config rerere.enabled false &&
        (
                cd subdir &&
@@ -244,6 +248,7 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' '
 '
 
 test_expect_success 'conflicted stash sets up rerere'  '
+       test_when_finished "git reset --hard" &&
        test_config rerere.enabled true &&
        git checkout stash1 &&
        echo "Conflicting stash content" >file11 &&
@@ -403,6 +408,7 @@ test_expect_success 'deleted vs modified submodule' '
 '
 
 test_expect_success 'file vs modified submodule' '
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        mv submod submod-movedaside &&
@@ -474,6 +480,7 @@ test_expect_success 'file vs modified submodule' '
 '
 
 test_expect_success 'submodule in subdirectory' '
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        git submodule update -N &&
        (
@@ -535,6 +542,7 @@ test_expect_success 'submodule in subdirectory' '
 '
 
 test_expect_success 'directory vs modified submodule' '
+       test_when_finished "git reset --hard" &&
        git checkout -b test$test_count branch1 &&
        mv submod submod-movedaside &&
        git rm --cached submod &&