[PATCH] Change in increment_mtime for BSD compatibility of test suite

Felix Geller fgeller at gmail.com
Wed May 25 06:07:52 PDT 2011


Use `-t' option rather than `-d' which is not supported by BSD's
touch. I'm not sure whether this is the cleanest way to do this, please
let me know if there is a better way. There are additional changes
(e.g., sed does not support `-r' but instead `-E') but they seem to be
incompatible between GNU and BSD. What's the recommended way to handle
this?

Cheers,
Felix


diff --git a/test/test-lib.sh b/test/test-lib.sh
index f536172..d2af857 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -218,9 +218,10 @@ increment_mtime_amount=0
 increment_mtime ()
 {
     dir="$1"
-
+    last_mod_date=`date -j -f %Y%m%d%H%M%S \`stat -f %Sm -t %Y%m%d%H%M%S ${dir}\` +%s`
     increment_mtime_amount=$((increment_mtime_amount + 1))
-    touch -d "+${increment_mtime_amount} seconds" "$dir"
+    new_date=`date -j -r ${last_mod_date} -v+${increment_mtime_amount}S +%Y%m%d%H%M.%S`
+    touch -t ${new_date} ${dir}
 }
 
 # Generate a new message in the mail directory, with a unique message
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 202 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20110525/3c4d9478/attachment.pgp>


More information about the notmuch mailing list