run-tests.sh 4.96 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 9 10 11 12 13 14 15 16 17 18 19
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."
}

20
unset DEBUG_ASDF_TEST
Robert P. Goldman's avatar
 
Robert P. Goldman committed
21 22 23

while getopts "duh" OPTION
do
24
    case $OPTION in
Robert P. Goldman's avatar
 
Robert P. Goldman committed
25
        d)
26
            export DEBUG_ASDF_TEST=t
Robert P. Goldman's avatar
 
Robert P. Goldman committed
27 28 29 30 31 32 33 34 35 36 37 38
            ;;
        u)
            usage
            exit 1
            ;;
        h)
            usage
            exit 1
            ;;
    esac
done
shift $(($OPTIND - 1))
39

40
if [ x"$1" = "xhelp" ]; then
Robert P. Goldman's avatar
 
Robert P. Goldman committed
41 42
    usage
    exit 1
43
fi
44
lisp=$1 ; shift
45

46
if [ -z "$*" ]; then
47 48
    scripts="*.script"
else
49
    scripts="$*"
50 51
fi

52 53
sok=1

Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
54 55
DO () { ( set -x ; "$@" ); }

56
do_tests() {
57
  command="$1" eval="$2"
58
  rm -f ~/.cache/common-lisp/"`pwd`"/* || true
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
59
  ( cd .. && DO $command $eval '(load "test/compile-asdf.lisp")' )
60 61 62 63
  if [ $? -ne 0 ] ; then
    echo "Compilation FAILED" >&2
  else
    echo "Compiled OK" >&2
64 65 66 67
    test_count=0
    test_pass=0
    test_fail=0
    failed_list=""
68 69
    for i in $scripts ;
    do
70 71
      echo "Testing: $i" >&2
      test_count=`expr "$test_count" + 1`
72
      rm -f ~/.cache/common-lisp/"`pwd`"/* || true
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
73
      if DO $command $eval "(load \"$i\")" ; then
74
        echo "Using $command, $i passed" >&2
75 76
	test_pass=`expr "$test_pass" + 1`
      else
77
        echo "Using $command, $i failed" >&2
78 79 80 81 82 83
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
84
    echo "-#---------------------------------------" >&2
85
    echo "Using $command" >&2
86 87 88 89
    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
90
        echo success > ../tmp/results/status
91 92 93
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
94
    echo "-#---------------------------------------" >&2
95
    echo >&2
96
  fi
97 98
}

99
# terminate on error
100 101
set -e

102 103
if [ -z $1 ] ; then
    lisp="sbcl"
104 105
fi

106
command= flags= nodebug= eval=
107
case "$lisp" in
108 109 110
  abcl)
    command="${ABCL:-abcl}"
    flags="--noinit --noinform"
111
    eval="--eval" ;;
112
  allegro)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
113
    command="${ALLEGRO:-alisp}"
114 115 116
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
117
  allegromodern)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
118
    command="${ALLEGROMODERN:-mlisp}"
119 120 121
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
122
  ccl)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
123
    command="${CCL:-ccl}"
124 125 126
    flags="--no-init --quiet"
    nodebug="--batch"
    eval="--eval" ;;
127 128 129 130 131
  clisp)
    command="${CLISP:-clisp}"
    flags="-norc -ansi -I "
    nodebug="-on-error exit"
    eval="-x" ;;
132
  cmucl)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
133
    command="${CMUCL:-lisp}"
134 135 136
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
137
  ecl)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
138
    command="${ECL:-ecl}"
139 140
    flags="-norc"
    eval="-eval" ;;
141 142 143 144 145
  gclcvs)
    export GCL_ANSI=t
    command="${GCL:-gclcvs}"
    flags="-batch"
    eval="-eval" ;;
146
  lispworks)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
147
    command="${LISPWORKS:-lispworks}"
148 149 150 151
    # 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
152 153
    flags="-siteinit - -init -"
    eval="-eval" ;;
154 155 156 157
  sbcl)
    command="${SBCL:-sbcl}"
    flags="--noinform --userinit /dev/null --sysinit /dev/null"
    nodebug="--disable-debugger"
158
    eval="--eval" ;;
159 160 161 162 163
  scl)
    command="${SCL:-scl}"
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
164 165 166 167
  *)
    echo "Unsupported lisp: $1" >&2
    echo "Please add support to run-tests.sh" >&2
    exit 42 ;;
168
esac
169

170 171
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
172 173 174
    exit 43
fi

175 176 177
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
1.647:  
Francois-Rene Rideau committed
178 179 180
env | grep asdf

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

Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
185

186 187
create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
188 189 190
}

clean_up () {
191
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
192 193
}

194
if [ -z "$command" ] ; then
Gary King's avatar
Gary King committed
195
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
196
else
197
    create_config
198
    mkdir -p ../tmp/results
199
    echo failure > ../tmp/results/status
Gary King's avatar
Gary King committed
200
    thedate=`date "+%Y-%m-%d"`
201
    do_tests "$command" "$eval" 2>&1 | \
202
	tee "../tmp/results/${lisp}.text" "../tmp/results/${lisp}-${thedate}.save"
203
    read a < ../tmp/results/status
204
    clean_up
205
    [ success = "$a" ] ## exit code
206
fi