Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

58 řádky
1.4 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. # -------------------------------------------------------------------
  25. 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
  26. expect {
  27. error { abort "failed to compile" }
  28. eof { abort "didn't run clang" }
  29. clang
  30. }
  31. expect {
  32. error { abort "failed to link" }
  33. eof { abort "didn't run ld" }
  34. ld
  35. }
  36. expect eof
  37. lassign [wait] pid spawnid os_error_flag value
  38. if {$value != 0} {
  39. abort "compiler crashed"
  40. }
  41. # -------------------------------------------------------------------
  42. spawn -noecho /tmp/sugar.generated.$BUILD_NAME
  43. expect {
  44. error { abort "failed to compile" }
  45. eof { abort "didn't output" }
  46. Hello
  47. }
  48. expect eof
  49. lassign [wait] pid spawnid os_error_flag value
  50. if {$value != 1} {
  51. abort "executable didn't return exit code 1 but $value instead"
  52. }