test-guild-compile 936 B

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