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.

45 lines
1.0 KiB

  1. #!/usr/bin/expect
  2. set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE)
  3. set BUILD_NAME 001.
  4. proc abort {reason} {
  5. puts "test failed $reason"
  6. exit 1
  7. }
  8. spawn -noecho $SUGAR_EXECUTABLE tests/001/exit-with-1.mol lex parse
  9. expect {
  10. error { abort "failed to parse" }
  11. eof { abort "cannot find the main" }
  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/001/exit-with-1.mol lex parse "/tmp/sugar.generated.$BUILD_NAME" generate assemble
  20. expect {
  21. error { abort "failed to compile" }
  22. eof { abort "didn't run clang" }
  23. clang
  24. }
  25. expect {
  26. error { abort "failed to link" }
  27. eof { abort "didn't run ld" }
  28. ld
  29. }
  30. expect eof
  31. lassign [wait] pid spawnid os_error_flag value
  32. if {$value != 0} {
  33. abort "compiler crashed"
  34. }
  35. spawn -noecho /tmp/sugar.generated.$BUILD_NAME
  36. expect eof
  37. lassign [wait] pid spawnid os_error_flag value
  38. if {$value != 1} {
  39. abort "executable didn't return exit code 1 but $value instead"
  40. }