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,'