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.

55 lines
1.3 KiB

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