File: test.sh

package info (click to toggle)
slime 1:20080223.dfsg-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,600 kB
  • ctags: 3,345
  • sloc: lisp: 30,707; sh: 163; makefile: 119; awk: 10
file content (82 lines) | stat: -rwxr-xr-x 1,925 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh

# Run the SLIME test suite inside screen, saving the results to a file.

# This script's exit status is the number of tests failed. If no tests
# fail then no output is printed. If at least one test fails then a
# one-line summary is printed.

# If something unexpected fails, you might get an exit code like 127
# or 255 instead. Sorry.

# This code has been placed in the Public Domain.  All warranties
# are disclaimed.

function usage () {
    echo "Usage: $name [-v] [-r] <emacs> <lisp>"
    exit 1
}

name=$0

while getopts vr opt; do
    case $opt in
	v) verbose=true;;
	r) dump_results=true;;
	*) usage;;
    esac
done

shift $((OPTIND - 1))
[ $# = 2 ] || usage

emacs=$1; lisp=$2;

# Move the code into a directory in /tmp, so that we can compile it
# for the current lisp.

slimedir=$(dirname $name)
testdir=/tmp/slime-test.$$
results=$testdir/results
dribble=$testdir/dribble
statusfile=$testdir/status

test -d $testdir && rm -r $testdir

trap "rm -r $testdir" EXIT	# remove temporary directory on exit

mkdir $testdir
cp -r $slimedir/*.{el,lisp} ChangeLog $slimedir/contrib  $testdir
mkfifo $dribble

session=slime-screen.$$

screen -S $session -m -D bash -c "$emacs -nw -q -no-site-file --no-site-file \
       --eval '(setq debug-on-quit t)' \
       --eval '(setq max-lisp-eval-depth 1000)' \
       --eval '(setq load-path (cons \"$testdir\" load-path))' \
       --eval '(require (quote slime))' \
       --eval '(setq inferior-lisp-program \"$lisp\")' \
       --eval '(slime-batch-test \"$results\")' > $dribble;\
       echo \$? > $statusfile" &

screenpid=$!

if [ "$verbose" = true ]; then
    cat $dribble &
else
    cat $dribble > /dev/null &
fi;

trap "screen -S $session -X quit" SIGINT
wait $screenpid

if [ -f "$statusfile" ]; then
    [ "$dump_results" = true ] && cat $results;
    echo $(cat $statusfile) "test(s) failed."
else
    # Tests crashed
    echo crashed
fi

exit $status