You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
1.8 KiB

  1. #!/usr/bin/expect
  2. set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE)
  3. set BUILD_NAME 005.
  4. proc abort {reason} {
  5. puts "test failed $reason"
  6. exit 1
  7. }
  8. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all
  9. expect {
  10. error { abort "failed to parse" }
  11. eof { abort "cannot find the symbol main in lexed output" }
  12. main
  13. }
  14. expect eof
  15. lassign [wait] pid spawnid os_error_flag value
  16. if {$value != 0} {
  17. abort "compiler crashed"
  18. }
  19. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
  20. expect {
  21. error { abort "failed to parse" }
  22. eof { abort "cannot find the main procedure" }
  23. main
  24. }
  25. expect eof
  26. lassign [wait] pid spawnid os_error_flag value
  27. if {$value != 0} {
  28. abort "compiler crashed"
  29. }
  30. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
  31. expect {
  32. error { abort "failed to parse" }
  33. eof { abort "cannot find the exit-syscall-number procedure" }
  34. exit-syscall-number
  35. }
  36. expect eof
  37. lassign [wait] pid spawnid os_error_flag value
  38. if {$value != 0} {
  39. abort "compiler crashed"
  40. }
  41. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol lex tests/005/library.mol lex merge parse /tmp/sugar.generated.$BUILD_NAME generate assemble
  42. expect {
  43. error { abort "failed to compile" }
  44. eof { abort "didn't run clang" }
  45. clang
  46. }
  47. expect {
  48. error { abort "failed to link" }
  49. eof { abort "didn't run ld" }
  50. ld
  51. }
  52. expect eof
  53. lassign [wait] pid spawnid os_error_flag value
  54. if {$value != 0} {
  55. abort "compiler crashed"
  56. }
  57. spawn -noecho /tmp/sugar.generated.$BUILD_NAME
  58. expect {
  59. error { abort "failed to compile" }
  60. eof { abort "didn't output" }
  61. Hello
  62. }
  63. expect eof
  64. lassign [wait] pid spawnid os_error_flag value
  65. if {$value != 3} {
  66. abort "executable didn't return exit code 3 but $value instead"
  67. }