run-tests.sh 4.17 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
export CL_SOURCE_REGISTRY="$PWD"
9
unset DEBUG_ASDF_TEST
Robert P. Goldman's avatar
   
Robert P. Goldman committed
10
11
12

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

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

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

40
41
sok=1

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

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

96
# terminate on error
97
98
set -e

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

104
command= flags= nodebug= eval=
105
106
case "$lisp" in
  sbcl)
107
108
109
110
    command=sbcl
    flags="--noinform --userinit /dev/null --sysinit /dev/null"
    nodebug="--disable-debugger"
    eval="--eval" ;;
111
  clisp)
112
113
114
115
    command=clisp
    flags="-norc -ansi -I "
    nodebug="-on-error exit"
    eval="-x" ;;
116
  allegro)
117
118
119
120
    command=alisp
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
121
  allegromodern)
122
123
124
125
    command=mlisp
    flags="-q"
    nodebug="-batch"
    eval="-e" ;;
126
  ccl)
127
128
129
130
    command=ccl
    flags="--no-init --quiet"
    nodebug="--batch"
    eval="--eval" ;;
131
  cmucl)
132
133
134
135
    command=lisp
    flags="-noinit"
    nodebug="-batch"
    eval="-eval" ;;
136
  ecl)
137
138
139
140
141
    #if [ -x /usr/lib/ecl/ecl-original ] ; then
    #  command=/usr/lib/ecl/ecl-original
    #else
      command=ecl
    #fi
142
143
    flags="-norc"
    eval="-eval" ;;
144
  lispworks)
145
146
147
148
149
150
    command=lispworks
    flags="-siteinit - -init -"
    eval="-eval" ;;
  gclcvs)
    export GCL_ANSI=t
    command=gclcvs
151
    flags="-batch"
152
    eval="-eval" ;;
153
154
155
  abcl)
    command=abcl
    eval="--eval" ;;
156
157
158
159
  *)
    echo "Unsupported lisp: $1" >&2
    echo "Please add support to run-tests.sh" >&2
    exit 42 ;;
160
esac
161

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

167
168
169
170
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
  command="$command $nodebug"
fi

171
172
create_config () {
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
173
174
175
}

clean_up () {
176
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
177
178
}

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