-
Notifications
You must be signed in to change notification settings - Fork 19
/
test.sh
executable file
·104 lines (85 loc) · 2.45 KB
/
test.sh
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/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 () {
cat <<EOF
Usage: $name [-bsRTS] [-n <name>] <emacs> <lisp>"
-b use batch mode
-s use screen to hide emacs
-R don't show results file
-T no temp directory (use slime in current directory)
-S don't execute tests in random order (use default ordering)
-n <name> run only the test with name <name>
EOF
exit 1
}
name=$0
batch_mode="" # command line arg for emacs
dump_results=true
use_temp_dir=true
test_name=nil
randomize=t
while getopts bsRTSn: opt; do
case $opt in
b) batch_mode="-batch";;
s) use_screen=true;;
n) test_name="'$OPTARG";;
S) randomize=nil;;
R) dump_results=false;;
T) use_temp_dir=false;;
*) 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)
tmpdir=/tmp/slime-test.$$
if [ $use_temp_dir == true ] ; then
testdir=$tmpdir
else
testdir=$(pwd)
fi
results=$tmpdir/results
statusfile=$tmpdir/status
test -d $tmpdir && rm -r $tmpdir
trap "rm -r $tmpdir" EXIT # remove temporary directory on exit
mkdir $tmpdir
if [ $use_temp_dir == true ] ; then
cp -r $slimedir/*.{el,lisp} ChangeLog $slimedir/contrib $tmpdir
fi
cmd=($emacs -nw -q -no-site-file $batch_mode --no-site-file
--eval "(setq debug-on-quit t)"
--eval "(add-to-list 'load-path \"$testdir\")"
--eval "(require 'slime)"
--eval "(setq inferior-lisp-program \"$lisp\")"
--eval "(slime-batch-test \"$results\" $test_name $randomize)")
if [ "$use_screen" = "" ]; then
"${cmd[@]}"
echo $? > $statusfile
else
session=slime-screen.$$
screen -S $session -m -D \
bash -c "\"\$@\"; echo \$? > $statusfile" "" "${cmd[@]}" &
screenpid=$!
trap "screen -S $session -X quit" SIGINT SIGQUIT
wait $screenpid
fi
if [ -f "$statusfile" ]; then
[ "$dump_results" = true ] && cat $results
status=$(cat $statusfile)
echo $status "test(s) failed."
else
# Tests crashed
echo crashed
status=255
fi
exit $status