run-tests.sh 3.79 KB
Newer Older
Daniel Barlow's avatar
Daniel Barlow committed
1 2
#!/bin/sh

3
# do_tests {lisp invocation} {scripts-regex}
4 5 6 7
# - 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

8
export CL_SOURCE_REGISTRY="$PWD"
9

10 11 12 13 14 15 16 17 18 19
if [ x"$1" = "xhelp" ]; then
    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 sbcl, clisp, allegro and allegromodern"
    exit -1
fi

20 21 22
if [ -z "$2" ]; then
    scripts="*.script"
else
23
    scripts="$2"
24 25
fi

26 27
sok=1

28
do_tests() {
29 30 31 32 33
  command=$1 eval=$2 fasl_ext=$3
  rm -f *.$fasl_ext ~/.cache/common-lisp/"`pwd`"/*.$fasl_ext || true
  ( cd .. && $command $eval '(load "test/compile-asdf.lisp")' )
  if [ $? -eq 0 ] ; then
    echo "Compiled OK"
34 35 36 37
    test_count=0
    test_pass=0
    test_fail=0
    failed_list=""
38 39
    for i in $scripts ;
    do
40 41
      echo "Testing: $i" >&2
      test_count=`expr "$test_count" + 1`
42 43 44
      rm -f *.$fasl_ext ~/.cache/common-lisp/"`pwd`"/*.$fasl_ext || true
      if $command $eval "(load \"$i\")" ; then
        echo "Using $command, $i passed" >&2
45 46
	test_pass=`expr "$test_pass" + 1`
      else
47
        echo "Using $command, $i failed" >&2
48 49 50 51 52 53
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
54
    echo "-#---------------------------------------" >&2
55
    echo "Using $command" >&2
56 57 58 59 60 61 62
    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
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
63
    echo "-#---------------------------------------" >&2
64
    echo >&2
65
  fi
66 67
}

68
# terminate on error
69 70
set -e

71 72 73
lisp=$1
if [ -z $1 ] ; then
    lisp="sbcl"
74 75
fi

76 77
case "$lisp" in
  sbcl)
78 79
    if type sbcl ; then
      fasl_ext="fasl"
80 81 82
      command="sbcl --noinform --userinit /dev/null --sysinit /dev/null"
      nodebug="--disable-debugger"
      eval="--eval"
83 84
    fi ;;
  clisp)
85 86
    if type clisp ; then
	fasl_ext="fas"
87
	command=`which clisp`
88 89 90
	command="$command -norc -ansi -I "
        nodebug="-on-error exit"
        eval="-x"
91 92
    fi ;;
  allegro)
93 94
    if type alisp ; then
	fasl_ext="fasl"
95 96 97
	command="alisp -q "
        nodebug="-batch"
        eval="-eval"
98 99
    fi ;;
  allegromodern)
100 101
    if type mlisp ; then
	fasl_ext="fasl"
102 103 104
	command="mlisp -q"
        nodebug="-batch"
        eval="-eval"
105 106
    fi ;;
  ccl)
Gary King's avatar
Gary King committed
107
    if type ccl ; then
108 109 110 111 112 113 114 115 116
        case `uname -s` in
          Linux) fasl_os=lx ;;
          Darwin) fasl_os=dx ;;
        esac
        case `uname -m` in
          x86_64|ppc64) fasl_bits=64 ;;
          i?86|ppc) fasl_bits=32 ;;
        esac
        fasl_ext="${fasl_os}${fasl_bits}fsl"
117 118 119
	command="ccl --no-init --quiet"
        nodebug="--batch"
        eval="--eval"
120 121 122 123
    fi ;;
  cmucl)
    if type lisp ; then
	fasl_ext="x86f"
124 125 126 127 128 129 130 131 132 133
	command="lisp -noinit"
        nodebug="-batch"
        eval="-eval"
    fi ;;
  ecl)
    if type ecl ; then
	fasl_ext="fas"
	command=`which ecl`
	command="$command -norc"
        eval="-eval"
134 135
    fi ;;
esac
136

137 138 139 140
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

141
create_asds () {
142 143 144
    mkdir -p {conf.d,dir1,dir2/{dir3,dir4}}
    for i in dir1 dir2; do touch "$i"/test.asd; done
    for i in dir3 dir4; do (cd dir2/$i; touch test.asd); done
145 146 147
}

clean_up () {
148
    rm -rf {conf.d,dir?}
149 150
}

151 152

if [ -z "$command" ] ; then
Gary King's avatar
Gary King committed
153
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
154
else
155
    create_asds
Gary King's avatar
Gary King committed
156
    mkdir -p results
157
    echo $command
Gary King's avatar
Gary King committed
158
    thedate=`date "+%Y-%m-%d"`
159 160
    do_tests "$command" "$eval" "$fasl_ext" 2>&1 | \
	tee "results/${lisp}.text" "results/${lisp}-${thedate}.save"
161
    clean_up
162
fi