Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

173 рядки
4.0 KiB

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