tap-fancy2.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: more unusual forms for valid TAP input.
  17. # See also related test 'tap-fancy.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. # To avoid problems with backslashes in echo arguments.
  33. xecho () { printf '%s\n' "$*"; }
  34. # There are 34 values for $str ...
  35. for str in \
  36. \' \
  37. '"' \
  38. '`' \
  39. '#' \
  40. '$' \
  41. '!' \
  42. '\' \
  43. '/' \
  44. '&' \
  45. '%' \
  46. '(' \
  47. ')' \
  48. '|' \
  49. '^' \
  50. '~' \
  51. '?' \
  52. '*' \
  53. '+' \
  54. '-' \
  55. ',' \
  56. ':' \
  57. ';' \
  58. '=' \
  59. '<' \
  60. '>' \
  61. '@' \
  62. '[' \
  63. ']' \
  64. '{' \
  65. '}' \
  66. '\\' \
  67. '...' \
  68. '?[a-zA-Z0-9]*' \
  69. '*.*' \
  70. ; do
  71. # ... each of them add 1 pass, 1 fail, ...
  72. xecho "ok${str}"
  73. xecho "not ok${str}"
  74. # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
  75. for settings in \
  76. 'result="ok" directive=SKIP' \
  77. 'result="not ok" directive=TODO' \
  78. 'result="ok" directive=TODO' \
  79. ; do
  80. eval "$settings"
  81. xecho "${result}# ${directive}${str}"
  82. # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since
  83. # they might not work with $str = '#' or $str = '\' ...
  84. if test x"$str" != x'#' && test x"$str" != x'\'; then
  85. xecho "${result}${str}#${directive}"
  86. xecho "${result}${str}# ${tab}${tab} ${directive}"
  87. xecho "${result}${str}#${directive}${str}"
  88. fi
  89. done
  90. done > all.test
  91. # Sanity check against a previous use of unportable usages of backslashes
  92. # with the "echo" builtin.
  93. if grep '[^\\]\\#' all.test; then
  94. framework_failure_ "writing backslashes in all.test"
  95. fi
  96. # ... so that we finally have:
  97. pass=34
  98. fail=34
  99. xfail=130 # = 4 * 34 - 6
  100. xpass=130 # = 4 * 34 - 6
  101. skip=130 # = 4 * 34 - 6
  102. error=0
  103. total=$(($pass + $fail + $xfail + $xpass + $skip))
  104. # Even nastier! But accordingly to the specifics, it should still work.
  105. for result in 'ok' 'not ok'; do
  106. echo "${result}{[(<#${tab}TODO>)]}" >> all.test
  107. done
  108. echo "ok{[(<#${tab}SKIP>)]}" >> all.test
  109. # We have to update some test counts.
  110. xfail=$(($xfail + 1))
  111. xpass=$(($xpass + 1))
  112. skip=$(($skip + 1))
  113. total=$(($total + 3))
  114. # And add the test plan!
  115. echo 1..$total >> all.test
  116. run_make -O -e FAIL check
  117. $EGREP '^(PASS|FAIL|SKIP).*#.*TODO' stdout && exit 1
  118. $EGREP '^X?(PASS|FAIL).*#.*SKIP' stdout && exit 1
  119. count_test_results total=$total pass=$pass fail=$fail skip=$skip \
  120. xpass=$xpass xfail=$xfail error=$error
  121. :