tap-diagnostic-custom.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # - option '--diagnostic-string' to customize the string introducing
  18. # TAP diagnostics
  19. . test-init.sh
  20. fetch_tap_driver
  21. cat >> configure.ac <<END
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. my_log_driver = $(srcdir)/tap-driver
  26. my_log_compiler = cat
  27. TEST_EXTENSIONS =
  28. TESTS =
  29. END
  30. : > later.mk
  31. # Quoting our comments below is an hack required to keep
  32. # comments near the things they refer to.
  33. i=0
  34. for string in \
  35. '## A letter' \
  36. a \
  37. '## A number' \
  38. 1023 \
  39. '## A non-alphabetic character' \
  40. @ \
  41. '## Some metacharacters (we need to repeat the "$" for make)' \
  42. '^>;&*"|$$' \
  43. '## A whitespace character' \
  44. " " \
  45. '## A tab character' \
  46. "$tab" \
  47. '## A string with more whitespace' \
  48. " ${tab}a b${tab} c" \
  49. '## Note the we do not have the empty string here. We prefer to' \
  50. '## leave its behaviour in this context undefined for the moment.'
  51. do
  52. case $string in '##'*) continue;; esac
  53. i=$(($i + 1))
  54. unindent >> Makefile.am << END
  55. TEST_EXTENSIONS += .t$i
  56. TESTS += foo$i.t$i
  57. T${i}_LOG_COMPILER = \$(my_log_compiler)
  58. T${i}_LOG_DRIVER = \$(my_log_driver)
  59. AM_T${i}_LOG_DRIVER_FLAGS = \
  60. --comments \
  61. --diagnostic-string '$string'
  62. END
  63. unindent > foo$i.t$i <<END
  64. 1..1
  65. ok 1
  66. $string blah blah $i
  67. END
  68. echo "AM_T${i}_LOG_DRIVER_FLAGS = --no-comments" >> later.mk
  69. done
  70. $ACLOCAL
  71. $AUTOCONF
  72. $AUTOMAKE
  73. ./configure
  74. run_make -O check
  75. count_test_results total=$i pass=$i fail=0 xpass=0 xfail=0 skip=0 error=0
  76. cat later.mk >> Makefile
  77. run_make -O check
  78. $FGREP 'blah blah' stdout && exit 1
  79. :