| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# This -*- sh -*- script tests whether 'guild compile' leaves traces |
| 4 |
# behind it upon SIGINT. |
| 5 |
|
| 6 |
source="t-guild-compile-$$" |
| 7 |
target="$source.go" |
| 8 |
|
| 9 |
trap 'rm -f "$source" "$target"' EXIT |
| 10 |
|
| 11 |
cat > "$source"<<EOF |
| 12 |
(eval-when (expand load eval) |
| 13 |
;; Wait for SIGINT, if the pause function exists. |
| 14 |
(if (defined? 'pause) (pause) (exit 77)) |
| 15 |
|
| 16 |
;; Then sleep so that the SIGINT handler gets to run |
| 17 |
;; and compilation doesn't complete before it runs. |
| 18 |
(sleep 100)) |
| 19 |
(define chbouib 42) |
| 20 |
EOF |
| 21 |
|
| 22 |
guild compile -o "$target" "$source" & |
| 23 |
pid="$!" |
| 24 |
|
| 25 |
# Send SIGINT. |
| 26 |
sleep 2 && kill -INT "$pid" |
| 27 |
|
| 28 |
# Wait for 'guild compile' to terminate. |
| 29 |
sleep 2 |
| 30 |
|
| 31 |
# Check whether there are any leftovers. |
| 32 |
for file in "$target"* |
| 33 |
do |
| 34 |
if test "$file" != "${target}*" |
| 35 |
then |
| 36 |
echo "error: 'guild compile' failed to remove '$file'" >&2 |
| 37 |
rm "$target"* |
| 38 |
kill "$pid" |
| 39 |
exit 1 |
| 40 |
fi |
| 41 |
done |
| 42 |
|
| 43 |
if test -f "$target" |
| 44 |
then |
| 45 |
echo "error: '$target' produced" >&2 |
| 46 |
exit 1 |
| 47 |
fi |