run-tests.sh 8.47 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
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"
14
    echo " lisps include abcl, allegro, allegromodern, ccl (clozure),"
15
    echo "  clisp, cmucl, ecl, gcl, gclcvs, sbcl, scl and xcl."
16 17
    echo "OPTIONS:"
    echo "    -d -- debug mode"
18 19
    echo "    -h -- show this message."
    echo "    -u -- upgrade tests."
20 21
}

22
unset DEBUG_ASDF_TEST upgrade
Robert P. Goldman's avatar
 
Robert P. Goldman committed
23 24 25

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

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

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

53 54
sok=1

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

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

102
# terminate on error
103 104
set -e

105
command= flags= nodebug= eval=
106
case "$lisp" in
107 108
  abcl)
    command="${ABCL:-abcl}"
109
    flags="--noinit --nosystem --noinform"
110
    eval="--eval" ;;
111
  allegro)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
112
    command="${ALLEGRO:-alisp}"
113 114 115
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
116
  allegromodern)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
117
    command="${ALLEGROMODERN:-mlisp}"
118 119 120
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
121
  ccl)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
122
    command="${CCL:-ccl}"
123 124 125
    flags="--no-init --quiet"
    nodebug="--batch"
    eval="--eval" ;;
126 127 128 129 130
  clisp)
    command="${CLISP:-clisp}"
    flags="-norc -ansi -I "
    nodebug="-on-error exit"
    eval="-x" ;;
131
  cmucl)
132 133 134
    # cmucl likes to have its executable called lisp, but so does scl
    # Please use a symlink or an exec ... "$@" trampoline script.
    command="${CMUCL:-cmucl}"
135 136 137
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
138
  ecl)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
139
    command="${ECL:-ecl}"
140 141
    flags="-norc -load sys:cmp"
    eval="-eval" ;;
142
  ecl_bytecodes)
143 144
    command="${ECL:-ecl}"
    flags="-norc -eval (ext::install-bytecodes-compiler)"
145
    eval="-eval" ;;
146 147 148 149 150
  gcl)
    export GCL_ANSI=t
    command="${GCL:-gcl}"
    flags="-batch"
    eval="-eval" ;;
151 152
  gclcvs)
    export GCL_ANSI=t
153
    command="${GCLCVS:-gclcvs}"
154 155
    flags="-batch"
    eval="-eval" ;;
156
  lispworks)
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
157
    command="${LISPWORKS:-lispworks}"
158 159 160 161
    # 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
162 163
    flags="-siteinit - -init -"
    eval="-eval" ;;
164 165 166 167
  mkcl)
    command="${MKCL:-mkcl}"
    flags="-norc"
    eval="-eval" ;;
168 169
  sbcl)
    command="${SBCL:-sbcl}"
170
    flags="--noinform --userinit /dev/null --sysinit /dev/null" # --eval (require'asdf)
171
    nodebug="--disable-debugger"
172
    eval="--eval" ;;
173 174 175 176 177
  scl)
    command="${SCL:-scl}"
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
178 179 180 181
  xcl)
    command="${XCL:-xcl}"
    flags="--no-userinit --no-siteinit"
    eval="--eval" ;;
182 183 184 185
  *)
    echo "Unsupported lisp: $1" >&2
    echo "Please add support to run-tests.sh" >&2
    exit 42 ;;
186
esac
187

188 189
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
190 191 192
    exit 43
fi

193 194
ASDFDIR="$(cd .. ; /bin/pwd)"
export CL_SOURCE_REGISTRY="${ASDFDIR}"
195
export ASDF_OUTPUT_TRANSLATIONS="(:output-translations (\"${ASDFDIR}\" (\"${ASDFDIR}/build/fasls\" :implementation)) :ignore-inherited-configuration)"
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
196 197 198
env | grep asdf

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

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

204
create_config () {
205
    mkdir -p ../build/test-source-registry-conf.d ../build/test-asdf-output-translations-conf.d
206
}
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
upgrade_tags () {
    if [ -n "$TEST_ASDF_TAGS" ] ; then
        echo $TEST_ASDF_TAGS ; return
    fi
    # 1.37 is the last release by Daniel Barlow
    # 1.97 is the last release before Gary King takes over
    # 1.369 is the last release by Gary King
    # 2.000 to 2.019 and 2.20 to 2.27 and beyond are Faré's "stable" releases
    echo 1.37 1.97 1.369
    git tag -l '2.0??'
    git tag -l '2.??'
}
extract_tagged_asdf () {
    ver=$1
    file=build/asdf-${tag}.lisp ;
    if [ ! -f $file ] ; then
        case $ver in
            1.*|2.0*|2.2[0-6])
                git show ${tag}:asdf.lisp > $file ;;
            *)
                echo "Don't know how to extract asdf.lisp for version $tag"
                exit 55
                ;;
        esac
    fi
}
run_upgrade_tests () {
    su=test/script-support.lisp
    lu="(load\"$su\")"
    lv="$command $eval $lu $eval" ;
    for tag in `upgrade_tags` ; do
        for x in load-system load-lisp load-lisp-compile-load-fasl load-fasl just-load-fasl ; do
            lo="(asdf-test::load-asdf-lisp \"${tag}\")" ;
            echo "Testing upgrade from ASDF ${tag} using method $x" ;
            extract_tagged_asdf $tag
            case ${lisp}:$tag:$x in
                abcl:2.0[01][1-9]:*|abcl:2.2[1-2]:*)
                    : Skip, because it is so damn slow ;;
                ccl:1.*|ccl:2.0[01]*)
                    : Skip, because ccl broke old asdf ;;
                cmucl:1.*|cmucl:2.00*|cmucl:2.01[0-4]:*)
                    : Skip, CMUCL has problems before 2.014.7 due to source-registry upgrade ;;
                ecl*:1.*|ecl*:2.0[01]*|ecl*:2.20:*)
                    : Skip, because of various ASDF issues ;;
                gcl:1.*|gcl:2.0*|gcl:2.2[0-6]*) : Skip old versions that do not support GCL 2.6 ;;
                mkcl:1.*|mkcl:2.0[01]*|mkcl:2.2[0-3]:*)
                    : Skip, because MKCL is only supported starting with 2.24 ;;
                xcl:1.*|xcl:2.00*|xcl:2.01[0-4]:*|xcl:*)
                    : XCL support starts with ASDF 2.014.2 - It also hangs badly during upgrade. ;;
                *) (set -x ; case $x in
                            load-system) l="$lo (asdf-test::load-asdf-system)" ;;
                            load-lisp) l="$lo (asdf-test::load-asdf-lisp)" ;;
                            load-lisp-compile-load-fasl) l="$lo (asdf-test::compile-load-asdf)" ;;
                            load-fasl) l="$lo (asdf-test::load-asdf-fasl)" ;;
                            just-load-fasl) l="(asdf-test::load-asdf-fasl)" ;;
                            *) echo "WTF?" ; exit 2 ;; esac ;
                        $lv "(asdf-test::test-asdf $l)" ) ||
                    { echo "upgrade FAILED" ; exit 1 ;} ;; esac ;
        done ; done 2>&1 | tee build/results/${lisp}-upgrade.text
}
run_tests () {
  create_config
  mkdir -p ../build/results
  echo failure > ../build/results/status
    thedate=`date "+%Y-%m-%d"`
    do_tests "$command" "$eval" 2>&1 | \
	tee "../build/results/${lisp}.text" "../build/results/${lisp}-${thedate}.save"
    read a < ../build/results/status
  clean_up
  [ success = "$a" ] ## exit code
}
278
clean_up () {
279
    rm -rf ../build/test-source-registry-conf.d ../build/test-asdf-output-translations-conf.d
280 281
}

282
if [ -z "$command" ] ; then
Gary King's avatar
Gary King committed
283
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
284 285
elif [ -n "$upgrade" ] ; then
    run_upgrade_tests
286
else
287
    run_tests
288
fi