[PATCH] tests: add compatibility layer

Tomi Ollila tomi.ollila at iki.fi
Sat Dec 31 07:17:41 PST 2016


On Thu, Dec 22 2016, mp39590 at gmail.com wrote:

> From: Mikhail <mp39590 at gmail.com>
>
> 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.


I've been slow to respond, mostly busy, partly checking some freebsd
facts...

The patch is mostly good, but there are a few issues i am going to
mention a bit later -- now I just have few minutes...

IIRC you're a freebsd port maintainer and would like to have more
certainty that every new test patch doesn't break your test.
In general we desire more portability overall e.g. things work on
linux, *bsd, macos, solaris...

But, for now I'd like you to test the following script which
I named `make-test-freesd.sh` (well, that could also work on many other
OSses) and tell why it would not work ;) ... in that there is one hint
how the patch should be improved :D

run it instead of `gmake test` in notmuch source directory.


Tomi



--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
#!/usr/bin/env bash

set -euf -o posix

SHELL=`command -v bash`
export SHELL

mkwrp () {
	command -v "$2" >/dev/null || return 0
	eval "$1 () { $2 \"\$@\"; }"
	export -f $1
}

mkwrp date gdate
mkwrp base64 gbase64
mkwrp gdb "$NOTMUCH_GDB"
mkwrp wc gwc
mkwrp sha256sum gsha256sum

set -x
exec gmake test
--8<----8<----8<----8<----8<----8<----8<----8<----8<--


> ---
>  configure                | 3 +++
>  test/README              | 6 ++++++
>  test/test-lib-FREEBSD.sh | 8 ++++++++
>  test/test-lib-common.sh  | 5 +++++
>  4 files changed, 22 insertions(+)
>  create mode 100644 test/test-lib-FREEBSD.sh
>
> diff --git a/configure b/configure
> index 72db26df..7ba9b9eb 100755
> --- a/configure
> +++ b/configure
> @@ -1203,6 +1203,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.
> diff --git a/test/README b/test/README
> index 104a120e..094e1d33 100644
> --- a/test/README
> +++ b/test/README
> @@ -33,6 +33,12 @@ chosen directory to your PATH before running the tests.
>  
>  e.g. env PATH=/opt/gnu/bin:$PATH make test
>  
> +For FreeBSD you will need to install coreutils, which provides GNU
> +versions of basic utils like 'date' or 'wc'. Also you will need to
> +install latest gdb from ports or packages and provide path to it in
> +BSD_GDB variable before executing the tests, native FreeBSD gdb will not
> +work.
> +
>  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
> index 00000000..24079689
> --- /dev/null
> +++ b/test/test-lib-FREEBSD.sh
> @@ -0,0 +1,8 @@
> +# Use GNU Coreutils instead of a native BSD utils
> +
> +date () { gdate "$@"; }
> +base64 () { gbase64 "$@"; }
> +gdb () { $BSD_GDB "$@"; }
> +wc () { gwc "$@"; }
> +sed () { gsed "$@"; }
> +sha256sum () { gsha256sum "$@"; }
> diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
> index 03ef1d2d..1c8d7f6e 100644
> --- a/test/test-lib-common.sh
> +++ b/test/test-lib-common.sh
> @@ -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
> +fi
> +
>  if test -n "$valgrind"
>  then
>  	make_symlink () {
> -- 
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list