tap-plan-corner.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. # - some corner cases for TAP plan
  18. . test-init.sh
  19. . tap-setup.sh
  20. # -------------------------------------------------------------------------
  21. cat > leading-repeated.test <<END
  22. 1..1
  23. 1..1
  24. ok 1
  25. END
  26. cat > trailing-repeated.test <<END
  27. ok 1
  28. 1..1
  29. 1..1
  30. END
  31. for pos in leading trailing; do
  32. run_make -O -e FAIL TESTS="$pos-repeated.test" check
  33. count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
  34. grep "^ERROR: $pos-repeated\\.test - multiple test plans$" stdout
  35. done
  36. # -------------------------------------------------------------------------
  37. cat > leading-repeated.test <<END
  38. 1..2
  39. ok 1
  40. 1..2
  41. ok 2
  42. END
  43. cat > trailing-repeated.test <<END
  44. ok 1
  45. 1..2
  46. ok 2
  47. 1..2
  48. END
  49. run_make -O -e FAIL check \
  50. TESTS='leading-repeated.test trailing-repeated.test'
  51. count_test_results total=6 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=3
  52. grep "^ERROR: leading-repeated\\.test - multiple test plans$" stdout
  53. grep "^ERROR: trailing-repeated\\.test - multiple test plans$" stdout
  54. grep "^ERROR: trailing-repeated\\.test 2 # AFTER LATE PLAN$" stdout
  55. grep "leading .*AFTER LATE PLAN" stdout && exit 1
  56. # -------------------------------------------------------------------------
  57. cat > 1.test <<END
  58. 1..0
  59. 1..0
  60. END
  61. cat > 2.test <<END
  62. 1..0 # SKIP
  63. 1..0
  64. END
  65. cat > 3.test <<END
  66. 1..0
  67. 1..0 # SKIP
  68. END
  69. cat > 4.test <<END
  70. 1..0 # SKIP
  71. 1..0 # SKIP
  72. END
  73. run_make -O -e FAIL check TESTS='1.test 2.test 3.test 4.test'
  74. count_test_results total=8 pass=0 fail=0 xpass=0 xfail=0 skip=4 error=4
  75. for i in 1 2 3 4; do
  76. grep "^ERROR: $i\\.test - multiple test plans$" stdout
  77. done
  78. # -------------------------------------------------------------------------
  79. cat > all.test <<END
  80. 1..5
  81. ok 1
  82. ok 2
  83. 1..5
  84. ok 3
  85. 1..5
  86. ok 4
  87. 1..5
  88. ok 5
  89. END
  90. run_make -O -e FAIL check
  91. count_test_results total=8 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=3
  92. cat > exp <<'END'
  93. PASS: all.test 1
  94. PASS: all.test 2
  95. ERROR: all.test - multiple test plans
  96. PASS: all.test 3
  97. ERROR: all.test - multiple test plans
  98. PASS: all.test 4
  99. ERROR: all.test - multiple test plans
  100. PASS: all.test 5
  101. END
  102. $FGREP ': all.test' stdout > got
  103. cat exp
  104. cat got
  105. diff exp got
  106. # -------------------------------------------------------------------------
  107. cat > all.test <<END
  108. 1..2
  109. ok 1
  110. ok 2
  111. 1..3
  112. ok 3
  113. END
  114. run_make -O -e FAIL check
  115. count_test_results total=5 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=3
  116. cat > exp <<'END'
  117. PASS: all.test 1
  118. PASS: all.test 2
  119. ERROR: all.test - multiple test plans
  120. ERROR: all.test 3 # UNPLANNED
  121. ERROR: all.test - too many tests run (expected 2, got 3)
  122. END
  123. $FGREP ': all.test' stdout > got
  124. cat exp
  125. cat got
  126. diff exp got
  127. # -------------------------------------------------------------------------
  128. cat > all.test <<END
  129. ok 1
  130. ok 2
  131. ok 3
  132. 1..5
  133. 1..5
  134. ok 4
  135. 1..5
  136. ok 5
  137. END
  138. run_make -O -e FAIL check
  139. count_test_results total=7 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=4
  140. cat > exp <<'END'
  141. PASS: all.test 1
  142. PASS: all.test 2
  143. PASS: all.test 3
  144. ERROR: all.test - multiple test plans
  145. ERROR: all.test 4 # AFTER LATE PLAN
  146. ERROR: all.test - multiple test plans
  147. ERROR: all.test 5 # AFTER LATE PLAN
  148. END
  149. $FGREP ': all.test' stdout > got
  150. cat exp
  151. cat got
  152. diff exp got
  153. :