tap-summary-aux.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Auxiliary script for tests on TAP support: checking testsuite summary.
  17. . test-init.sh
  18. br='============================================================================'
  19. case $use_colors in
  20. yes|no) ;;
  21. *) fatal_ "invalid \$use_colors value '$use_colors'"
  22. esac
  23. fetch_tap_driver
  24. cat > configure.ac <<END
  25. AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org])
  26. AM_INIT_AUTOMAKE
  27. AC_CONFIG_FILES([Makefile])
  28. AC_OUTPUT
  29. END
  30. cat > Makefile.am << 'END'
  31. TEST_LOG_DRIVER = $(srcdir)/tap-driver
  32. TEST_LOG_COMPILER = cat
  33. TESTS = all.test
  34. END
  35. # The following shell variables are influential for this function:
  36. # - expect_failure
  37. # - use_colors
  38. do_check ()
  39. {
  40. case $#,$1 in
  41. 1,--pass) expect_failure=no;;
  42. 1,--fail) expect_failure=yes;;
  43. *) fatal_ "invalid usage of 'do_check'";;
  44. esac
  45. shift
  46. cat > summary.exp
  47. cat all.test
  48. if test $use_colors = yes; then
  49. # Forced colorization should take place also with non-ANSI terminals;
  50. # hence the "TERM=dumb" definition.
  51. make_args='TERM=dumb AM_COLOR_TESTS=always'
  52. else
  53. make_args=
  54. fi
  55. run_make -O -e IGNORE $make_args check
  56. if test $expect_failure = yes; then
  57. test $am_make_rc -gt 0 || exit 1
  58. else
  59. test $am_make_rc -eq 0 || exit 1
  60. fi
  61. $PERL "$am_testaux_srcdir"/extract-testsuite-summary.pl stdout >summary.got \
  62. || fatal_ "cannot extract testsuite summary"
  63. cat summary.exp
  64. cat summary.got
  65. if test $use_colors = yes; then
  66. # Use cmp, not diff, because the files might contain binary data.
  67. compare=cmp
  68. else
  69. compare=diff
  70. fi
  71. $compare summary.exp summary.got || exit 1
  72. }
  73. if test $use_colors = yes; then
  74. red="$esc[0;31m"
  75. grn="$esc[0;32m"
  76. lgn="$esc[1;32m"
  77. blu="$esc[1;34m"
  78. mgn="$esc[0;35m"
  79. brg="$esc[1m"
  80. std="$esc[m"
  81. else
  82. red= grn= lgn= blu= mgn= brg= std=
  83. fi
  84. success_header="\
  85. ${grn}${br}${std}
  86. ${grn}Testsuite summary for GNU AutoTAP 5.12${std}
  87. ${grn}${br}${std}"
  88. success_footer=${grn}${br}${std}
  89. failure_header="\
  90. ${red}${br}${std}
  91. ${red}Testsuite summary for GNU AutoTAP 5.12${std}
  92. ${red}${br}${std}"
  93. failure_footer="\
  94. ${red}${br}${std}
  95. ${red}See ./test-suite.log${std}
  96. ${red}Please report to bug-automake@gnu.org${std}
  97. ${red}${br}${std}"
  98. $ACLOCAL
  99. $AUTOCONF
  100. $AUTOMAKE --add-missing
  101. ./configure
  102. # 1 pass.
  103. { echo 1..1 && echo ok; } > all.test
  104. do_check --pass <<END
  105. $success_header
  106. ${brg}# TOTAL: 1${std}
  107. ${grn}# PASS: 1${std}
  108. # SKIP: 0
  109. # XFAIL: 0
  110. # FAIL: 0
  111. # XPASS: 0
  112. # ERROR: 0
  113. $success_footer
  114. END
  115. # 1 skip.
  116. { echo 1..1 && echo 'ok # SKIP'; } > all.test
  117. do_check --pass <<END
  118. $success_header
  119. ${brg}# TOTAL: 1${std}
  120. # PASS: 0
  121. ${blu}# SKIP: 1${std}
  122. # XFAIL: 0
  123. # FAIL: 0
  124. # XPASS: 0
  125. # ERROR: 0
  126. $success_footer
  127. END
  128. # 1 xfail.
  129. { echo 1..1 && echo 'not ok # TODO'; } > all.test
  130. do_check --pass <<END
  131. $success_header
  132. ${brg}# TOTAL: 1${std}
  133. # PASS: 0
  134. # SKIP: 0
  135. ${lgn}# XFAIL: 1${std}
  136. # FAIL: 0
  137. # XPASS: 0
  138. # ERROR: 0
  139. $success_footer
  140. END
  141. # 1 fail.
  142. { echo 1..1 && echo not ok; } > all.test
  143. do_check --fail <<END
  144. $failure_header
  145. ${brg}# TOTAL: 1${std}
  146. # PASS: 0
  147. # SKIP: 0
  148. # XFAIL: 0
  149. ${red}# FAIL: 1${std}
  150. # XPASS: 0
  151. # ERROR: 0
  152. $failure_footer
  153. END
  154. # 1 xpass.
  155. { echo 1..1 && echo 'ok # TODO'; } > all.test
  156. do_check --fail <<END
  157. $failure_header
  158. ${brg}# TOTAL: 1${std}
  159. # PASS: 0
  160. # SKIP: 0
  161. # XFAIL: 0
  162. # FAIL: 0
  163. ${red}# XPASS: 1${std}
  164. # ERROR: 0
  165. $failure_footer
  166. END
  167. # 1 hard error.
  168. { echo 1..1 && echo 'Bail out!'; } > all.test
  169. do_check --fail <<END
  170. $failure_header
  171. ${brg}# TOTAL: 1${std}
  172. # PASS: 0
  173. # SKIP: 0
  174. # XFAIL: 0
  175. # FAIL: 0
  176. # XPASS: 0
  177. ${mgn}# ERROR: 1${std}
  178. $failure_footer
  179. END
  180. # 3 non-failing results.
  181. cat > all.test <<END
  182. 1..3
  183. ok
  184. not ok # TODO
  185. ok # SKIP
  186. END
  187. do_check --pass <<END
  188. $success_header
  189. ${brg}# TOTAL: 3${std}
  190. ${grn}# PASS: 1${std}
  191. ${blu}# SKIP: 1${std}
  192. ${lgn}# XFAIL: 1${std}
  193. # FAIL: 0
  194. # XPASS: 0
  195. # ERROR: 0
  196. $success_footer
  197. END
  198. # 1 pass, 1 skip, 1 fail.
  199. cat > all.test <<END
  200. 1..3
  201. ok
  202. ok # SKIP
  203. not ok
  204. END
  205. do_check --fail <<END
  206. $failure_header
  207. ${brg}# TOTAL: 3${std}
  208. ${grn}# PASS: 1${std}
  209. ${blu}# SKIP: 1${std}
  210. # XFAIL: 0
  211. ${red}# FAIL: 1${std}
  212. # XPASS: 0
  213. # ERROR: 0
  214. $failure_footer
  215. END
  216. # 1 pass, 1 xfail, 1 xpass.
  217. cat > all.test <<END
  218. 1..3
  219. ok
  220. ok # TODO
  221. not ok # TODO
  222. END
  223. do_check --fail <<END
  224. $failure_header
  225. ${brg}# TOTAL: 3${std}
  226. ${grn}# PASS: 1${std}
  227. # SKIP: 0
  228. ${lgn}# XFAIL: 1${std}
  229. # FAIL: 0
  230. ${red}# XPASS: 1${std}
  231. # ERROR: 0
  232. $failure_footer
  233. END
  234. # 1 skip, 1 xfail, 1 error.
  235. cat > all.test <<END
  236. 1..3
  237. ok # SKIP
  238. not ok # TODO
  239. Bail out!
  240. END
  241. do_check --fail <<END
  242. $failure_header
  243. ${brg}# TOTAL: 3${std}
  244. # PASS: 0
  245. ${blu}# SKIP: 1${std}
  246. ${lgn}# XFAIL: 1${std}
  247. # FAIL: 0
  248. # XPASS: 0
  249. ${mgn}# ERROR: 1${std}
  250. $failure_footer
  251. END
  252. # 1 of each kind
  253. cat > all.test <<END
  254. 1..6
  255. ok
  256. not ok
  257. ok # TODO
  258. not ok # TODO
  259. ok # SKIP
  260. Bail out!
  261. END
  262. do_check --fail <<END
  263. $failure_header
  264. ${brg}# TOTAL: 6${std}
  265. ${grn}# PASS: 1${std}
  266. ${blu}# SKIP: 1${std}
  267. ${lgn}# XFAIL: 1${std}
  268. ${red}# FAIL: 1${std}
  269. ${red}# XPASS: 1${std}
  270. ${mgn}# ERROR: 1${std}
  271. $failure_footer
  272. END
  273. # Prepare some common data for later.
  274. for i in 0 1 2 3 4 5 6 7 8 9; do
  275. for j in 0 1 2 3 4 5 6 7 8 9; do
  276. echo "ok"
  277. echo "not ok # TODO"
  278. echo "ok # SKIP"
  279. done
  280. done > tap
  281. # Lots of non-failures (300 per kind).
  282. (cat tap && cat tap && cat tap) > all.test
  283. test $(wc -l <all.test) -eq 900 || exit 99 # Sanity check.
  284. echo 1..900 >> all.test # Test plan.
  285. do_check --pass <<END
  286. $success_header
  287. ${brg}# TOTAL: 900${std}
  288. ${grn}# PASS: 300${std}
  289. ${blu}# SKIP: 300${std}
  290. ${lgn}# XFAIL: 300${std}
  291. # FAIL: 0
  292. # XPASS: 0
  293. # ERROR: 0
  294. $success_footer
  295. END
  296. # 1 failure and lots of non-failures means failure.
  297. (cat tap && echo "not ok" && cat tap) > all.test
  298. test $(wc -l <all.test) -eq 601 || exit 99 # Sanity check.
  299. echo 1..601 >> all.test # Test plan.
  300. do_check --fail <<END
  301. $failure_header
  302. ${brg}# TOTAL: 601${std}
  303. ${grn}# PASS: 200${std}
  304. ${blu}# SKIP: 200${std}
  305. ${lgn}# XFAIL: 200${std}
  306. ${red}# FAIL: 1${std}
  307. # XPASS: 0
  308. # ERROR: 0
  309. $failure_footer
  310. END
  311. # 1 error and lots of non-failures means failure.
  312. (cat tap && sed 30q tap && echo 'Bail out!') > all.test
  313. test $(wc -l <all.test) -eq 331 || exit 99 # Sanity check.
  314. echo 1..331 >> all.test # Test plan.
  315. do_check --fail <<END
  316. $failure_header
  317. ${brg}# TOTAL: 331${std}
  318. ${grn}# PASS: 110${std}
  319. ${blu}# SKIP: 110${std}
  320. ${lgn}# XFAIL: 110${std}
  321. # FAIL: 0
  322. # XPASS: 0
  323. ${mgn}# ERROR: 1${std}
  324. $failure_footer
  325. END
  326. :