{"thread":{"id":"23364","subject":"[RFC] war on \"sleep\" in tests","startedAt":"2010-04-07T00:08:54Z","lastAt":"2010-04-07T00:08:54Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"138790","messageId":"7vfx38gm3t.fsf@alter.siamese.dyndns.org","threadId":"23364","inReplyTo":null,"subject":"[RFC] war on \"sleep\" in tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-07T00:08:54Z","receivedAt":"2010-04-07T00:08:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"In many places in test suite we have \"sleep\"s that do not have to be\nthere.\n\n - I do not simply see the point of the one in t3500.  It may be making\n   sure that the timestamp order of commits generated during the test is\n   stable, in which case test_tick is the right ingredient to use without\n   wasting tester's time.\n\n - The one in t4011 is to make sure that the plumbing diff-index notices\n   the stat-dirtyness of a removed then identically recreated symlink.\n   Keeping the old symlink around to make sure that a newly created\n   symlink gets different ino would be sufficient for that purpose.\n\n - The one in t7600 is to make sure that \"git merge\" does not get confused\n   by stat-dirty \"file\" in the working tree.  Again, keeping the old file\n   around and creating an identical copy to ensure a different ino would\n   be sufficient for that purpose.\n\nThe \"racy git\" tests in t0010 are inherently about mtime between the index\nitself and index entries.  The \"sleep\" in that test must stay as they are.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n t/t3500-cherry.sh       |    5 ++++-\n t/t4011-diff-symlink.sh |    5 ++---\n t/t7600-merge.sh        |    3 +--\n 3 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh\nindex dadbbc2..f038f34 100755\n--- a/t/t3500-cherry.sh\n+++ b/t/t3500-cherry.sh\n@@ -17,17 +17,19 @@ test_expect_success \\\n     'prepare repository with topic branch, and check cherry finds the 2 patches from there' \\\n     'echo First > A &&\n      git update-index --add A &&\n+     test_tick &&\n      git commit -m \"Add A.\" &&\n \n      git checkout -b my-topic-branch &&\n \n      echo Second > B &&\n      git update-index --add B &&\n+     test_tick &&\n      git commit -m \"Add B.\" &&\n \n-     sleep 2 &&\n      echo AnotherSecond > C &&\n      git update-index --add C &&\n+     test_tick &&\n      git commit -m \"Add C.\" &&\n \n      git checkout -f master &&\n@@ -35,6 +37,7 @@ test_expect_success \\\n \n      echo Third >> A &&\n      git update-index A &&\n+     test_tick &&\n      git commit -m \"Modify A.\" &&\n \n      expr \"$(echo $(git cherry master my-topic-branch) )\" : \"+ [^ ]* + .*\"\ndiff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh\nindex d7e327c..e12fbea 100755\n--- a/t/t4011-diff-symlink.sh\n+++ b/t/t4011-diff-symlink.sh\n@@ -54,7 +54,7 @@ EOF\n \n test_expect_success \\\n     'diff removed symlink' \\\n-    'rm frotz &&\n+    'mv frotz frotz2 &&\n     git diff-index -M -p $tree > current &&\n     compare_diff_patch current expected'\n \n@@ -64,8 +64,7 @@ EOF\n \n test_expect_success \\\n     'diff identical, but newly created symlink' \\\n-    'sleep 3 &&\n-    ln -s xyzzy frotz &&\n+    'ln -s xyzzy frotz &&\n     git diff-index -M -p $tree > current &&\n     compare_diff_patch current expected'\n \ndiff --git a/t/t7600-merge.sh b/t/t7600-merge.sh\nindex 57f6d2b..cde8390 100755\n--- a/t/t7600-merge.sh\n+++ b/t/t7600-merge.sh\n@@ -554,8 +554,7 @@ test_debug 'gitk --all'\n \n test_expect_success 'refresh the index before merging' '\n \tgit reset --hard c1 &&\n-\tsleep 1 &&\n-\ttouch file &&\n+\tcp file file.n && mv -f file.n file &&\n \tgit merge c3\n '\n \n"}]}