run-tests.sh 4.19 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"
Robert P. Goldman's avatar
 
Robert P. Goldman committed
9
export DEBUG_ASDF_TEST=
Robert P. Goldman's avatar
 
Robert P. Goldman committed
10 11 12 13 14

while getopts "duh" OPTION
do
    case OPTION in
        d)
Robert P. Goldman's avatar
 
Robert P. Goldman committed
15
            DEBUG_ASDF_TEST = 1
Robert P. Goldman's avatar
 
Robert P. Goldman committed
16 17 18 19 20 21 22 23 24 25 26 27
            ;;
        u)
            usage
            exit 1
            ;;
        h)
            usage
            exit 1
            ;;
    esac
done
shift $(($OPTIND - 1))
28

29
if [ x"$1" = "xhelp" ]; then
Robert P. Goldman's avatar
 
Robert P. Goldman committed
30 31
    usage
    exit 1
32 33
fi

34 35 36
if [ -z "$2" ]; then
    scripts="*.script"
else
37
    scripts="$2"
38 39
fi

40 41
sok=1

Robert P. Goldman's avatar
 
Robert P. Goldman committed
42 43 44 45 46 47 48 49 50 51 52 53
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 sbcl, clisp, allegro and allegromodern"
    echo "OPTIONS:"
    echo "    -d -- debug mode"
    echo "    -u -h -- show this message."
}

54
do_tests() {
55 56 57 58 59
  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"
60 61 62 63
    test_count=0
    test_pass=0
    test_fail=0
    failed_list=""
64 65
    for i in $scripts ;
    do
66 67
      echo "Testing: $i" >&2
      test_count=`expr "$test_count" + 1`
68 69 70
      rm -f *.$fasl_ext ~/.cache/common-lisp/"`pwd`"/*.$fasl_ext || true
      if $command $eval "(load \"$i\")" ; then
        echo "Using $command, $i passed" >&2
71 72
	test_pass=`expr "$test_pass" + 1`
      else
73
        echo "Using $command, $i failed" >&2
74 75 76 77 78 79
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
80
    echo "-#---------------------------------------" >&2
81
    echo "Using $command" >&2
82 83 84 85 86 87 88
    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
89
    echo "-#---------------------------------------" >&2
90
    echo >&2
91
  fi
92 93
}

94
# terminate on error
95 96
set -e

97 98 99
lisp=$1
if [ -z $1 ] ; then
    lisp="sbcl"
100 101
fi

102 103
case "$lisp" in
  sbcl)
104 105
    if type sbcl ; then
      fasl_ext="fasl"
106 107 108
      command="sbcl --noinform --userinit /dev/null --sysinit /dev/null"
      nodebug="--disable-debugger"
      eval="--eval"
109 110
    fi ;;
  clisp)
111 112
    if type clisp ; then
	fasl_ext="fas"
113
	command=`which clisp`
114 115 116
	command="$command -norc -ansi -I "
        nodebug="-on-error exit"
        eval="-x"
117 118
    fi ;;
  allegro)
119 120
    if type alisp ; then
	fasl_ext="fasl"
121 122 123
	command="alisp -q "
        nodebug="-batch"
        eval="-eval"
124 125
    fi ;;
  allegromodern)
126 127
    if type mlisp ; then
	fasl_ext="fasl"
128 129 130
	command="mlisp -q"
        nodebug="-batch"
        eval="-eval"
131 132
    fi ;;
  ccl)
Gary King's avatar
Gary King committed
133
    if type ccl ; then
134 135 136 137 138 139 140 141 142
        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"
143 144 145
	command="ccl --no-init --quiet"
        nodebug="--batch"
        eval="--eval"
146 147 148 149
    fi ;;
  cmucl)
    if type lisp ; then
	fasl_ext="x86f"
150 151 152 153 154 155 156 157 158 159
	command="lisp -noinit"
        nodebug="-batch"
        eval="-eval"
    fi ;;
  ecl)
    if type ecl ; then
	fasl_ext="fas"
	command=`which ecl`
	command="$command -norc"
        eval="-eval"
160 161
    fi ;;
esac
162

163 164 165 166
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

167
create_asds () {
168 169 170
    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
171 172 173
}

clean_up () {
174
    rm -rf {conf.d,dir?}
175 176
}

177 178

if [ -z "$command" ] ; then
Gary King's avatar
Gary King committed
179
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
180
else
181
    create_asds
Gary King's avatar
Gary King committed
182
    mkdir -p results
183
    echo $command
Gary King's avatar
Gary King committed
184
    thedate=`date "+%Y-%m-%d"`
185 186
    do_tests "$command" "$eval" "$fasl_ext" 2>&1 | \
	tee "results/${lisp}.text" "results/${lisp}-${thedate}.save"
187
    clean_up
188
fi