Skip to content
run-tests.sh 5.22 KiB
Newer Older
Daniel Barlow's avatar
Daniel Barlow committed
#!/bin/sh

# do_tests {lisp invocation} {scripts-regex}
# - read lisp forms one at a time from standard input
# - quit with exit status 0 on getting eof
# - quit with exit status >0 if an unhandled error occurs

usage () {
    echo "$0 [lisp invocation] [scripts-regex]"
    echo " - read lisp forms one at a time from matching scripts"
    echo " - quit with exit status 0 on getting eof"
    echo " - quit with exit status >0 if an unhandled error occurs"
    echo " you need to supply the .script in the second argument"
    echo " lisps include abcl, allegro, allegromodern, ccl (clozure),"
    echo "  clisp, cmucl, ecl, gclcvs, sbcl, and scl."
    echo "OPTIONS:"
    echo "    -d -- debug mode"
    echo "    -u -h -- show this message."
}

Robert P. Goldman's avatar
 
Robert P. Goldman committed

while getopts "duh" OPTION
do
Robert P. Goldman's avatar
 
Robert P. Goldman committed
        d)
Robert P. Goldman's avatar
 
Robert P. Goldman committed
            ;;
        u)
            usage
            exit 1
            ;;
        h)
            usage
            exit 1
            ;;
    esac
done
shift $(($OPTIND - 1))
Robert P. Goldman's avatar
 
Robert P. Goldman committed
    usage
    exit 1
lisp=${1:-sbcl} ; shift
    scripts="*.script"
else
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
DO () { ( set -x ; "$@" ); }

  command="$1" eval="$2"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
  ( cd .. && DO $command $eval '(load "test/compile-asdf.lisp")' )
  if [ $? -ne 0 ] ; then
    echo "Compilation FAILED" >&2
  else
    echo "Compiled OK" >&2
    test_count=0
    test_pass=0
    test_fail=0
    failed_list=""
      echo "Testing: $i" >&2
      test_count=`expr "$test_count" + 1`
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
      if DO $command $eval "(load \"$i\")" ; then
        echo "Using $command, $i passed" >&2
	test_pass=`expr "$test_pass" + 1`
      else
        echo "Using $command, $i failed" >&2
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
    echo "-#---------------------------------------" >&2
    echo "Using $command" >&2
    echo "Ran $test_count tests: " >&2
    echo "  $test_pass passing and $test_fail failing" >&2
    if [ $test_fail -eq 0 ] ; then
	echo "all tests apparently successful" >&2
        echo success > ../tmp/results/status
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
    echo "-#---------------------------------------" >&2
command= flags= nodebug= eval=
case "$lisp" in
    flags="--noinit --nosystem --noinform"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${ALLEGRO:-alisp}"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${ALLEGROMODERN:-mlisp}"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${CCL:-ccl}"
    flags="--no-init --quiet"
    nodebug="--batch"
    eval="--eval" ;;
  clisp)
    command="${CLISP:-clisp}"
    flags="-norc -ansi -I "
    nodebug="-on-error exit"
    eval="-x" ;;
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${CMUCL:-lisp}"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${ECL:-ecl}"
    flags="-norc -load sys:cmp"
    eval="-eval" ;;
  ecl-bytecodes)
    command="${ECL:-ecl}"
    flags="-norc -eval (ext::install-bytecodes-compiler)"
  gclcvs)
    export GCL_ANSI=t
    command="${GCL:-gclcvs}"
    flags="-batch"
    eval="-eval" ;;
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
    command="${LISPWORKS:-lispworks}"
    # If you have a licensed copy of lispworks,
    # you can obtain the "lispworks" binary with, e.g.
    # echo '(hcl:save-image "/lispworks" :environment nil)' > /tmp/build.lisp ;
    # ./lispworks-6-0-0-x86-linux -siteinit - -init - -build /tmp/build.lisp
  sbcl)
    command="${SBCL:-sbcl}"
    flags="--noinform --userinit /dev/null --sysinit /dev/null"
    nodebug="--disable-debugger"
  scl)
    command="${SCL:-scl}"
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
  xcl)
    command="${XCL:-xcl}"
    flags="--no-userinit --no-siteinit"
    eval="--eval" ;;
  *)
    echo "Unsupported lisp: $1" >&2
    echo "Please add support to run-tests.sh" >&2
    exit 42 ;;
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
ASDFDIR="$(cd .. ; /bin/pwd)"
export CL_SOURCE_REGISTRY="${ASDFDIR}"
export ASDF_OUTPUT_TRANSLATIONS="(:output-translations (\"${ASDFDIR}\" (\"${ASDFDIR}/tmp/fasls\" :implementation)) :ignore-inherited-configuration)"
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
env | grep asdf

command="$command $flags"
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

Francois-Rene Rideau's avatar
Francois-Rene Rideau committed

create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
Gary King's avatar
Gary King committed
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
    echo failure > ../tmp/results/status
Gary King's avatar
Gary King committed
    thedate=`date "+%Y-%m-%d"`
	tee "../tmp/results/${lisp}.text" "../tmp/results/${lisp}-${thedate}.save"
    read a < ../tmp/results/status
    [ success = "$a" ] ## exit code