In particular, move all test preparations inside test_expect_success. In a subsequent patch, we are going to move test case path3 out of the loop of test cases. Use this opportunity to linearize the tests. Signed-off-by: Johannes Sixt <j6t@xxxxxxxx> --- t/t2100-update-cache-badpath.sh | 81 ++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/t/t2100-update-cache-badpath.sh b/t/t2100-update-cache-badpath.sh index 2df3fdd..a3f9255 100755 --- a/t/t2100-update-cache-badpath.sh +++ b/t/t2100-update-cache-badpath.sh @@ -24,38 +24,51 @@ All of the attempts should fail. . ./test-lib.sh -mkdir path2 path3 -date >path0 -if test_have_prereq SYMLINKS -then - ln -s xyzzy path1 -else - date > path1 -fi -date >path2/file2 -date >path3/file3 - -test_expect_success \ - 'git update-index --add to add various paths.' \ - 'git update-index --add -- path0 path1 path2/file2 path3/file3' - -rm -fr path? - -mkdir path0 path1 -date >path2 -if test_have_prereq SYMLINKS -then - ln -s frotz path3 -else - date > path3 -fi -date >path0/file0 -date >path1/file1 - -for p in path0/file0 path1/file1 path2 path3 -do - test_expect_success \ - "git update-index to add conflicting path $p should fail." \ - "test_must_fail git update-index --add -- $p" -done +test_expect_success 'git update-index --add to add various paths' ' + + mkdir path2 path3 && + date >path0 && + if test_have_prereq SYMLINKS + then + ln -s xyzzy path1 + else + date >path1 + fi && + date >path2/file2 && + date >path3/file3 && + test_when_finished "rm -fr path0 path1 path2 path3" && + git update-index --add -- path0 path1 path2/file2 path3/file3 +' + +test_expect_success 'git update-index to add conflicting path path0/file0 should fail' ' + + mkdir path0 && + date >path0/file0 && + test_must_fail git update-index --add -- path0/file0 +' + +test_expect_success 'git update-index to add conflicting path path1/file1 should fail' ' + + mkdir path1 && + date >path1/file1 && + test_must_fail git update-index --add -- path1/file1 +' + +test_expect_success 'git update-index to add conflicting file path2 should fail' ' + + date >path2 && + test_must_fail git update-index --add -- path2 +' + +test_expect_success 'git update-index to add conflicting symlink path3 should fail' ' + + if test_have_prereq SYMLINKS + then + ln -s xyzzy path3 + else + date >path3 + fi && + test_must_fail git update-index --add -- path3 +' + test_done -- 1.8.3.rc1.32.g8b61cbb -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html