wisp
 
(Arne Babenhauserheide)
2017-09-19: provide realpath on OSX to get the tests to run

provide realpath on OSX to get the tests to run

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -44,5 +44,6 @@ AM_COND_IF([IS_MAKE_DISTCHECK], [AC_MSG_
 AM_INIT_AUTOMAKE([gnu])
 AM_MAINTAINER_MODE([enable])
 AC_CONFIG_FILES([Makefile])
+AC_CONFIG_LINKS([tests/realpath.sh:tests/realpath.sh])
 
 AC_OUTPUT
diff --git a/tests/realpath.sh b/tests/realpath.sh
new file mode 100755
--- /dev/null
+++ b/tests/realpath.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# realpath implementation for systems which lack it (like OSX)
+if command -v realpath 2>/dev/null 1>/dev/null; then
+    realpath "$@"
+elif command -v perl 2>/dev/null 1>/dev/null; then
+    perl -MCwd -le 'print Cwd::realpath($ARGV[0])' "$@"
+else # fallback, though not getting out of a/../a
+    [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
+fi
diff --git a/tests/runtests-scheme-reader.sh b/tests/runtests-scheme-reader.sh
--- a/tests/runtests-scheme-reader.sh
+++ b/tests/runtests-scheme-reader.sh
@@ -2,16 +2,20 @@
 
 # Simple test runner for wisp, mainly intended to be run by autotools.
 
+# FIXME: ./tests/realpath.sh currently encodes the path to the
+# command. AC_CONFIG_LINKS in autoconf.ac ensures that this exists in
+# the build dir. Still this could be nicer.
+
 if [[ x"$1" == x"" || x"$1" == x"." ]]; then
-    srcdir="$(realpath "$(pwd)")"
+    srcdir="$(./tests/realpath.sh "$(pwd)")"
 else
-    srcdir="$(realpath "$1")"
+    srcdir="$(./tests/realpath.sh "$1")"
 fi
 
 if [[ x"$2" == x"" || x"$2" == x"."  ]]; then
-    builddir="$(realpath $(pwd))"
+    builddir="$(./tests/realpath.sh $(pwd))"
 else
-    builddir="$(realpath "$2")"
+    builddir="$(./tests/realpath.sh "$2")"
 fi
 
 failed=0