@matheusbsbs / matheus-bagliano / commits / 016e5ff243
Fork 0

war on "sleep" in tests

In many places in test suite we have "sleep"s that do not have to be there. - I do not simply see the point of the one in t3500. It may be making sure that the timestamp order of commits generated during the test is stable, in which case test_tick is the right ingredient to use without wasting tester's time. - The one in t4011 is to make sure that the plumbing diff-index notices the stat-dirtyness of a removed then identically recreated symlink. Keeping the old symlink around to make sure that a newly created symlink gets different ino would be sufficient for that purpose. - The one in t7600 is to make sure that "git merge" does not get confused by stat-dirty "file" in the working tree. Again, keeping the old file around and creating an identical copy to ensure a different ino would be sufficient for that purpose. The "racy git" tests in t0010 are inherently about mtime between the index itself and index entries. The "sleep" in that test must stay as they are. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Apr 6, 2010 at 17:08 UTC 016e5ff24345f974a084375da83ee143b5f2772d
3 files changed +7 -6
t/t3500-cherry.sh
+4 -1
@@ -17,17 +17,19 @@ test_expect_success \
17 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
18 'echo First > A &&
19 git update-index --add A &&
20 + test_tick &&
21 git commit -m "Add A." &&
22
23 git checkout -b my-topic-branch &&
24
25 echo Second > B &&
26 git update-index --add B &&
27 + test_tick &&
28 git commit -m "Add B." &&
29
28 - sleep 2 &&
30 echo AnotherSecond > C &&
31 git update-index --add C &&
32 + test_tick &&
33 git commit -m "Add C." &&
34
35 git checkout -f master &&
@@ -35,6 +37,7 @@ test_expect_success \
37
38 echo Third >> A &&
39 git update-index A &&
40 + test_tick &&
41 git commit -m "Modify A." &&
42
43 expr "$(echo $(git cherry master my-topic-branch) )" : "+ [^ ]* + .*"
t/t4011-diff-symlink.sh
+2 -3
@@ -54,7 +54,7 @@ EOF
54
55 test_expect_success \
56 'diff removed symlink' \
57 - 'rm frotz &&
57 + 'mv frotz frotz2 &&
58 git diff-index -M -p $tree > current &&
59 compare_diff_patch current expected'
60
@@ -64,8 +64,7 @@ EOF
64
65 test_expect_success \
66 'diff identical, but newly created symlink' \
67 - 'sleep 3 &&
68 - ln -s xyzzy frotz &&
67 + 'ln -s xyzzy frotz &&
68 git diff-index -M -p $tree > current &&
69 compare_diff_patch current expected'
70
t/t7600-merge.sh
+1 -2
@@ -554,8 +554,7 @@ test_debug 'gitk --all'
554
555 test_expect_success 'refresh the index before merging' '
556 git reset --hard c1 &&
557 - sleep 1 &&
558 - touch file &&
557 + cp file file.n && mv -f file.n file &&
558 git merge c3
559 '
560