run-tests.sh 4.86 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
44
fi

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

51
52
sok=1

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
    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
89
        echo success > ../tmp/results/status
90
91
92
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
93
    echo "-#---------------------------------------" >&2
94
    echo >&2
95
  fi
96
97
}

98
# terminate on error
99
100
set -e

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

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

165
166
if ! type "$command" ; then
    echo "lisp implementation not found: $command" >&2
167
168
169
    exit 43
fi

170
171
172
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
173
174
175
env | grep asdf

command="$command $flags"
176
177
178
179
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

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

181
182
create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
183
184
185
}

clean_up () {
186
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
187
188
}

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