tap-global-result.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. # TAP support:
  17. # - which global test result derives from different test results
  18. # mixed in a single script?
  19. . test-init.sh
  20. . tap-setup.sh
  21. cat > ok.test <<END
  22. 1..3
  23. ok 1
  24. not ok 2 # TODO
  25. ok 3 # SKIP
  26. END
  27. cat > skip.test <<'END'
  28. 1..3
  29. ok 1 # SKIP
  30. ok 2 # SKIP
  31. ok 3 # SKIP
  32. END
  33. cat > skipall.test <<'END'
  34. 1..0 # SKIP
  35. foo
  36. # bar
  37. END
  38. cat > fail.test <<'END'
  39. 1..1
  40. not ok 1
  41. END
  42. (sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.test
  43. cat > xpass.test <<'END'
  44. 1..1
  45. ok 1 # TODO
  46. END
  47. (sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.test
  48. echo 'Bail out!' > bail.test
  49. (cat ok.test && echo 'Bail out!') > bail2.test
  50. cat > bail3.test <<'END'
  51. 1..0 # SKIP
  52. Bail out!
  53. END
  54. # Too many tests.
  55. cat > error.test <<'END'
  56. 1..2
  57. ok 1
  58. ok 2 # SKIP
  59. not ok 3
  60. not ok 4 # TODO
  61. END
  62. # Too few tests.
  63. cat > error2.test <<'END'
  64. 1..4
  65. ok 1
  66. not ok 2 # TODO
  67. ok 3 # SKIP
  68. END
  69. # Repeated plan.
  70. cat > error3.test <<'END'
  71. 1..2
  72. 1..2
  73. ok 1
  74. ok 2
  75. END
  76. # Too many tests, after a "SKIP" plan.
  77. cat > error4.test <<'END'
  78. 1..0 # SKIP
  79. ok 1
  80. ok 2
  81. END
  82. # Tests out of order.
  83. cat > error5.test <<'END'
  84. 1..4
  85. not ok 1 # TODO
  86. ok 3
  87. ok 2
  88. ok 4
  89. END
  90. # Wrong test number.
  91. cat > error6.test <<'END'
  92. 1..2
  93. ok 1 # SKIP
  94. ok 7
  95. END
  96. # No plan.
  97. cat > error7.test <<'END'
  98. ok 1 # SKIP
  99. ok 2 # TODO
  100. not ok 3 # TODO
  101. ok 4
  102. END
  103. cat > hodgepodge.test <<'END'
  104. 1..2
  105. not ok 1
  106. ok 2 # TODO
  107. Bail out!
  108. END
  109. cat > hodgepodge-all.test <<'END'
  110. 1..4
  111. ok 1
  112. ok 2 # SKIP
  113. not ok 2 # TODO
  114. not ok 3
  115. ok 4 # TODO
  116. Bail out!
  117. END
  118. tests=$(echo *.test) # Also required later.
  119. run_make -O -e FAIL TESTS="$tests" check
  120. # Dirty trick required here.
  121. for tst in $(echo " $tests " | sed 's/\.test / /'); do
  122. echo :copy-in-global-log: yes >> $tst.trs
  123. done
  124. rm -f test-suite.log
  125. run_make -e FAIL TESTS="$tests" test-suite.log
  126. cat test-suite.log
  127. have_rst_section ()
  128. {
  129. eqeq=$(echo "$1" | sed 's/./=/g')
  130. # Assume $1 contains no RE metacharacters.
  131. sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got
  132. (echo "$1" && echo "$eqeq") > exp
  133. cat exp
  134. cat got
  135. diff exp got
  136. }
  137. have_rst_section 'PASS: ok'
  138. have_rst_section 'SKIP: skip'
  139. have_rst_section 'SKIP: skipall'
  140. have_rst_section 'FAIL: fail'
  141. have_rst_section 'FAIL: fail2'
  142. have_rst_section 'FAIL: xpass'
  143. have_rst_section 'FAIL: xpass2'
  144. have_rst_section 'ERROR: bail'
  145. have_rst_section 'ERROR: bail2'
  146. have_rst_section 'ERROR: bail3'
  147. have_rst_section 'ERROR: error'
  148. have_rst_section 'ERROR: error2'
  149. have_rst_section 'ERROR: error3'
  150. have_rst_section 'ERROR: error4'
  151. have_rst_section 'ERROR: error5'
  152. have_rst_section 'ERROR: error6'
  153. have_rst_section 'ERROR: error7'
  154. have_rst_section 'ERROR: hodgepodge'
  155. have_rst_section 'ERROR: hodgepodge-all'
  156. :