run-tests.sh 4.59 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
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
    # 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
147
148
149
150
    flags="-siteinit - -init -"
    eval="-eval" ;;
  gclcvs)
    export GCL_ANSI=t
Francois-Rene Rideau's avatar
1.647:    
Francois-Rene Rideau committed
151
    command="${GCL:-gclcvs}"
152
    flags="-batch"
153
    eval="-eval" ;;
154
  abcl)
Francois-Rene Rideau's avatar
1.647:    
Francois-Rene Rideau committed
155
    command="${ABCL:-abcl}"
156
    eval="--eval" ;;
157
158
159
160
  *)
    echo "Unsupported lisp: $1" >&2
    echo "Please add support to run-tests.sh" >&2
    exit 42 ;;
161
esac
162

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

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

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

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

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

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

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