~ chicken-core (chicken-5) 708456bc180e5816a6c94121e9f31b789ca5aef4


commit 708456bc180e5816a6c94121e9f31b789ca5aef4
Author:     Evan Hanson <evhan@foldling.org>
AuthorDate: Mon Jan 16 14:43:52 2017 +1300
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Tue Jan 17 07:47:43 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.

diff --git a/tests/runtests.sh b/tests/runtests.sh
index 164c1f4f..7c9fc2b6 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -87,11 +87,19 @@ 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 || :`
 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}"
 interpret="../csi -n -include-path ${TEST_DIR}/.."
+time=time
+
+# 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',
+# `command', etc. NOTE "time" must be called from a variable here.
+set +e
+$time true >/dev/null 2>/dev/null
+test $? -eq 127 && time=
+set -e
 
 rm -f *.exe *.so *.o *.import.* a.out ../foo.import.*
 
Trap