[PATCH 2 of 3 remotefilelog-test-fixes] test-gc: work around lack of -d on BSD touch

raf at durin42.com raf at durin42.com
Thu Jul 16 11:07:46 CDT 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1437062797 14400
#      Thu Jul 16 12:06:37 2015 -0400
# Node ID 3cf16ed00c9ffabfc1a594fbc37975f598a69fc4
# Parent  9be47eb79109b37830f5a200f182a6a485a05232
test-gc: work around lack of -d on BSD touch

touch -t is portable, but requires some computation to get a date
value that's a week ago. A Python oneliner is a little goofy, but
seemed like a straightforward enough answer that I chose that.

diff --git a/tests/test-gc.t b/tests/test-gc.t
--- a/tests/test-gc.t
+++ b/tests/test-gc.t
@@ -29,7 +29,8 @@
 
 # gc client cache
 
-  $ find $CACHEDIR -type f -exec touch -d "last week" {} \;
+  $ lastweek=`python -c 'import datetime,time; print datetime.datetime.fromtimestamp(time.time() - (86400 * 7)).strftime("%y%m%d%H%M")'`
+  $ find $CACHEDIR -type f -exec touch -t $lastweek {} \;
 
   $ find $CACHEDIR -type f | wc -l
   3


More information about the Mercurial-devel mailing list