From: Felix Geller <fgeller@gmail.com>
To: Carl Worth <cworth@cworth.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH] Change in increment_mtime for BSD compatibility of test suite
Date: Mon, 30 May 2011 14:40:04 +0200 [thread overview]
Message-ID: <m21uzgfjkr.fsf@gmail.com> (raw)
In-Reply-To: <87boypcdrw.fsf@yoom.home.cworth.org>
[-- Attachment #1: Type: text/plain, Size: 5531 bytes --]
Another try :)
[...]
Support for platform-specific test configuration
- Platform-specific functionality is stored in test-config-PLATFORM.sh files
- configure script creates a test/test-config.sh depending on the platform
- test-lib.sh loads test-config.sh file
- Some platform-specific functionality included for gnu/bsd:
- Work-around for touch -d on BSD
- Variable to store sed command for extended expressions
diff --git a/configure b/configure
index bbf30cd..053a4a1 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,13 @@ if [ "$srcdir" != "." ]; then
# whole thing into the build directory.
cp -a "$srcdir"/test/* test
+ # Platform specific test configuration
+ if [ $platform = MACOSX ] ; then
+ cp test/test-config-bsd.sh test/test-config.sh
+ else
+ cp test/test-config-gnu.sh test/test-config.sh
+ fi
+
# Emacs only likes to generate compiled files next to the .el files
# by default so copy these as well (which is not ideal0.
cp -a "$srcdir"/emacs/*.el emacs
diff --git a/test/basic b/test/basic
index 808c968..5fbedfe 100755
--- a/test/basic
+++ b/test/basic
@@ -54,13 +54,14 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'
eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test ../notmuch-test)
tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
available=$(ls -1 ../ | \
- sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \
- -e "/^(README|test-lib.sh|test-lib.el|test-results|tmp.*|valgrind|corpus*)/d" \
- -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \
- -e "/^(test.expected-output|.*~)/d" \
- -e "/^(gnupg-secret-key.asc)/d" \
- -e "/^(gnupg-secret-key.NOTE)/d" \
- | sort)
+ $SED_EXTENDED -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \
+ -e "/^(README|test-lib.sh|test-lib.el|test-results|tmp.*|valgrind|corpus*)/d" \
+ -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose)/d" \
+ -e "/^(test.expected-output|.*~)/d" \
+ -e "/^(gnupg-secret-key.asc)/d" \
+ -e "/^(gnupg-secret-key.NOTE)/d" \
+ -e "/^(test-config*)/d" \
+ | sort)
test_expect_equal "$tests_in_suite" "$available"
EXPECTED=../test.expected-output
diff --git a/test/test-config-bsd.sh b/test/test-config-bsd.sh
new file mode 100644
index 0000000..e35d2fa
--- /dev/null
+++ b/test/test-config-bsd.sh
@@ -0,0 +1,23 @@
+# This file contains helper functions and other values that are
+# require platform-specific functionality (e.g., differing between GNU
+# and BSD). The configure script is used to identify the appropriate
+# file for a given platform, and copies the file test-config-FOO.sh to
+# test-config.sh, where FOO is the respective platform (bsd or gnu).
+#
+# This file is BSD-specific.
+
+# Syntax for extended expressions
+SED_EXTENDED="sed -E"
+
+# There is no touch -d on BSD, therefore we have to use a more tedious
+# version that uses date/stat to increment a date by a single second.
+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))
+ new_date=`date -j -r ${last_mod_date} -v+${increment_mtime_amount}S +%Y%m%d%H%M.%S`
+ touch -t ${new_date} ${dir}
+}
diff --git a/test/test-config-gnu.sh b/test/test-config-gnu.sh
new file mode 100644
index 0000000..596505a
--- /dev/null
+++ b/test/test-config-gnu.sh
@@ -0,0 +1,20 @@
+# This file contains helper functions and other values that are
+# require platform-specific functionality (e.g., differing between GNU
+# and BSD). The configure script is used to identify the appropriate
+# file for a given platform, and copies the file test-config-FOO.sh to
+# test-config.sh, where FOO is the respective platform (bsd or gnu).
+#
+# This file is GNU-specific.
+
+# Syntax for extended expressions
+SED_EXTENDED="sed -r"
+
+# Use touch to increment the modification date by a single second.
+increment_mtime_amount=0
+increment_mtime ()
+{
+ dir="$1"
+
+ increment_mtime_amount=$((increment_mtime_amount + 1))
+ touch -d "+${increment_mtime_amount} seconds" "$dir"
+}
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 922b1ef..1aa3a1c 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -23,6 +23,9 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
exit 1
fi
+# Load platform-specific values
+. ./test-config.sh
+
# if --tee was passed, write the output not only to the terminal, but
# additionally to the file test-results/$BASENAME.out, too.
case "$GIT_TEST_TEE_STARTED, $* " in
@@ -214,14 +217,6 @@ remove_cr () {
}
# Notmuch helper functions
-increment_mtime_amount=0
-increment_mtime ()
-{
- dir="$1"
-
- increment_mtime_amount=$((increment_mtime_amount + 1))
- touch -d "+${increment_mtime_amount} seconds" "$dir"
-}
# Generate a new message in the mail directory, with a unique message
# ID and subject. The message is not added to the index.
@@ -514,7 +509,7 @@ NOTMUCH_NEW ()
notmuch_search_sanitize ()
{
- sed -r -e 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
+ $SED_EXTENDED 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
}
NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
[-- Attachment #2: Type: application/pgp-signature, Size: 202 bytes --]
prev parent reply other threads:[~2011-05-30 12:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 13:07 [PATCH] Change in increment_mtime for BSD compatibility of test suite Felix Geller
2011-05-26 22:12 ` Carl Worth
2011-05-30 12:40 ` Felix Geller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m21uzgfjkr.fsf@gmail.com \
--to=fgeller@gmail.com \
--cc=cworth@cworth.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).