summaryrefslogtreecommitdiff
path: root/test-suite/standalone/test-guild-compile
blob: edc623570a42d67c11a42be2846f89b6471a4519 (plain)
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
#!/bin/sh
#
# This -*- sh -*- script tests whether 'guild compile' leaves traces
# behind it upon SIGINT.

source="t-guild-compile-$$"
target="$source.go"

trap 'rm -f "$source" "$target"' EXIT

cat > "$source"<<EOF
(eval-when (expand load eval)
  ;; Wait for SIGINT, if the pause function exists.
  (if (defined? 'pause) (pause) (exit 77))

  ;; Then sleep so that the SIGINT handler gets to run
  ;; and compilation doesn't complete before it runs.
  (sleep 100))
(define chbouib 42)
EOF

guild compile -o "$target" "$source" &
pid="$!"

# Send SIGINT.
sleep 2 && kill -INT "$pid"

# Wait for 'guild compile' to terminate.
sleep 2

# Check whether there are any leftovers.
for file in "$target"*
do
    if test "$file" != "${target}*"
    then
	echo "error: 'guild compile' failed to remove '$file'" >&2
	rm "$target"*
	kill "$pid"
	exit 1
    fi
done

if test -f "$target"
then
    echo "error: '$target' produced" >&2
    exit 1
fi