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

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

while getopts "duh" OPTION
do
25
    case $OPTION in
Robert P. Goldman's avatar
 
Robert P. Goldman committed
26
        d)
27
            export DEBUG_ASDF_TEST=t
Robert P. Goldman's avatar
 
Robert P. Goldman committed
28 29 30 31 32 33 34 35 36 37 38 39
            ;;
        u)
            usage
            exit 1
            ;;
        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
Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
60
  ( cd .. && DO $command $eval '(load "test/compile-asdf.lisp")' )
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 83 84
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
85
    echo "-#---------------------------------------" >&2
86
    echo "Using $command" >&2
87 88 89 90
    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
91
        echo success > ../tmp/results/status
92 93 94
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
95
    echo "-#---------------------------------------" >&2
96
    echo >&2
97
  fi
98 99
}

100
# terminate on error
101 102
set -e

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

175 176
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
177 178 179
    exit 43
fi

180 181 182
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
183 184 185
env | grep asdf

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

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

191 192
create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
193 194 195
}

clean_up () {
196
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
197 198
}

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