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.

157 lines
3.4 KiB

  1. #!/usr/bin/expect
  2. set SUGAR_EXECUTABLE $::env(SUGAR_EXECUTABLE)
  3. set BUILD_NAME 005.
  4. proc abort {reason} {
  5. puts "test failed $reason"
  6. exit 1
  7. }
  8. spawn -noecho $SUGAR_EXECUTABLE lex
  9. expect {
  10. error { abort "failed to parse" }
  11. eof { abort "failed silently" }
  12. expects
  13. }
  14. expect eof
  15. lassign [wait] pid spawnid os_error_flag value
  16. if {$value == 0} {
  17. abort "compiler didn't crash"
  18. }
  19. spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex
  20. expect {
  21. error { abort "failed to parse" }
  22. eof { abort "failed silently" }
  23. "does not exist"
  24. }
  25. expect eof
  26. lassign [wait] pid spawnid os_error_flag value
  27. if {$value == 0} {
  28. abort "compiler didn't crash"
  29. }
  30. spawn -noecho $SUGAR_EXECUTABLE "fake_01.006.not_a_file" lex-all
  31. expect {
  32. error { abort "failed to parse" }
  33. eof { abort "failed silently" }
  34. "does not exist"
  35. }
  36. expect eof
  37. lassign [wait] pid spawnid os_error_flag value
  38. if {$value == 0} {
  39. abort "compiler didn't crash"
  40. }
  41. spawn -noecho $SUGAR_EXECUTABLE "tests/005/library.mol" lex merge
  42. expect {
  43. error { abort "failed to parse" }
  44. eof { abort "failed silently" }
  45. expects
  46. }
  47. expect eof
  48. lassign [wait] pid spawnid os_error_flag value
  49. if {$value == 0} {
  50. abort "compiler didn't crash"
  51. }
  52. spawn -noecho $SUGAR_EXECUTABLE merge
  53. expect {
  54. error { abort "failed to parse" }
  55. eof { abort "failed silently" }
  56. expects
  57. }
  58. expect eof
  59. lassign [wait] pid spawnid os_error_flag value
  60. if {$value == 0} {
  61. abort "compiler didn't crash"
  62. }
  63. spawn -noecho $SUGAR_EXECUTABLE parse
  64. expect {
  65. error { abort "failed to parse" }
  66. eof { abort "failed silently" }
  67. expects
  68. }
  69. expect eof
  70. lassign [wait] pid spawnid os_error_flag value
  71. if {$value == 0} {
  72. abort "compiler didn't crash"
  73. }
  74. spawn -noecho $SUGAR_EXECUTABLE generate
  75. expect {
  76. error { abort "failed to parse" }
  77. eof { abort "failed silently" }
  78. expects
  79. }
  80. expect eof
  81. lassign [wait] pid spawnid os_error_flag value
  82. if {$value == 0} {
  83. abort "compiler didn't crash"
  84. }
  85. file delete "/tmp/006.fake_target"
  86. spawn -noecho $SUGAR_EXECUTABLE "/tmp/006.fake_target" generate
  87. expect {
  88. error { abort "failed to parse" }
  89. eof { abort "failed silently" }
  90. "parsed output"
  91. }
  92. expect eof
  93. lassign [wait] pid spawnid os_error_flag value
  94. if {$value == 0} {
  95. abort "compiler didn't crash"
  96. }
  97. if {[file exists "/tmp/006.fake_target"]} {
  98. abort "created a file even if it failed to compile anything"
  99. file delete "/tmp/006.fake_target"
  100. }
  101. spawn -noecho $SUGAR_EXECUTABLE merge-all
  102. expect {
  103. error { abort "failed to parse" }
  104. eof { abort "failed silently" }
  105. expects
  106. }
  107. expect eof
  108. lassign [wait] pid spawnid os_error_flag value
  109. if {$value == 0} {
  110. abort "compiler didn't crash"
  111. }
  112. spawn -noecho $SUGAR_EXECUTABLE assemble
  113. expect {
  114. error { abort "failed to parse" }
  115. eof { abort "failed silently" }
  116. expects
  117. }
  118. expect eof
  119. lassign [wait] pid spawnid os_error_flag value
  120. if {$value == 0} {
  121. abort "compiler didn't crash"
  122. }
  123. spawn -noecho $SUGAR_EXECUTABLE help
  124. expect {
  125. error { abort "failed to parse" }
  126. eof { abort "failed silently" }
  127. Commands
  128. }
  129. expect eof
  130. lassign [wait] pid spawnid os_error_flag value
  131. if {$value != 0} {
  132. abort "compiler crashed displaying help"
  133. }
  134. spawn -noecho $SUGAR_EXECUTABLE --help
  135. expect {
  136. error { abort "failed to parse" }
  137. eof { abort "failed silently" }
  138. Commands
  139. }
  140. expect eof
  141. lassign [wait] pid spawnid os_error_flag value
  142. if {$value != 0} {
  143. abort "compiler crashed displaying help"
  144. }