Patchwork D11900: tests: add a short `sleep` in test-status.t

login
register
mail settings
Submitter phabricator
Date Dec. 10, 2021, 10:14 p.m.
Message ID <differential-rev-PHID-DREV-7j372z7gjmyw6t5loyhv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50225/
State New
Headers show

Comments

phabricator - Dec. 10, 2021, 10:14 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  With dirstate-v2 and rhg both enabled, this test would sometimes fail for me
  with:
  
    --- tests/test-status.t
    +++ tests/test-status.t#dirstate-v2.err
    @@ -943,7 +943,7 @@
       $ rm subdir/unknown
       $ hg status
       $ hg debugdirstate --all --no-dates | grep '^ '
    -      0         -1 set                 subdir
    +      0         -1 unset               subdir
  
  Meaning that `status` did not write a directory mtime in the dirstate
  as expected. This can happen if the observed mtime of the directory is
  the same as "current time" at the start of `status`. This current time
  is obtained by creating a temporary file and checking its mtime.
  
  Even with ext4 on my system being able to store nanosecond precision,
  identical mtime for successive but separate operations is still possible
  becuse the kernel may cache the current time:
  https://stackoverflow.com/a/14393315/1162888
  
  0.1 second should be enough for this cache to be updated, without
  significantly slowing down the test.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11900

AFFECTED FILES
  tests/test-status.t

CHANGE DETAILS




To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -941,6 +941,7 @@ 
 Now the directory is eligible for caching, so its mtime is save in the dirstate
 
   $ rm subdir/unknown
+  $ sleep 0.1 # ensure the kernel’s internal clock for mtimes has ticked
   $ hg status
   $ hg debugdirstate --all --no-dates | grep '^ '
       0         -1 set                 subdir