[PATCH STABLE] test-fix: fix use of 'f --newer' to check that foo.whole is not updated
Matt Harbison
mharbison72 at gmail.com
Mon Apr 23 02:32:06 UTC 2018
On Thu, 19 Apr 2018 09:54:02 -0400, Yuya Nishihara <yuya at tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1524143530 -32400
> # Thu Apr 19 22:12:10 2018 +0900
> # Branch stable
> # Node ID 769bd30988035d0c802cd5c8acaece16ebb3d024
> # Parent 3866a9af240cc01e5eab12ffeac668f61cfa2a13
> test-fix: fix use of 'f --newer' to check that foo.whole is not updated
>
> Here we want to assert not 'mtime(foo.whole.orig) < mtime(foo.whole)'.
> The condition has to be inverted since 'f --newer' says "newer" if the
> mtimes match.
>
> Alternatively, we could insert 'sleep 2' before 'cp' to ensure that
> foo.whole.orig is newer than foo.whole, but a fewer sleeps should be
> better.
This fails on Windows. I added code to `f` to print st_mtime, and got
results (with `cp -p`) like:
foo.whole foo.whole.orig
1524449468.91 1524449469.0
1524449707.08 1524449707.0
Should `f` be rounding to a whole number before comparing? Seems not
great, but if tests already have to delay 2 seconds for some filesystems,
it doesn't seem unreasonable.
> diff --git a/tests/test-fix.t b/tests/test-fix.t
> --- a/tests/test-fix.t
> +++ b/tests/test-fix.t
> @@ -493,11 +493,11 @@ write back to the file, so for example t
> $ printf "NO FIX NEEDED\n" > foo.whole
> $ hg add
> adding foo.whole
> - $ cp foo.whole foo.whole.orig
> + $ cp -p foo.whole foo.whole.orig
> $ sleep 2 # mtime has a resolution of one or two seconds.
> $ hg fix --working-dir
> - $ f foo.whole --newer foo.whole.orig
> - foo.whole: older than foo.whole.orig
> + $ f foo.whole.orig --newer foo.whole
> + foo.whole.orig: newer than foo.whole
> $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list