tap-fancy.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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: some unusual forms for valid TAP input.
  17. # See also related test 'tap-fancy2.sh'.
  18. . test-init.sh
  19. . tap-setup.sh
  20. #
  21. # From manpage Test::Harness::TAP(3):
  22. #
  23. # Lines written to standard output matching /^(not )?ok\b/ must be
  24. # interpreted as test lines. All other lines must not be considered
  25. # test output.
  26. #
  27. # Unfortunately, the exact format of TODO and SKIP directives is not as
  28. # clearly described in that manpage; but a simple reverse-engineering of
  29. # the prove(1) utility shows that it is probably given by the perl regex
  30. # /#\s*(TODO|SKIP)\b/.
  31. #
  32. cat > all.test <<END
  33. 1..21
  34. ok? a question
  35. not ok? a question
  36. ok+plus
  37. not ok+plus
  38. ok-minus
  39. not ok-minus
  40. ok#55
  41. not ok#55
  42. ok${tab} ${tab}9
  43. ok ${tab}${tab} 10
  44. not ok${tab} ${tab}11
  45. not ok ${tab}${tab} 12
  46. ok# SKIP
  47. ok${tab}#SKIP--who cares?
  48. ok?#SKIP!
  49. ok!#SKIP?
  50. not ok# TODO
  51. not ok${tab}#TODO--who cares?
  52. not ok?#TODO!
  53. not ok!#TODO?
  54. ok~#TODO
  55. END
  56. run_make -O -e FAIL check
  57. count_test_results total=21 pass=6 fail=6 xfail=4 xpass=1 skip=4 error=0
  58. #
  59. # "Weird" characters support.
  60. #
  61. # The "#" character might cause confusion w.r.t. TAP directives (TODO,
  62. # SKIP), so we don't attempt to use it.
  63. weirdchars=\''"$!&()[]<>;^?*/@%=,.:'
  64. cat > all.test <<END
  65. 1..6
  66. ok $weirdchars
  67. not ok $weirdchars
  68. ok $weirdchars # TODO
  69. not ok $weirdchars # TODO
  70. ok $weirdchars # SKIP
  71. Bail out! $weirdchars
  72. END
  73. run_make -O -e FAIL check
  74. count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
  75. $FGREP "PASS: all.test 1 $weirdchars" stdout
  76. $FGREP "FAIL: all.test 2 $weirdchars" stdout
  77. $FGREP "XPASS: all.test 3 $weirdchars" stdout
  78. $FGREP "XFAIL: all.test 4 $weirdchars" stdout
  79. $FGREP "SKIP: all.test 5 $weirdchars" stdout
  80. $FGREP "ERROR: all.test - Bail out! $weirdchars" stdout
  81. #
  82. # Trailing backslashes does not confuse the parser.
  83. #
  84. bs='\'
  85. cat > all.test <<END
  86. 1..6
  87. ok $bs
  88. not ok $bs
  89. ok # TODO $bs
  90. not ok # TODO $bs
  91. ok # SKIP $bs
  92. Bail out! $bs
  93. END
  94. run_make -O -e FAIL check
  95. count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
  96. grep '^PASS: all\.test 1 \\$' stdout
  97. grep '^FAIL: all\.test 2 \\$' stdout
  98. grep '^XPASS: all\.test 3 # TODO \\$' stdout
  99. grep '^XFAIL: all\.test 4 # TODO \\$' stdout
  100. grep '^SKIP: all\.test 5 # SKIP \\$' stdout
  101. grep '^ERROR: all\.test - Bail out! \\$' stdout
  102. :