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

login
register
mail settings
Submitter Augie Fackler
Date July 16, 2015, 4:07 p.m.
Message ID <3cf16ed00c9ffabfc1a5.1437062866@imladris.local>
Download mbox | patch
Permalink /patch/10008/
State Accepted
Headers show

Comments

Augie Fackler - July 16, 2015, 4:07 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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