25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.1 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. # -------------------------------------------------------------------
  20. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
  21. expect {
  22. error { abort "failed to parse" }
  23. eof { abort "cannot find the main procedure" }
  24. main
  25. }
  26. expect eof
  27. lassign [wait] pid spawnid os_error_flag value
  28. if {$value != 0} {
  29. abort "compiler crashed"
  30. }
  31. # -------------------------------------------------------------------
  32. spawn -noecho $SUGAR_EXECUTABLE tests/005/exit-with-3.mol tests/005/library.mol lex-all merge-all parse
  33. expect {
  34. error { abort "failed to parse" }
  35. eof { abort "cannot find the exit-syscall-number procedure" }
  36. exit-syscall-number
  37. }
  38. expect eof
  39. lassign [wait] pid spawnid os_error_flag value
  40. if {$value != 0} {
  41. abort "compiler crashed"
  42. }
  43. # -------------------------------------------------------------------
  44. 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
  45. expect {
  46. error { abort "failed to compile" }
  47. eof { abort "didn't run clang" }
  48. clang
  49. }
  50. expect {
  51. error { abort "failed to link" }
  52. eof { abort "didn't run ld" }
  53. ld
  54. }
  55. expect eof
  56. lassign [wait] pid spawnid os_error_flag value
  57. if {$value != 0} {
  58. abort "compiler crashed"
  59. }
  60. # -------------------------------------------------------------------
  61. spawn -noecho /tmp/sugar.generated.$BUILD_NAME
  62. expect {
  63. error { abort "failed to compile" }
  64. eof { abort "didn't output" }
  65. Hello
  66. }
  67. expect eof
  68. lassign [wait] pid spawnid os_error_flag value
  69. if {$value != 3} {
  70. abort "executable didn't return exit code 3 but $value instead"
  71. }