選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

54 行
1.3 KiB

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