run-tests.sh 4.34 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
unset DEBUG_ASDF_TEST
Robert P. Goldman's avatar
 
Robert P. Goldman committed
9 10 11

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

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

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

39 40
sok=1

Robert P. Goldman's avatar
 
Robert P. Goldman committed
41 42 43 44 45 46 47 48 49 50 51 52
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."
}

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

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

97
# terminate on error
98 99
set -e

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

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

159 160
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
161 162 163
    exit 43
fi

Francois-Rene Rideau's avatar
1.647:  
Francois-Rene Rideau committed
164 165 166 167 168 169
asdfdir="$(cd .. ; /bin/pwd)"
export CL_SOURCE_REGISTRY="${asdfdir}"
export ASDF_OUTPUT_TRANSLATIONS="${asdfdir}:${asdfdir}/tmp/fasls/$(basename $command)"
env | grep asdf

command="$command $flags"
170 171 172 173
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

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

175 176
create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
177 178 179
}

clean_up () {
180
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
181 182
}

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