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.

44 lines
994 B

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