tap-todo-skip-whitespace.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. # - normalization of whitespace in console testsuite progress associated
  18. # with TODO and SKIP directives
  19. . test-init.sh
  20. . tap-setup.sh
  21. cat > stub.tap <<END
  22. 1 # TODO
  23. 2 # TODO foo?
  24. 3 # TODO: bar!
  25. 4 aa # TODO
  26. 5 bb # TODO fnord 5
  27. 6 cc # TODO:${tab}fnord 6
  28. 7 - x # TODO
  29. 8 - y # TODO fnord $tab 8
  30. 9 - z # TODO: fnord 9 $tab
  31. 10# TODO x0
  32. 11$tab# TODO x1
  33. 12 $tab$tab # TODO x2
  34. 13 asd# TODO x3
  35. 14 sad$tab# TODO x4
  36. 15 das$tab$tab # TODO x5
  37. END
  38. cat > stub.exp <<END
  39. 1 # TODO
  40. 2 # TODO foo?
  41. 3 # TODO: bar!
  42. 4 aa # TODO
  43. 5 bb # TODO fnord 5
  44. 6 cc # TODO:${tab}fnord 6
  45. 7 - x # TODO
  46. 8 - y # TODO fnord $tab 8
  47. 9 - z # TODO: fnord 9
  48. 10 # TODO x0
  49. 11 # TODO x1
  50. 12 # TODO x2
  51. 13 asd # TODO x3
  52. 14 sad # TODO x4
  53. 15 das # TODO x5
  54. END
  55. plan=1..15
  56. my_make_check ()
  57. {
  58. xpass=0 xfail=0 skip=0
  59. case $1 in
  60. xpass|xfail|skip) eval $1=15;;
  61. *) fatal_ "bad argument '$1' for my_make_check";;
  62. esac
  63. cat all.test
  64. # We don't care about the exit status in this test.
  65. run_make -O -e IGNORE check
  66. count_test_results total=15 pass=0 fail=0 error=0 \
  67. xpass=$xpass xfail=$xfail skip=$skip
  68. # Don't be too strict w.r.t. possible normalization of "TODO: foo" into
  69. # "TODO : foo" (as is done by, e.g., the 'TAP::Parser' perl module).
  70. LC_ALL=C grep '^[A-Z][A-Z]*:' stdout \
  71. | sed -e 's/# TODO *:/# TODO:/' -e 's/# SKIP *:/# SKIP:/' > got
  72. cat exp
  73. cat got
  74. diff exp got
  75. }
  76. # For "TODO" directives leading to XPASS results.
  77. (echo $plan && sed -e 's/^/ok /' stub.tap) > all.test
  78. sed -e 's/^/XPASS: all.test /' stub.exp > exp
  79. my_make_check xpass
  80. # For "TODO" directives leading to XFAIL results.
  81. (echo $plan && sed -e 's/^/not ok /' stub.tap) > all.test
  82. sed -e 's/^/XFAIL: all.test /' stub.exp > exp
  83. my_make_check xfail
  84. # For "SKIP" directives.
  85. (echo $plan && sed -e 's/^/ok /' -e 's/TODO/SKIP/' stub.tap) > all.test
  86. sed -e 's/TODO/SKIP/' -e 's/^/SKIP: all.test /' stub.exp > exp
  87. my_make_check skip
  88. :