Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
marvel
GitHub Repository: marvel/qnf
Path: blob/master/elisp/slime/test.sh
989 views
1
#!/bin/bash
2
3
# Run the SLIME test suite inside screen, saving the results to a file.
4
5
6
# This script's exit status is the number of tests failed. If no tests
7
# fail then no output is printed. If at least one test fails then a
8
# one-line summary is printed.
9
10
# If something unexpected fails, you might get an exit code like 127
11
# or 255 instead. Sorry.
12
13
# This code has been placed in the Public Domain. All warranties
14
# are disclaimed.
15
16
function usage () {
17
cat <<EOF
18
Usage: $name [-bsRTS] [-n <name>] <emacs> <lisp>"
19
-b use batch mode
20
-s use screen to hide emacs
21
-R don't show results file
22
-T no temp directory (use slime in current directory)
23
-S don't execute tests in random order (use default ordering)
24
-n <name> run only the test with name <name>
25
EOF
26
exit 1
27
}
28
29
name=$0
30
batch_mode="" # command line arg for emacs
31
dump_results=true
32
use_temp_dir=true
33
test_name=nil
34
randomize=t
35
36
while getopts bsRTSn: opt; do
37
case $opt in
38
b) batch_mode="-batch";;
39
s) use_screen=true;;
40
n) test_name="'$OPTARG";;
41
S) randomize=nil;;
42
R) dump_results=false;;
43
T) use_temp_dir=false;;
44
*) usage;;
45
esac
46
done
47
48
shift $((OPTIND - 1))
49
[ $# = 2 ] || usage
50
51
emacs=$1; lisp=$2;
52
53
# Move the code into a directory in /tmp, so that we can compile it
54
# for the current lisp.
55
56
slimedir=$(dirname $name)
57
tmpdir=/tmp/slime-test.$$
58
if [ $use_temp_dir == true ] ; then
59
testdir=$tmpdir
60
else
61
testdir=$(pwd)
62
fi
63
results=$tmpdir/results
64
statusfile=$tmpdir/status
65
66
test -d $tmpdir && rm -r $tmpdir
67
68
trap "rm -r $tmpdir" EXIT # remove temporary directory on exit
69
70
mkdir $tmpdir
71
if [ $use_temp_dir == true ] ; then
72
cp -r $slimedir/*.{el,lisp} ChangeLog $tmpdir
73
# cp -r $slimedir/contrib $tmpdir
74
fi
75
76
cmd=($emacs -nw -q -no-site-file $batch_mode --no-site-file
77
--eval "(setq debug-on-quit t)"
78
--eval "(add-to-list 'load-path \"$testdir\")"
79
--eval "(require 'slime)"
80
--eval "(setq inferior-lisp-program \"$lisp\")"
81
--eval "(slime-batch-test \"$results\" $test_name $randomize)")
82
83
if [ "$use_screen" = "" ]; then
84
"${cmd[@]}"
85
echo $? > $statusfile
86
else
87
session=slime-screen.$$
88
screen -S $session -m -D \
89
bash -c "\"\$@\"; echo \$? > $statusfile" "" "${cmd[@]}" &
90
screenpid=$!
91
trap "screen -S $session -X quit" SIGINT SIGQUIT
92
wait $screenpid
93
fi
94
95
if [ -f "$statusfile" ]; then
96
[ "$dump_results" = true ] && cat $results
97
status=$(cat $statusfile)
98
echo $status "test(s) failed."
99
else
100
# Tests crashed
101
echo crashed
102
status=255
103
fi
104
105
exit $status
106
107