tap-recheck.sh 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. # Test the 'recheck' target for TAP test protocol.
  17. # Keep in sync with 'test-driver-custom-multitest-recheck.sh'.
  18. . test-init.sh
  19. fetch_tap_driver
  20. cat >> configure.ac <<END
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. TEST_LOG_DRIVER = $(srcdir)/tap-driver
  25. TESTS = a.test b.test c.test d.test
  26. END
  27. cat > a.test << 'END'
  28. #! /bin/sh
  29. echo 1..2
  30. echo ok 1
  31. echo ok 2
  32. : > a.run
  33. END
  34. cat > b.test << 'END'
  35. #! /bin/sh
  36. : > b.run
  37. echo 1..2
  38. echo ok 1
  39. if test -f b.ok; then
  40. echo ok 2
  41. else
  42. echo 'Bail out!'
  43. fi
  44. END
  45. cat > c.test << 'END'
  46. #! /bin/sh
  47. echo 1..3
  48. if test -f c.pass; then
  49. echo 'ok - c is ok :-)'
  50. else
  51. echo 'not ok - c is ko :-('
  52. fi
  53. if test -f c.xfail; then
  54. echo 'not ok 2 # TODO'
  55. else
  56. echo 'ok 2 # TODO'
  57. fi
  58. echo 'not ok 3 - blah blah # TODO need better diagnostic'
  59. : > c.run
  60. END
  61. cat > d.test << 'END'
  62. #! /bin/sh
  63. test -f ./d.count && . ./d.count
  64. echo 1..${test_count-2}
  65. echo ok 1 '# SKIP: who cares ...'
  66. (. ./d.extra) || echo 'not ok 2 - d.extra failed'
  67. : > d.run
  68. END
  69. chmod a+x *.test
  70. $ACLOCAL
  71. $AUTOCONF
  72. $AUTOMAKE
  73. do_recheck ()
  74. {
  75. case $* in
  76. --fail) status=FAIL;;
  77. --pass) status=0;;
  78. *) fatal_ "invalid usage of function 'do_recheck'";;
  79. esac
  80. rm -f *.run
  81. run_make -O -e $status recheck || { ls -l; exit 1; }
  82. ls -l
  83. }
  84. for vpath in : false; do
  85. if $vpath; then
  86. mkdir build
  87. cd build
  88. srcdir=..
  89. else
  90. srcdir=.
  91. fi
  92. $srcdir/configure
  93. : A "make recheck" in a clean tree should run no tests.
  94. do_recheck --pass
  95. cat test-suite.log
  96. test ! -e a.run
  97. test ! -e a.log
  98. test ! -e b.run
  99. test ! -e b.log
  100. test ! -e c.run
  101. test ! -e c.log
  102. test ! -e d.run
  103. test ! -e d.log
  104. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  105. : Run the tests for the first time.
  106. run_make -O -e FAIL check
  107. ls -l
  108. # All the test scripts should have run.
  109. test -f a.run
  110. test -f b.run
  111. test -f c.run
  112. test -f d.run
  113. count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
  114. : Let us make b.test pass.
  115. using_gmake || $sleep # Required by BSD make.
  116. echo OK > b.ok
  117. do_recheck --fail
  118. # a.test has been successful the first time, so no need to re-run it.
  119. # Similar considerations apply to similar checks, below.
  120. test ! -e a.run
  121. test -f b.run
  122. test -f c.run
  123. test -f d.run
  124. count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
  125. : Let us make the first part of c.test pass.
  126. using_gmake || $sleep # Required by BSD make.
  127. echo OK > c.pass
  128. do_recheck --fail
  129. test ! -e a.run
  130. test ! -e b.run
  131. test -f c.run
  132. test -f d.run
  133. count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
  134. : Let us make also the second part of c.test pass.
  135. using_gmake || $sleep # Required by BSD make.
  136. echo KO > c.xfail
  137. do_recheck --fail
  138. test ! -e a.run
  139. test ! -e b.run
  140. test -f c.run
  141. test -f d.run
  142. count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
  143. : Nothing changed, so only d.test should be run.
  144. for i in 1 2; do
  145. using_gmake || $sleep # Required by BSD make.
  146. do_recheck --fail
  147. test ! -e a.run
  148. test ! -e b.run
  149. test ! -e c.run
  150. test -f d.run
  151. count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
  152. done
  153. : Let us make d.test run more testcases, and experience _more_ failures.
  154. using_gmake || $sleep # Required by BSD make.
  155. echo 'test_count=9' > d.count
  156. unindent > d.extra <<'END'
  157. echo 'ok # SKIP s'
  158. echo 'not ok - f 1'
  159. echo 'ok - p 1'
  160. echo 'not ok - f 2'
  161. echo 'ok # TODO xp'
  162. echo 'not ok - f 3'
  163. echo 'not ok - f 4'
  164. echo 'ok - p 2'
  165. echo 'ok' # Extra test.
  166. echo 'Bail out!'
  167. END
  168. do_recheck --fail
  169. test ! -e a.run
  170. test ! -e b.run
  171. test ! -e c.run
  172. test -f d.run
  173. count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
  174. : Let us finally make d.test pass.
  175. using_gmake || $sleep # Required by BSD make.
  176. echo 'test_count=1' > d.count
  177. echo : > d.extra
  178. do_recheck --pass
  179. test ! -e a.run
  180. test ! -e b.run
  181. test ! -e c.run
  182. test -f d.run
  183. count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
  184. : All tests have been successful or skipped, nothing should be re-run.
  185. using_gmake || $sleep # Required by BSD make.
  186. do_recheck --pass
  187. test ! -e a.run
  188. test ! -e b.run
  189. test ! -e c.run
  190. test ! -e d.run
  191. count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
  192. cd $srcdir
  193. done
  194. :