~ chicken-core (chicken-5) a559bb2e4ccb2da71df2f2df4ad2d50ed582f3ff
commit a559bb2e4ccb2da71df2f2df4ad2d50ed582f3ff
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Mon Jan 16 14:43:52 2017 +1300
Commit: Evan Hanson <evhan@foldling.org>
CommitDate: Tue Jan 17 08:15:47 2017 +1300
Make "time" command detection more robust in tests
This is a better way of checking for a "time" command: we just call it
and check for an exit status of 127 (i.e. command not found).
Note that `time' must be called through a variable during this check.
Otherwise, the Cygwin shell will use its builtin for the test, but not
later in the script when it's called as "$time", causing an error.
Signed-off-by: Evan Hanson <evhan@foldling.org>
diff --git a/tests/runtests.sh b/tests/runtests.sh
index ab65cf4b..f61b4ef6 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -63,12 +63,20 @@ SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"csi\" (make-pathname ${TEST
TYPESDB=../types.db
cp $TYPESDB test-repository/types.db
-time=`command >/dev/null -v time && echo time || :`
+time=time
compile="../csc -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -o a.out"
compile2="../csc -compiler $CHICKEN -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
interpret="../csi -n -include-path ${TEST_DIR}/.."
+# Check for a `time' command, since some systems don't ship with a
+# time(1) or shell builtin and we also can't portably rely on which(1),
+# etc. NOTE `time' must be called from a variable here.
+set +e
+$time true >/dev/null 2>/dev/null
+if [ $? -eq 127 ]; then time=; fi
+set -e
+
rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
echo "======================================== version tests ..."
Trap