tap-passthrough.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. # - all input (valid TAP lines, invalid TAP lines, non-TAP lines)
  18. # are passed through in the log file
  19. # - TAP errors are reported in the log file too
  20. # See also related test 'tap-passthrough-exit.sh'.
  21. . test-init.sh
  22. weirdchars=\''"\$@!&()[]<>#;,:.^?*/'
  23. . tap-setup.sh
  24. #
  25. # Only successful tests.
  26. #
  27. # The whitespace in this test might be normalized in the testsuite
  28. # progress output, but should be copied verbatim in the log files.
  29. cat > ok.test <<END
  30. 1..6
  31. TAP plan in the previous line.
  32. ok${tab}
  33. ok 2
  34. ok - foo
  35. ok 4 - x
  36. This is not a TAP line, but should still be copied in the log file!
  37. # some diagnostic${tab}
  38. not ok # TODO low priority
  39. ok # SKIP who cares?
  40. $weirdchars
  41. END
  42. run_make TESTS=ok.test check || { cat ok.log; exit 1; }
  43. cat ok.log
  44. for rx in \
  45. '1\.\.6' \
  46. 'TAP plan in the previous line\.' \
  47. "ok${tab}" \
  48. 'ok 2' \
  49. 'ok - foo' \
  50. 'ok 4 - x' \
  51. ' This is not a TAP line, but should still be copied in the log file!' \
  52. "# some diagnostic${tab}" \
  53. 'not ok # TODO low priority' \
  54. 'ok # SKIP who cares?' \
  55. ; do
  56. grep "^$rx$" ok.log
  57. done
  58. $FGREP "$weirdchars" ok.log
  59. #
  60. # Mixed failing/successful tests.
  61. #
  62. cat > tiny.test <<END
  63. 1..1
  64. ok
  65. END
  66. cat > ok.test <<END
  67. 1..1
  68. ok
  69. only one success here
  70. END
  71. cat > ko.test <<END
  72. 1..5
  73. foo foo foo
  74. ok${tab}
  75. ok 2
  76. not ok - foo
  77. not ok 4 - x
  78. # diagnostic ko
  79. bar${tab}bar${tab}bar
  80. ok # TODO dunno
  81. $weirdchars
  82. END
  83. cat > bail.test <<END
  84. Bail out! Test is taking too long!
  85. END
  86. cat > skip.test <<END
  87. 1..0 # Skipped: WWW::Mechanize not installed
  88. END
  89. cat > err.test <<END
  90. 1..3
  91. ok 1
  92. Invalid test count
  93. ok 23
  94. Misplaced plan
  95. 1..13
  96. ok
  97. Extra test
  98. ok
  99. Last line
  100. END
  101. st=0
  102. run_make check \
  103. TESTS='tiny.test ok.test ko.test bail.test skip.test err.test' || st=$?
  104. cat tiny.log
  105. cat ok.log
  106. cat ko.log
  107. cat bail.log
  108. cat skip.log
  109. cat err.log
  110. test $st -gt 0 || exit 1
  111. grep '^1\.\.1$' tiny.log
  112. grep '^ok$' tiny.log
  113. grep '^only one success here$' ok.log
  114. for rx in \
  115. '1\.\.5' \
  116. 'foo foo foo' \
  117. "ok${tab}" \
  118. 'ok 2' \
  119. 'not ok - foo' \
  120. 'not ok 4 - x' \
  121. '# diagnostic ko' \
  122. " bar${tab}bar${tab}bar" \
  123. 'ok # TODO dunno' \
  124. ; do
  125. grep "^$rx$" ko.log
  126. done
  127. $FGREP "$weirdchars" ko.log
  128. grep '^Bail out! Test is taking too long!$' bail.log
  129. grep '^1\.\.0 # Skipped: WWW::Mechanize not installed$' skip.log
  130. for rx in \
  131. '^1\.\.3$' \
  132. '^Invalid test count$' \
  133. '^ok 23$' \
  134. '^Misplaced plan$' \
  135. '^1\.\.13$' \
  136. '^ERROR:.* multiple test plans' \
  137. '^Extra test$' \
  138. '^Last line$' \
  139. '^ERROR:.* [tT]oo many tests run.*expected 3, got 4' \
  140. '^ERROR:.* err\.test 23 .*OUT[ -]OF[ -]ORDER.*expecting 2' \
  141. ; do
  142. grep "$rx" err.log
  143. done
  144. :