shtest-shell.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. # Check the internal shell handling component of the ShTest format.
  2. #
  3. # RUN: not %{lit} -j 1 -v %{inputs}/shtest-shell > %t.out
  4. # FIXME: Temporarily dump test output so we can debug failing tests on
  5. # buildbots.
  6. # RUN: cat %t.out
  7. # RUN: FileCheck --input-file %t.out %s
  8. #
  9. # END.
  10. # CHECK: -- Testing:
  11. # CHECK: FAIL: shtest-shell :: cat-error-0.txt
  12. # CHECK: *** TEST 'shtest-shell :: cat-error-0.txt' FAILED ***
  13. # CHECK: $ "cat" "-b" "temp1.txt"
  14. # CHECK: # command stderr:
  15. # CHECK: Unsupported: 'cat': option -b not recognized
  16. # CHECK: error: command failed with exit status: 1
  17. # CHECK: ***
  18. # CHECK: FAIL: shtest-shell :: cat-error-1.txt
  19. # CHECK: *** TEST 'shtest-shell :: cat-error-1.txt' FAILED ***
  20. # CHECK: $ "cat" "temp1.txt"
  21. # CHECK: # command stderr:
  22. # CHECK: [Errno 2] No such file or directory: 'temp1.txt'
  23. # CHECK: error: command failed with exit status: 1
  24. # CHECK: ***
  25. # CHECK: FAIL: shtest-shell :: colon-error.txt
  26. # CHECK: *** TEST 'shtest-shell :: colon-error.txt' FAILED ***
  27. # CHECK: $ ":"
  28. # CHECK: # command stderr:
  29. # CHECK: Unsupported: ':' cannot be part of a pipeline
  30. # CHECK: error: command failed with exit status: 127
  31. # CHECK: ***
  32. # CHECK: FAIL: shtest-shell :: diff-encodings.txt
  33. # CHECK: *** TEST 'shtest-shell :: diff-encodings.txt' FAILED ***
  34. # CHECK: $ "diff" "-u" "diff-in.bin" "diff-in.bin"
  35. # CHECK-NOT: error
  36. # CHECK: $ "diff" "-u" "diff-in.utf16" "diff-in.bin"
  37. # CHECK: # command output:
  38. # CHECK-NEXT: ---
  39. # CHECK-NEXT: +++
  40. # CHECK-NEXT: @@
  41. # CHECK-NEXT: {{^ .f.o.o.$}}
  42. # CHECK-NEXT: {{^-.b.a.r.$}}
  43. # CHECK-NEXT: {{^\+.b.a.r..}}
  44. # CHECK-NEXT: {{^ .b.a.z.$}}
  45. # CHECK: error: command failed with exit status: 1
  46. # CHECK: $ "true"
  47. # CHECK: $ "diff" "-u" "diff-in.utf8" "diff-in.bin"
  48. # CHECK: # command output:
  49. # CHECK-NEXT: ---
  50. # CHECK-NEXT: +++
  51. # CHECK-NEXT: @@
  52. # CHECK-NEXT: -foo
  53. # CHECK-NEXT: -bar
  54. # CHECK-NEXT: -baz
  55. # CHECK-NEXT: {{^\+.f.o.o.$}}
  56. # CHECK-NEXT: {{^\+.b.a.r..}}
  57. # CHECK-NEXT: {{^\+.b.a.z.$}}
  58. # CHECK: error: command failed with exit status: 1
  59. # CHECK: $ "true"
  60. # CHECK: $ "diff" "-u" "diff-in.bin" "diff-in.utf8"
  61. # CHECK: # command output:
  62. # CHECK-NEXT: ---
  63. # CHECK-NEXT: +++
  64. # CHECK-NEXT: @@
  65. # CHECK-NEXT: {{^\-.f.o.o.$}}
  66. # CHECK-NEXT: {{^\-.b.a.r..}}
  67. # CHECK-NEXT: {{^\-.b.a.z.$}}
  68. # CHECK-NEXT: +foo
  69. # CHECK-NEXT: +bar
  70. # CHECK-NEXT: +baz
  71. # CHECK: error: command failed with exit status: 1
  72. # CHECK: $ "true"
  73. # CHECK: $ "false"
  74. # CHECK: ***
  75. # CHECK: FAIL: shtest-shell :: diff-error-0.txt
  76. # CHECK: *** TEST 'shtest-shell :: diff-error-0.txt' FAILED ***
  77. # CHECK: $ "diff" "diff-error-0.txt" "diff-error-0.txt"
  78. # CHECK: # command stderr:
  79. # CHECK: Unsupported: 'diff' cannot be part of a pipeline
  80. # CHECK: error: command failed with exit status: 127
  81. # CHECK: ***
  82. # CHECK: FAIL: shtest-shell :: diff-error-1.txt
  83. # CHECK: *** TEST 'shtest-shell :: diff-error-1.txt' FAILED ***
  84. # CHECK: $ "diff" "-B" "temp1.txt" "temp2.txt"
  85. # CHECK: # command stderr:
  86. # CHECK: Unsupported: 'diff': option -B not recognized
  87. # CHECK: error: command failed with exit status: 127
  88. # CHECK: ***
  89. # CHECK: FAIL: shtest-shell :: diff-error-2.txt
  90. # CHECK: *** TEST 'shtest-shell :: diff-error-2.txt' FAILED ***
  91. # CHECK: $ "diff" "temp.txt"
  92. # CHECK: # command stderr:
  93. # CHECK: Error: missing or extra operand
  94. # CHECK: error: command failed with exit status: 127
  95. # CHECK: ***
  96. # CHECK: FAIL: shtest-shell :: diff-error-3.txt
  97. # CHECK: *** TEST 'shtest-shell :: diff-error-3.txt' FAILED ***
  98. # CHECK: $ "diff" "temp.txt" "temp1.txt"
  99. # CHECK: # command stderr:
  100. # CHECK: Error: 'diff' command failed
  101. # CHECK: error: command failed with exit status: 1
  102. # CHECK: ***
  103. # CHECK: FAIL: shtest-shell :: diff-error-4.txt
  104. # CHECK: *** TEST 'shtest-shell :: diff-error-4.txt' FAILED ***
  105. # CHECK: Exit Code: 1
  106. # CHECK: # command output:
  107. # CHECK: diff-error-4.txt.tmp
  108. # CHECK: diff-error-4.txt.tmp1
  109. # CHECK: *** 1 ****
  110. # CHECK: ! hello-first
  111. # CHECK: --- 1 ----
  112. # CHECK: ! hello-second
  113. # CHECK: ***
  114. # CHECK: FAIL: shtest-shell :: diff-error-5.txt
  115. # CHECK: *** TEST 'shtest-shell :: diff-error-5.txt' FAILED ***
  116. # CHECK: $ "diff"
  117. # CHECK: # command stderr:
  118. # CHECK: Error: missing or extra operand
  119. # CHECK: error: command failed with exit status: 127
  120. # CHECK: ***
  121. # CHECK: FAIL: shtest-shell :: diff-error-6.txt
  122. # CHECK: *** TEST 'shtest-shell :: diff-error-6.txt' FAILED ***
  123. # CHECK: $ "diff"
  124. # CHECK: # command stderr:
  125. # CHECK: Error: missing or extra operand
  126. # CHECK: error: command failed with exit status: 127
  127. # CHECK: ***
  128. # CHECK: FAIL: shtest-shell :: diff-r-error-0.txt
  129. # CHECK: *** TEST 'shtest-shell :: diff-r-error-0.txt' FAILED ***
  130. # CHECK: $ "diff" "-r"
  131. # CHECK: # command output:
  132. # CHECK: Only in {{.*}}dir1: dir1unique
  133. # CHECK: Only in {{.*}}dir2: dir2unique
  134. # CHECK: error: command failed with exit status: 1
  135. # CHECK: FAIL: shtest-shell :: diff-r-error-1.txt
  136. # CHECK: *** TEST 'shtest-shell :: diff-r-error-1.txt' FAILED ***
  137. # CHECK: $ "diff" "-r"
  138. # CHECK: # command output:
  139. # CHECK: *** {{.*}}dir1{{.*}}subdir{{.*}}f01
  140. # CHECK: --- {{.*}}dir2{{.*}}subdir{{.*}}f01
  141. # CHECK: 12345
  142. # CHECK: 00000
  143. # CHECK: error: command failed with exit status: 1
  144. # CHECK: FAIL: shtest-shell :: diff-r-error-2.txt
  145. # CHECK: *** TEST 'shtest-shell :: diff-r-error-2.txt' FAILED ***
  146. # CHECK: $ "diff" "-r"
  147. # CHECK: # command output:
  148. # CHECK: Only in {{.*}}dir2: extrafile
  149. # CHECK: error: command failed with exit status: 1
  150. # CHECK: FAIL: shtest-shell :: diff-r-error-3.txt
  151. # CHECK: *** TEST 'shtest-shell :: diff-r-error-3.txt' FAILED ***
  152. # CHECK: $ "diff" "-r"
  153. # CHECK: # command output:
  154. # CHECK: Only in {{.*}}dir1: extra_subdir
  155. # CHECK: error: command failed with exit status: 1
  156. # CHECK: FAIL: shtest-shell :: diff-r-error-4.txt
  157. # CHECK: *** TEST 'shtest-shell :: diff-r-error-4.txt' FAILED ***
  158. # CHECK: $ "diff" "-r"
  159. # CHECK: # command output:
  160. # CHECK: File {{.*}}dir1{{.*}}extra_subdir is a directory while file {{.*}}dir2{{.*}}extra_subdir is a regular file
  161. # CHECK: error: command failed with exit status: 1
  162. # CHECK: FAIL: shtest-shell :: diff-r-error-5.txt
  163. # CHECK: *** TEST 'shtest-shell :: diff-r-error-5.txt' FAILED ***
  164. # CHECK: $ "diff" "-r"
  165. # CHECK: # command output:
  166. # CHECK: Only in {{.*}}dir1: extra_subdir
  167. # CHECK: error: command failed with exit status: 1
  168. # CHECK: FAIL: shtest-shell :: diff-r-error-6.txt
  169. # CHECK: *** TEST 'shtest-shell :: diff-r-error-6.txt' FAILED ***
  170. # CHECK: $ "diff" "-r"
  171. # CHECK: # command output:
  172. # CHECK: File {{.*}}dir1{{.*}}extra_file is a regular empty file while file {{.*}}dir2{{.*}}extra_file is a directory
  173. # CHECK: error: command failed with exit status: 1
  174. # CHECK: PASS: shtest-shell :: diff-r.txt
  175. # CHECK: FAIL: shtest-shell :: diff-strip-trailing-cr.txt
  176. # CHECK: *** TEST 'shtest-shell :: diff-strip-trailing-cr.txt' FAILED ***
  177. # CHECK: $ "diff" "-u" "diff-in.dos" "diff-in.unix"
  178. # CHECK: # command output:
  179. # CHECK: @@
  180. # CHECK-NEXT: -In this file, the
  181. # CHECK-NEXT: -sequence "\r\n"
  182. # CHECK-NEXT: -terminates lines.
  183. # CHECK-NEXT: +In this file, the
  184. # CHECK-NEXT: +sequence "\n"
  185. # CHECK-NEXT: +terminates lines.
  186. # CHECK: error: command failed with exit status: 1
  187. # CHECK: $ "true"
  188. # CHECK: $ "diff" "-u" "diff-in.unix" "diff-in.dos"
  189. # CHECK: # command output:
  190. # CHECK: @@
  191. # CHECK-NEXT: -In this file, the
  192. # CHECK-NEXT: -sequence "\n"
  193. # CHECK-NEXT: -terminates lines.
  194. # CHECK-NEXT: +In this file, the
  195. # CHECK-NEXT: +sequence "\r\n"
  196. # CHECK-NEXT: +terminates lines.
  197. # CHECK: error: command failed with exit status: 1
  198. # CHECK: $ "true"
  199. # CHECK: $ "diff" "-u" "--strip-trailing-cr" "diff-in.dos" "diff-in.unix"
  200. # CHECK: # command output:
  201. # CHECK: @@
  202. # CHECK-NEXT: In this file, the
  203. # CHECK-NEXT: -sequence "\r\n"
  204. # CHECK-NEXT: +sequence "\n"
  205. # CHECK-NEXT: terminates lines.
  206. # CHECK: error: command failed with exit status: 1
  207. # CHECK: $ "true"
  208. # CHECK: $ "diff" "-u" "--strip-trailing-cr" "diff-in.unix" "diff-in.dos"
  209. # CHECK: # command output:
  210. # CHECK: @@
  211. # CHECK-NEXT: In this file, the
  212. # CHECK-NEXT: -sequence "\n"
  213. # CHECK-NEXT: +sequence "\r\n"
  214. # CHECK-NEXT: terminates lines.
  215. # CHECK: error: command failed with exit status: 1
  216. # CHECK: $ "true"
  217. # CHECK: $ "false"
  218. # CHECK: ***
  219. # CHECK: FAIL: shtest-shell :: diff-unified-error-0.txt
  220. # CHECK: *** TEST 'shtest-shell :: diff-unified-error-0.txt' FAILED ***
  221. # CHECK: $ "diff" "-U" "30.1" "{{[^"]*}}" "{{[^"]*}}"
  222. # CHECK: # command stderr:
  223. # CHECK: Error: invalid '-U' argument: 30.1
  224. # CHECK: error: command failed with exit status: 127
  225. # CHECK: ***
  226. # CHECK: FAIL: shtest-shell :: diff-unified-error-1.txt
  227. # CHECK: *** TEST 'shtest-shell :: diff-unified-error-1.txt' FAILED ***
  228. # CHECK: $ "diff" "-U-1" "{{[^"]*}}" "{{[^"]*}}"
  229. # CHECK: # command stderr:
  230. # CHECK: Error: invalid '-U' argument: -1
  231. # CHECK: error: command failed with exit status: 127
  232. # CHECK: ***
  233. # CHECK: FAIL: shtest-shell :: diff-unified.txt
  234. # CHECK: *** TEST 'shtest-shell :: diff-unified.txt' FAILED ***
  235. # CHECK: $ "diff" "-u" "{{[^"]*}}.foo" "{{[^"]*}}.bar"
  236. # CHECK: # command output:
  237. # CHECK: @@ {{.*}} @@
  238. # CHECK-NEXT: 3
  239. # CHECK-NEXT: 4
  240. # CHECK-NEXT: 5
  241. # CHECK-NEXT: -6 foo
  242. # CHECK-NEXT: +6 bar
  243. # CHECK-NEXT: 7
  244. # CHECK-NEXT: 8
  245. # CHECK-NEXT: 9
  246. # CHECK-EMPTY:
  247. # CHECK-NEXT: error: command failed with exit status: 1
  248. # CHECK-NEXT: $ "true"
  249. # CHECK: $ "diff" "-U" "2" "{{[^"]*}}.foo" "{{[^"]*}}.bar"
  250. # CHECK: # command output:
  251. # CHECK: @@ {{.*}} @@
  252. # CHECK-NEXT: 4
  253. # CHECK-NEXT: 5
  254. # CHECK-NEXT: -6 foo
  255. # CHECK-NEXT: +6 bar
  256. # CHECK-NEXT: 7
  257. # CHECK-NEXT: 8
  258. # CHECK-EMPTY:
  259. # CHECK-NEXT: error: command failed with exit status: 1
  260. # CHECK-NEXT: $ "true"
  261. # CHECK: $ "diff" "-U4" "{{[^"]*}}.foo" "{{[^"]*}}.bar"
  262. # CHECK: # command output:
  263. # CHECK: @@ {{.*}} @@
  264. # CHECK-NEXT: 2
  265. # CHECK-NEXT: 3
  266. # CHECK-NEXT: 4
  267. # CHECK-NEXT: 5
  268. # CHECK-NEXT: -6 foo
  269. # CHECK-NEXT: +6 bar
  270. # CHECK-NEXT: 7
  271. # CHECK-NEXT: 8
  272. # CHECK-NEXT: 9
  273. # CHECK-NEXT: 10
  274. # CHECK-EMPTY:
  275. # CHECK-NEXT: error: command failed with exit status: 1
  276. # CHECK-NEXT: $ "true"
  277. # CHECK: $ "diff" "-U0" "{{[^"]*}}.foo" "{{[^"]*}}.bar"
  278. # CHECK: # command output:
  279. # CHECK: @@ {{.*}} @@
  280. # CHECK-NEXT: -6 foo
  281. # CHECK-NEXT: +6 bar
  282. # CHECK-EMPTY:
  283. # CHECK-NEXT: error: command failed with exit status: 1
  284. # CHECK-NEXT: $ "true"
  285. # CHECK: $ "false"
  286. # CHECK: ***
  287. # CHECK: FAIL: shtest-shell :: error-0.txt
  288. # CHECK: *** TEST 'shtest-shell :: error-0.txt' FAILED ***
  289. # CHECK: $ "not-a-real-command"
  290. # CHECK: # command stderr:
  291. # CHECK: 'not-a-real-command': command not found
  292. # CHECK: error: command failed with exit status: 127
  293. # CHECK: ***
  294. # FIXME: The output here sucks.
  295. #
  296. # CHECK: FAIL: shtest-shell :: error-1.txt
  297. # CHECK: *** TEST 'shtest-shell :: error-1.txt' FAILED ***
  298. # CHECK: shell parser error on: ': \'RUN: at line 3\'; echo "missing quote'
  299. # CHECK: ***
  300. # CHECK: FAIL: shtest-shell :: error-2.txt
  301. # CHECK: *** TEST 'shtest-shell :: error-2.txt' FAILED ***
  302. # CHECK: Unsupported redirect:
  303. # CHECK: ***
  304. # CHECK: FAIL: shtest-shell :: mkdir-error-0.txt
  305. # CHECK: *** TEST 'shtest-shell :: mkdir-error-0.txt' FAILED ***
  306. # CHECK: $ "mkdir" "-p" "temp"
  307. # CHECK: # command stderr:
  308. # CHECK: Unsupported: 'mkdir' cannot be part of a pipeline
  309. # CHECK: error: command failed with exit status: 127
  310. # CHECK: ***
  311. # CHECK: FAIL: shtest-shell :: mkdir-error-1.txt
  312. # CHECK: *** TEST 'shtest-shell :: mkdir-error-1.txt' FAILED ***
  313. # CHECK: $ "mkdir" "-p" "-m" "777" "temp"
  314. # CHECK: # command stderr:
  315. # CHECK: Unsupported: 'mkdir': option -m not recognized
  316. # CHECK: error: command failed with exit status: 127
  317. # CHECK: ***
  318. # CHECK: FAIL: shtest-shell :: mkdir-error-2.txt
  319. # CHECK: *** TEST 'shtest-shell :: mkdir-error-2.txt' FAILED ***
  320. # CHECK: $ "mkdir" "-p"
  321. # CHECK: # command stderr:
  322. # CHECK: Error: 'mkdir' is missing an operand
  323. # CHECK: error: command failed with exit status: 127
  324. # CHECK: ***
  325. # CHECK: PASS: shtest-shell :: redirects.txt
  326. # CHECK: FAIL: shtest-shell :: rm-error-0.txt
  327. # CHECK: *** TEST 'shtest-shell :: rm-error-0.txt' FAILED ***
  328. # CHECK: $ "rm" "-rf" "temp"
  329. # CHECK: # command stderr:
  330. # CHECK: Unsupported: 'rm' cannot be part of a pipeline
  331. # CHECK: error: command failed with exit status: 127
  332. # CHECK: ***
  333. # CHECK: FAIL: shtest-shell :: rm-error-1.txt
  334. # CHECK: *** TEST 'shtest-shell :: rm-error-1.txt' FAILED ***
  335. # CHECK: $ "rm" "-f" "-v" "temp"
  336. # CHECK: # command stderr:
  337. # CHECK: Unsupported: 'rm': option -v not recognized
  338. # CHECK: error: command failed with exit status: 127
  339. # CHECK: ***
  340. # CHECK: FAIL: shtest-shell :: rm-error-2.txt
  341. # CHECK: *** TEST 'shtest-shell :: rm-error-2.txt' FAILED ***
  342. # CHECK: $ "rm" "-r" "hello"
  343. # CHECK: # command stderr:
  344. # CHECK: Error: 'rm' command failed
  345. # CHECK: error: command failed with exit status: 1
  346. # CHECK: ***
  347. # CHECK: FAIL: shtest-shell :: rm-error-3.txt
  348. # CHECK: *** TEST 'shtest-shell :: rm-error-3.txt' FAILED ***
  349. # CHECK: Exit Code: 1
  350. # CHECK: ***
  351. # CHECK: PASS: shtest-shell :: rm-unicode-0.txt
  352. # CHECK: PASS: shtest-shell :: sequencing-0.txt
  353. # CHECK: XFAIL: shtest-shell :: sequencing-1.txt
  354. # CHECK: PASS: shtest-shell :: valid-shell.txt
  355. # CHECK: Failing Tests (32)