Patchwork D3252: tests: use `f --newer` instead of `stat -c` in test-fix.t

login
register
mail settings
Submitter phabricator
Date April 11, 2018, 9:24 p.m.
Message ID <differential-rev-PHID-DREV-a23gcohmngf2qklk5ul7-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30744/
State Superseded
Headers show

Comments

phabricator - April 11, 2018, 9:24 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Also increase sleep to two seconds so this test will likely pass on FAT32.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-fix.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - April 13, 2018, 11:54 a.m.
yuja added inline comments.

INLINE COMMENTS

> test-fix.t:495
>    adding foo.whole
> -  $ OLD_MTIME=`stat -c %Y foo.whole`
> -  $ sleep 1 # mtime has a resolution of one second.
> +  $ cp foo.whole foo.whole.orig
> +  $ sleep 2 # mtime has a resolution of one or two seconds.

Maybe `cp -p` to not increment a few microseconds?

> test-fix.t:499
> +  $ f foo.whole --newer foo.whole.orig
> +  foo.whole: older than foo.whole.orig
>  

This means `mtime(foo.whole) < mtime(foo.whole.orig)`, but we
need to assert `mtime(foo.whole.orig) >= mtime(foo.whole)`.

REPOSITORY
  rHG Mercurial

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

To: durin42, #hg-reviewers, indygreg
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -492,11 +492,11 @@ 
   $ printf "NO FIX NEEDED\n" > foo.whole
   $ hg add
   adding foo.whole
-  $ OLD_MTIME=`stat -c %Y foo.whole`
-  $ sleep 1 # mtime has a resolution of one second.
+  $ cp foo.whole foo.whole.orig
+  $ sleep 2 # mtime has a resolution of one or two seconds.
   $ hg fix --working-dir
-  $ NEW_MTIME=`stat -c %Y foo.whole`
-  $ test $OLD_MTIME = $NEW_MTIME
+  $ f foo.whole --newer foo.whole.orig
+  foo.whole: older than foo.whole.orig
 
   $ cd ..