]> git.notmuchmail.org Git - notmuch/commitdiff
tests: add compatibility layer
authorMikhail <mp39590@gmail.com>
Thu, 9 Mar 2017 13:32:43 +0000 (09:32 -0400)
committerDavid Bremner <david@tethera.net>
Sat, 25 Mar 2017 10:56:52 +0000 (07:56 -0300)
Make test-lib-common.sh load test-lib-<$PLATFORM>.sh to create
additional shim for platform specifics.

Use test-lib-FREEBSD.sh to call GNU utilities instead of native ones.

- amended by db following Tomi's suggestions

configure
test/README
test/test-lib-FREEBSD.sh [new file with mode: 0644]
test/test-lib-common.sh

index 6c782e16d5a63a746e3b49691bcc398fcb7f63cd..03131275a241c41098ba40e5b5f73fb152599dd4 100755 (executable)
--- a/configure
+++ b/configure
@@ -1199,6 +1199,9 @@ NOTMUCH_PYTHON=${python}
 # Are the ruby development files (and ruby) available? If not skip
 # building/testing ruby bindings.
 NOTMUCH_HAVE_RUBY_DEV=${have_ruby_dev}
+
+# Platform we are run on
+PLATFORM=${platform}
 EOF
 
 # Finally, after everything configured, inform the user how to continue.
index dcd05237a0623c859af0ae67e033994137dd0d54..f2499bce780bdda3ae1c17242aab4f00d9ad8252 100644 (file)
@@ -33,6 +33,17 @@ chosen directory to your PATH before running the tests.
 
 e.g. env PATH=/opt/gnu/bin:$PATH make test
 
+For FreeBSD you need to install latest gdb from ports or packages and
+provide path to it in TEST_GDB environment variable before executing
+the tests, native FreeBSD gdb does not not work.  If you install
+coreutils, which provides GNU versions of basic utils like 'date' and
+'base64' on FreeBSD, the test suite will use these instead of the
+native ones. This provides robustness against portability issues with
+these system tools. Most often the tests are written, reviewed and
+tested on Linux system so such portability issues arise from time to
+time.
+
+
 Running Tests
 -------------
 The easiest way to run tests is to say "make test", (or simply run the
diff --git a/test/test-lib-FREEBSD.sh b/test/test-lib-FREEBSD.sh
new file mode 100644 (file)
index 0000000..d1840b5
--- /dev/null
@@ -0,0 +1,9 @@
+# If present, use GNU Coreutils instead of a native BSD utils
+if command -v gdate >/dev/null
+   then
+       date () { gdate "$@"; }
+       base64 () { gbase64 "$@"; }
+       wc () { gwc "$@"; }
+       sed () { gsed "$@"; }
+       sha256sum () { gsha256sum "$@"; }
+   fi
index a96cfbeba019c081ef0f164ddffaad90561f06f3..ef409171fa86d547f43d5b940c7afd6e98d5b08d 100644 (file)
@@ -66,6 +66,11 @@ export LD_LIBRARY_PATH
 # configure output
 . $notmuch_path/sh.config || exit 1
 
+# load OS specifics
+if [ -e ./test-lib-$PLATFORM.sh ]; then
+       . ./test-lib-$PLATFORM.sh || exit 1
+fi
+
 if test -n "$valgrind"
 then
        make_symlink () {