tap-whitespace-normalization.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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: whitespace normalization (or lack thereof) in the testsuite
  17. # progress output on console. We keep all of these checks here in a single
  18. # script so that a potential cosmetic change in the output format won't
  19. # force us to tweak dozens of other tests (hopefully).
  20. # See also related test 'tap-todo-skip-whitespace.sh'.
  21. . test-init.sh
  22. cat > Makefile.am << 'END'
  23. TEST_LOG_COMPILER = cat
  24. TESTS =
  25. END
  26. : > exp
  27. spaces_a=${sp}${tab}${tab}${sp}${sp}${tab}
  28. spaces_b=${tab}${tab}${sp}${tab}${sp}${sp}${sp}
  29. #-----------------------------------------------------------------------
  30. echo TESTS += numbers.test >> Makefile.am
  31. cat > numbers.test <<END
  32. 1..6
  33. ok${spaces_a}1
  34. ok 2${spaces_b}
  35. ok${spaces_a}3${spaces_b}
  36. not ok${spaces_b}4
  37. not ok 5${spaces_a}
  38. not ok${spaces_b}6${spaces_a}
  39. END
  40. cat >> exp <<END
  41. PASS: numbers.test 1
  42. PASS: numbers.test 2
  43. PASS: numbers.test 3
  44. FAIL: numbers.test 4
  45. FAIL: numbers.test 5
  46. FAIL: numbers.test 6
  47. END
  48. #-----------------------------------------------------------------------
  49. echo TESTS += description.test >> Makefile.am
  50. cat > description.test <<END
  51. 1..8
  52. ok${spaces_a}+foo
  53. ok +bar${spaces_b}
  54. ok${spaces_a}+baz${spaces_b}
  55. not ok${spaces_b}-foo
  56. not ok -bar${spaces_a}
  57. not ok${spaces_b}-baz${spaces_a}
  58. ok u${spaces_b}v${spaces_a}w${sp}
  59. not ok${spaces_a}x${spaces_a}y${tab}z${tab}
  60. END
  61. cat >> exp <<END
  62. PASS: description.test 1 +foo
  63. PASS: description.test 2 +bar
  64. PASS: description.test 3 +baz
  65. FAIL: description.test 4 -foo
  66. FAIL: description.test 5 -bar
  67. FAIL: description.test 6 -baz
  68. PASS: description.test 7 u${spaces_b}v${spaces_a}w
  69. FAIL: description.test 8 x${spaces_a}y${tab}z
  70. END
  71. #-----------------------------------------------------------------------
  72. # "Bail out!" magic.
  73. echo TESTS += bailout.test >> Makefile.am
  74. cat > bailout.test <<END
  75. 1..1
  76. Bail out!${tab}${sp}${sp}${tab}We're out of disk space.
  77. ok 1
  78. END
  79. cat >> exp <<END
  80. ERROR: bailout.test - Bail out! We're out of disk space.
  81. END
  82. echo TESTS += bailout2.test >> Makefile.am
  83. cat > bailout2.test <<END
  84. 1..1
  85. Bail out!foo${tab}${sp}
  86. ok 1
  87. END
  88. cat >> exp <<END
  89. ERROR: bailout2.test - Bail out! foo
  90. END
  91. #-----------------------------------------------------------------------
  92. # Diagnostic lines.
  93. echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile.am
  94. echo TESTS += cmnt.test >> Makefile.am
  95. cat > cmnt.test <<END
  96. 1..1
  97. ok 1
  98. #Leading whitespace gets added
  99. # ${tab}${tab} ${tab}Extra leading whitespace is stripped
  100. # Trailing whitespace is stripped ${tab} ${tab}${tab}
  101. # Middle${tab}whitespace is${tab} ${tab}${tab} kept
  102. # ${tab} And only${tab}middle ${tab}whitespace ${tab}${tab} ${tab}
  103. END
  104. cat >> exp <<END
  105. PASS: cmnt.test 1
  106. # cmnt.test: Leading whitespace gets added
  107. # cmnt.test: Extra leading whitespace is stripped
  108. # cmnt.test: Trailing whitespace is stripped
  109. # cmnt.test: Middle${tab}whitespace is${tab} ${tab}${tab} kept
  110. # cmnt.test: And only${tab}middle ${tab}whitespace
  111. END
  112. #-----------------------------------------------------------------------
  113. # TODO: we should have more checks here ... (but let's not over-do FTM).
  114. #-----------------------------------------------------------------------
  115. chmod a+x *.test
  116. . tap-setup.sh
  117. # We don't care about exit status or number of test results, they
  118. # should be checked for in many other tests.
  119. run_make -O -e FAIL check
  120. LC_ALL=C sort exp > t
  121. mv -f t exp
  122. # We need the sort below to account for parallel make usage.
  123. LC_ALL=C grep '[a-z0-9][a-z0-9]*\.test' stdout | LC_ALL=C sort > got
  124. cat exp
  125. cat got
  126. diff exp got
  127. :