~ubuntu-branches/ubuntu/trusty/cl-asdf/trusty

« back to all changes in this revision

Viewing changes to test/run-tests.sh

  • Committer: Package Import Robot
  • Author(s): Francois-Rene Rideau
  • Date: 2013-05-27 22:44:50 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20130527224450-4bddztgqi7q1uzn7
Tags: 2:3.0.1.2-1
ASDF 3.0.1.2 fixes issues with the debian package itself.
It also includes fixes to run-program and run-shell-command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
2
 
3
 
# do_tests {lisp invocation} {scripts-regex}
 
3
# run-tests {lisp invocation} {scripts-regex}
4
4
# - read lisp forms one at a time from standard input
5
5
# - quit with exit status 0 on getting eof
6
6
# - quit with exit status >0 if an unhandled error occurs
12
12
    echo " - quit with exit status >0 if an unhandled error occurs"
13
13
    echo " you need to supply the .script in the second argument"
14
14
    echo " lisps include abcl, allegro, allegromodern, ccl (clozure),"
15
 
    echo "  clisp, cmucl, ecl, gclcvs, sbcl, and scl."
 
15
    echo "  clisp, cmucl, ecl, gcl, gclcvs, sbcl, scl and xcl."
16
16
    echo "OPTIONS:"
17
17
    echo "    -d -- debug mode"
18
 
    echo "    -u -h -- show this message."
 
18
    echo "    -h -- show this message."
 
19
    echo "    -u -- upgrade tests."
 
20
    echo "    -c -- clean load test"
 
21
    echo "    -l -- load systems tests"
 
22
    echo "    -t -- test interactively"
 
23
    echo "    -H -- extract all asdf versions to upgrade from"
19
24
}
20
25
 
21
 
unset DEBUG_ASDF_TEST
 
26
unset DEBUG_ASDF_TEST upgrade clean_load load_systems test_interactively extract_all
 
27
SHELL=/bin/sh
 
28
export SHELL DEBUG_ASDF_TEST GCL_ANSI ASDF_OUTPUT_TRANSLATIONS
22
29
 
23
 
while getopts "duh" OPTION
 
30
while getopts "cdtHulhu" OPTION
24
31
do
25
32
    case $OPTION in
26
33
        d)
27
 
            export DEBUG_ASDF_TEST=t
 
34
            DEBUG_ASDF_TEST=t
28
35
            ;;
29
36
        u)
30
 
            usage
31
 
            exit 1
 
37
            upgrade=t
 
38
            ;;
 
39
        c)
 
40
            clean_load=t
 
41
            ;;
 
42
        l)
 
43
            load_systems=t
 
44
            ;;
 
45
        t)
 
46
            test_interactively=t
 
47
            ;;
 
48
        H)
 
49
            extract_all=t
32
50
            ;;
33
51
        h)
34
52
            usage
44
62
fi
45
63
lisp=${1:-sbcl} ; shift
46
64
 
47
 
if [ -z "$*" ]; then
48
 
    scripts="*.script"
49
 
else
50
 
    scripts="$*"
51
 
fi
52
 
 
53
 
sok=1
54
 
 
55
 
DO () { ( set -x ; "$@" ); }
56
 
 
57
 
do_tests() {
58
 
  command="$1" eval="$2"
 
65
 
 
66
ECHO () { printf '%s\n' "$*" ;}
 
67
ECHOn () { printf '%s' "$*" ;}
 
68
DBG () { ECHO "$*" >& 2 ;}
 
69
simple_term_p () {
 
70
  case "$1" in *[!a-zA-Z0-9-+_,.:=%/]*) return 1 ;; *) return 0 ;; esac
 
71
}
 
72
kwote0 () { ECHOn "$1" | sed -e "s/\([\\\\\"\$\`]\)/\\\\\\1/g" ;}
 
73
kwote1 () { if simple_term_p "$1" ; then ECHOn "$1"
 
74
  else ECHOn "\"$(kwote0 "$1")\"" ; fi ;}
 
75
kwote () { ( set +x
 
76
  k="" ; for i ; do ECHOn "$k" ; kwote1 "$i" ; k=" " ; done ; echo
 
77
) }
 
78
DO () { kwote "$@" ; "$@" ; }
 
79
 
 
80
do_tests () {
 
81
  if [ -z "$*" ]; then
 
82
       scripts="*.script"
 
83
  else
 
84
       scripts="$*"
 
85
  fi
 
86
  env | grep -i asdf
59
87
  rm -f ~/.cache/common-lisp/"`pwd`"/* || true
60
 
  ( cd .. && DO $command $eval '(load "test/compile-asdf.lisp")' )
 
88
  ( cd .. && DO $cmd $debugp $eval '(or #.(load "test/script-support.lisp") #.(asdf-test::compile-asdf-script))' )
61
89
  if [ $? -ne 0 ] ; then
62
90
    echo "Compilation FAILED" >&2
 
91
    echo "you can retry compilation with:" >&2
 
92
    echo ./test/run-tests.sh $lisp >&2
 
93
    echo "or more interactively (and maybe with rlwrap or in emacs), start with:" >&2
 
94
    echo "$cmd" >&2
 
95
    echo "then copy/paste:" >&2
 
96
    echo '(load "test/script-support.lisp") (asdf-test::compile-asdf-script)' >&2
63
97
  else
64
98
    echo "Compiled OK" >&2
65
99
    test_count=0
71
105
      echo "Testing: $i" >&2
72
106
      test_count=`expr "$test_count" + 1`
73
107
      rm -f ~/.cache/common-lisp/"`pwd`"/* || true
74
 
      if DO $command $eval "(load \"$i\")" ; then
 
108
      if DO $cmd $debugp $eval "(load \"script-support.lisp\")" $eval "(progn (asdf-test::load-asdf) (asdf-test::frob-packages) (asdf-test::with-test () (load \"$i\")))" ; then
75
109
        echo "Using $command, $i passed" >&2
76
110
        test_pass=`expr "$test_pass" + 1`
77
111
      else
78
112
        echo "Using $command, $i failed" >&2
79
113
        test_fail=`expr "$test_fail" + 1`
80
114
        failed_list="$failed_list $i"
81
 
        sok=0
 
115
        echo "you can retry compilation with:" >&2
 
116
        echo ./test/run-tests.sh $lisp $i >&2
 
117
        echo "or more interactively (and maybe with rlwrap or in emacs), start with:" >&2
 
118
        echo "(cd test ; $cmd )" >&2
 
119
        echo "then copy/paste:" >&2
 
120
        echo "'(#.(load \"script-support.lisp\") #.(asdf-test::da) #.(load-asdf) #.(frob-packages) #.(load \"$i\"))" >&2
82
121
      fi
 
122
      echo >&2
 
123
      echo >&2
83
124
    done
84
125
    echo >&2
85
126
    echo "-#---------------------------------------" >&2
88
129
    echo "  $test_pass passing and $test_fail failing" >&2
89
130
    if [ $test_fail -eq 0 ] ; then
90
131
        echo "all tests apparently successful" >&2
91
 
        echo success > ../tmp/results/status
 
132
        echo success > ../build/results/status
92
133
    else
93
134
        echo "failing test(s): $failed_list" >&2
94
135
    fi
108
149
    eval="--eval" ;;
109
150
  allegro)
110
151
    command="${ALLEGRO:-alisp}"
111
 
    flags="-q"
 
152
    #flags="-q"
112
153
    nodebug="-batch"
113
154
    eval="-e" ;;
114
155
  allegromodern)
123
164
    eval="--eval" ;;
124
165
  clisp)
125
166
    command="${CLISP:-clisp}"
126
 
    flags="-norc -ansi -I "
 
167
    flags="-norc --silent -ansi -I "
127
168
    nodebug="-on-error exit"
128
169
    eval="-x" ;;
129
170
  cmucl)
137
178
    command="${ECL:-ecl}"
138
179
    flags="-norc -load sys:cmp"
139
180
    eval="-eval" ;;
140
 
  ecl-bytecodes)
 
181
  ecl_bytecodes)
141
182
    command="${ECL:-ecl}"
142
183
    flags="-norc -eval (ext::install-bytecodes-compiler)"
143
184
    eval="-eval" ;;
 
185
  gcl)
 
186
    GCL_ANSI=t
 
187
    command="${GCL:-gcl}"
 
188
    flags="-batch"
 
189
    eval="-eval" ;;
144
190
  gclcvs)
145
 
    export GCL_ANSI=t
146
 
    command="${GCL:-gclcvs}"
 
191
    GCL_ANSI=t
 
192
    command="${GCLCVS:-gclcvs}"
147
193
    flags="-batch"
148
194
    eval="-eval" ;;
149
195
  lispworks)
160
206
    eval="-eval" ;;
161
207
  sbcl)
162
208
    command="${SBCL:-sbcl}"
163
 
    flags="--noinform --userinit /dev/null --sysinit /dev/null"
 
209
    flags="--noinform --userinit /dev/null --sysinit /dev/null" # --eval (require'asdf)
164
210
    nodebug="--disable-debugger"
165
211
    eval="--eval" ;;
166
212
  scl)
178
224
    exit 42 ;;
179
225
esac
180
226
 
181
 
if ! type "$command" ; then
 
227
if ! type "$command" > /dev/null ; then
182
228
    echo "lisp implementation not found: $command" >&2
183
229
    exit 43
184
230
fi
185
231
 
186
 
ASDFDIR="$(cd .. ; /bin/pwd)"
187
 
export CL_SOURCE_REGISTRY="${ASDFDIR}"
188
 
export ASDF_OUTPUT_TRANSLATIONS="(:output-translations (\"${ASDFDIR}\" (\"${ASDFDIR}/tmp/fasls\" :implementation)) :ignore-inherited-configuration)"
189
 
env | grep asdf
 
232
ASDFDIR="$(cd $(dirname $0)/.. ; /bin/pwd)"
190
233
 
191
 
command="$command $flags"
 
234
cmd="$command $flags"
 
235
debugp=
192
236
if [ -z "${DEBUG_ASDF_TEST}" ] ; then
193
 
  command="$command $nodebug"
 
237
  debugp="$nodebug"
194
238
fi
195
239
 
196
240
 
197
241
create_config () {
198
 
    mkdir -p ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
199
 
}
200
 
 
 
242
    cd ${ASDFDIR}
 
243
    mkdir -p build/results/ build/test-source-registry-conf.d build/test-asdf-output-translations-conf.d
 
244
}
 
245
upgrade_tags () {
 
246
    if [ -n "$ASDF_UPGRADE_TEST_TAGS" ] ; then
 
247
        echo $ASDF_UPGRADE_TEST_TAGS ; return
 
248
    fi
 
249
    # REQUIRE is a magic tag meaning whatever your implementation provides, if anything
 
250
    #
 
251
    # 1.85 (2004-05-16) is the last release by Daniel Barlow (not 1.37, which is the README revision!)
 
252
    # 1.97 (2006-05-14) is the last release before Gary King takes over
 
253
    # 1.369 (2009-10-27) is the last release by Gary King
 
254
    #
 
255
    # 2.000 to 2.019 and 2.20 to 2.26 and beyond are Faré's "stable" ASDF 2 releases
 
256
    # 2.26.61 is the last single-file, single-package ASDF.
 
257
    # 2.27 and beyond are Faré's "stable" ASDF 3 pre-releases
 
258
    #
 
259
    # 2.000 (2010-05-31) was the first ASDF 2 release
 
260
    # 2.008 (2010-09-10) was a somewhat stable ASDF 2 release
 
261
    # 2.011 (2010-11-28) was used by CLISP 2.49, Debian squeeze, Ubuntu 10.04 LTS
 
262
    # 2.014.6 (2011-04-06) was used by Quicklisp in 2011
 
263
    # 2.019 (2011-11-27) was stable
 
264
    # 2.20 (2012-01-18) was in CCL 1.8, Ubuntu 12.04 LTS
 
265
    # 2.22 (2012-06-12) was used by debian wheezy
 
266
    # 2.26 (2012-10-30) was used by Quicklisp
 
267
    # 2.27 (2013-02-01) is the first ASDF 3 pre-release
 
268
    # 2.32 (2013-03-05) is the first really stable ASDF 3 pre-release
 
269
    #
 
270
    echo REQUIRE 1.85 1.97 1.369
 
271
    # git tag -l '2.0??'
 
272
    # git tag -l '2.??'
 
273
    echo 2.000 2.008 2.011 2.014.6 2.019 2.20 2.22 2.26
 
274
    echo 2.27
 
275
    git tag -l '2.3[2-9]'
 
276
}
 
277
upgrade_methods () {
 
278
    if [ -n "$ASDF_UPGRADE_TEST_METHODS" ] ; then
 
279
        echo $ASDF_UPGRADE_TEST_METHODS ; return
 
280
    fi
 
281
    cat <<EOF
 
282
'load-asdf-lisp'load-asdf-lisp-clean
 
283
'load-asdf-lisp'load-asdf-system
 
284
'load-asdf-lisp'compile-load-asdf
 
285
'load-asdf-lisp'load-asdf-fasl
 
286
()'load-asdf-fasl
 
287
'load-asdf-lisp-and-test-uiop'load-asdf-fasl
 
288
EOF
 
289
}
 
290
extract_tagged_asdf () {
 
291
    cd ${ASDFDIR}
 
292
    mkdir -p build/
 
293
    tag=$1
 
294
    if [ REQUIRE = "$tag" ] ; then return 0 ; fi
 
295
    file=build/asdf-${tag}.lisp ;
 
296
    if [ ! -f $file ] ; then
 
297
        case $tag in
 
298
            1.*|2.0*|2.2[0-6]|2.26.61)
 
299
                git show ${tag}:asdf.lisp > $file ;;
 
300
            2.2[7-9]*|2.[3-9]*|3.*)
 
301
                mkdir -p build/old/build
 
302
                git archive ${tag} | (cd build/old/ ; tar xf -)
 
303
                make -C build/old
 
304
                mv build/old/build/asdf.lisp build/asdf-${tag}.lisp
 
305
                rm -rf build/old ;;
 
306
             *)
 
307
                echo "Don't know how to extract asdf.lisp for version $tag"
 
308
                exit 55
 
309
                ;;
 
310
        esac
 
311
    fi
 
312
}
 
313
extract_all_tagged_asdf () {
 
314
    for i in `upgrade_tags` ; do
 
315
      extract_tagged_asdf $i
 
316
    done
 
317
}
 
318
valid_upgrade_test_p () {
 
319
    case "${1}:${2}:${3}" in
 
320
        # It's damn slow. Also, for some reason, we punt on anything earlier than 2.25,
 
321
        # and only need to test it once, below for 2.24.
 
322
        abcl:1.*|abcl:2.00[0-9]:*|abcl:201[0-9]:*|abcl:2.2[0-3]:*) : ;;
 
323
        # Skip allegro modern on 1.x -- fails for rpgoldman on his mac (!)
 
324
        allegromodern:1.*) : ;;
 
325
        # ccl fasl numbering broke loading of old asdf 2.0
 
326
        ccl:2.0[01]*) : ;;
 
327
        # my old ubuntu clisp 2.44.1 is wired in
 
328
        # with an antique ASDF 1.374 from CLC that can't be downgraded.
 
329
        # 2.00[0-7] use UID, which fails on that CLISP and was removed afterwards.
 
330
        # Note that for the longest time, CLISP has included 2.011 in its distribution.
 
331
        # Since we punt on the upgrade, let's only do the test once, for 2.26.
 
332
        clisp:2.00[0-7]:*|clisp:1.*|clisp:2.0[01]*|clisp:2.2[0-5]:*) : ;;
 
333
        # Skip, CMUCL has problems before 2.014.7 due to source-registry upgrade.
 
334
        # Weird unidentified problems before 2.018, so we punt equally for everything before,
 
335
        # and only need to test it once: above, for 2.017.
 
336
        cmucl:1.*|cmucl:2.00*|cmucl:2.01[0-6]:*) : ;;
 
337
        # Skip many ECL tests, for various ASDF issues
 
338
        ecl*:1.*|ecl*:2.0[01]*|ecl*:2.20:*) : ;;
 
339
        # GCL 2.6 is only supported with ASDF 2.27, so skip earlier versions
 
340
        gcl:1.*|gcl:2.0*|gcl:2.2[0-6]*) : ;;
 
341
        # MKCL is only supported starting with 2.24, so skip earlier versions
 
342
        mkcl:1.*|mkcl:2.0[01]*|mkcl:2.2[0-3]:*) : ;;
 
343
        # XCL support starts with ASDF 2.014.2
 
344
        # — It also dies during upgrade trying to show the backtrace.
 
345
        xcl:1.*|xcl:2.00*|xcl:2.01[0-4]:*|xcl:*) : ;;
 
346
        *) return 0 ;;
 
347
   esac
 
348
   return 1
 
349
}
 
350
run_upgrade_tests () {
 
351
    cd ${ASDFDIR}
 
352
    mkdir -p build/results/
 
353
    rm -f build/*.*f* uiop/*.*f* test/*.*f* ## Remove stale FASLs from ASDF 1.x, especially when different implementations have same name
 
354
    ASDF_OUTPUT_TRANSLATIONS="(:output-translations (\"${ASDFDIR}\" (\"${ASDFDIR}/build/fasls/\" :implementation \"asdf/\")) (t (\"${ASDFDIR}/build/fasls/\" :implementation \"root/\")) :ignore-inherited-configuration)"
 
355
    su=test/script-support.lisp
 
356
    for tag in `upgrade_tags` ; do
 
357
        for method in `upgrade_methods` ; do
 
358
            if valid_upgrade_test_p $lisp $tag $method ; then
 
359
                echo "Testing ASDF upgrade from ${tag} using method $method"
 
360
                extract_tagged_asdf $tag
 
361
                $cmd $debugp $eval \
 
362
                "'(#.(load\"$su\")#.(in-package :asdf-test)#.(test-upgrade $method \"$tag\"))" ||
 
363
                { echo "upgrade FAILED for $lisp from $tag using method $method" ;
 
364
                  echo "you can retry just that test with:" ;
 
365
                  echo ASDF_UPGRADE_TEST_TAGS=\"$tag\" ASDF_UPGRADE_TEST_METHODS=\"$method\" ./test/run-tests.sh -u $lisp ;
 
366
                  echo "or more interactively (and maybe with rlwrap or in emacs), start with:"
 
367
                  echo "$cmd"
 
368
                  echo "then copy/paste:"
 
369
                  echo "(load\"$su\") (asdf-test::da) (test-upgrade $method \"$tag\")"
 
370
                  exit 1 ;}
 
371
    fi ; done ; done 2>&1 | tee build/results/${lisp}-upgrade.text
 
372
}
 
373
run_tests () {
 
374
  create_config
 
375
  cd ./test/
 
376
  echo failure > ../build/results/status
 
377
    thedate=`date "+%Y-%m-%d"`
 
378
    do_tests "$@" 2>&1 | \
 
379
        tee "../build/results/${lisp}.text" "../build/results/${lisp}-${thedate}.save"
 
380
    read a < ../build/results/status
 
381
  clean_up
 
382
  if [ success = "$a" ] ; then ## exit code
 
383
      return 0
 
384
  else
 
385
     echo "To view full results and failures, try the following command:" >&2
 
386
     echo "     less -p ABORTED build/results/${lisp}.text" >&2
 
387
     return 1
 
388
  fi
 
389
}
201
390
clean_up () {
202
 
    rm -rf ../tmp/test-source-registry-conf.d ../tmp/test-asdf-output-translations-conf.d
 
391
    rm -rf ../build/test-source-registry-conf.d ../build/test-asdf-output-translations-conf.d
 
392
}
 
393
test_clean_load () {
 
394
    case $lisp in
 
395
        gcl|cmucl) return 0 ;; # These are hopeless
 
396
    esac
 
397
    cd ${ASDFDIR}
 
398
    mkdir -p build/results/
 
399
    nop=build/results/${lisp}-nop.text
 
400
    load=build/results/${lisp}-load.text
 
401
    ${cmd} ${eval} \
 
402
      '(or #.(load "test/script-support.lisp" :verbose nil :print nil) #.(asdf-test::exit-lisp 0))' \
 
403
        > $nop 2>&1
 
404
    ${cmd} ${eval} \
 
405
      '(or #.(load "test/script-support.lisp" :verbose nil :print nil) #.(asdf-test::verbose nil) #.(load "build/asdf.lisp" :verbose nil) #.(asdf/image:quit 0))' \
 
406
        > $load 2>&1
 
407
    if diff $nop $load ; then
 
408
      echo "GOOD: Loading ASDF on $lisp produces no message" >&2 ; return 0
 
409
    else
 
410
      echo "BAD: Loading ASDF on $lisp produces messages" >&2 ; return 1
 
411
    fi
 
412
}
 
413
test_load_systems () {
 
414
    case $lisp in
 
415
        gcl) return 0 ;; # This one is hopeless
 
416
    esac
 
417
    cd ${ASDFDIR}
 
418
    mkdir -p build/results/
 
419
    echo "Loading all these systems: $*"
 
420
    ${cmd} ${eval} \
 
421
      "(or #.(load \"test/script-support.lisp\") #.(asdf-test::with-test () (asdf-test::test-load-systems $*)))" \
 
422
        2>&1 | tee build/results/${lisp}-systems.text
 
423
}
 
424
test_interactively () {
 
425
    cd ${ASDFDIR}
 
426
    mkdir -p build/results/
 
427
    rlwrap $cmd $eval "(or #.(load \"test/script-support.lisp\") #.(asdf-test::interactive-test '($*)))"
203
428
}
204
429
 
205
 
if [ -z "$command" ] ; then
 
430
if [ -z "$cmd" ] ; then
206
431
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
 
432
elif [ -n "$test_interactively" ] ; then
 
433
    test_interactively "$@"
 
434
elif [ -n "$clean_load" ] ; then
 
435
    test_clean_load
 
436
elif [ -n "$load_systems" ] ; then
 
437
    test_load_systems "$@"
 
438
elif [ -n "$upgrade" ] ; then
 
439
    run_upgrade_tests
 
440
elif [ -n "$extract_all" ] ; then
 
441
    extract_all_tagged_asdf
207
442
else
208
 
    create_config
209
 
    mkdir -p ../tmp/results
210
 
    echo failure > ../tmp/results/status
211
 
    thedate=`date "+%Y-%m-%d"`
212
 
    do_tests "$command" "$eval" 2>&1 | \
213
 
        tee "../tmp/results/${lisp}.text" "../tmp/results/${lisp}-${thedate}.save"
214
 
    read a < ../tmp/results/status
215
 
    clean_up
216
 
    [ success = "$a" ] ## exit code
217
 
fi
 
443
    run_tests "$@"
 
444
fi ; exit # NB: "; exit" makes it robust wrt the script being modified while running.