test-metadata-recheck.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. # Test the "make recheck" semantics for custom test drivers, as documented
  17. # in the Automake manual.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_OUTPUT
  21. END
  22. cat > Makefile.am << 'END'
  23. LOG_DRIVER = ./dummy-driver
  24. TEST_EXTENSIONS =
  25. TESTS =
  26. END
  27. #
  28. # Tests to be re-run by "make recheck"
  29. #
  30. : > y-1
  31. echo "foo bar" > y-2
  32. echo ":recheck:" > y-3
  33. echo ":recheck:yes" > y-4
  34. echo ":recheck: who cares" > y-5
  35. echo ":recheck: $tab y" > y-6
  36. echo ":recheck: yeah!$tab$tab " > y-7
  37. cat > y-10 <<END
  38. :foo:
  39. :recheck: ???
  40. END
  41. cat > y-11 <<END
  42. :recheck: YES
  43. :foo:
  44. END
  45. cat > y-12 <<END
  46. foo
  47. :recheck:yes
  48. bar
  49. zardoz
  50. END
  51. echo " $tab $tab$tab :recheck: yes" > y-8
  52. # The :test-result: fields and the fist line of the log should be
  53. # irrelevant for the decision of whether "make recheck" should or
  54. # should not re-run a test.
  55. echo ":test-result: PASS" > y-100
  56. echo "PASS: y-101"
  57. cat > y-102 <<END
  58. PASS: y-102
  59. ===========
  60. :test-result: PASS
  61. END
  62. #
  63. # Tests *not* to be re-run by "make recheck"
  64. #
  65. echo ":recheck:no" > n-1
  66. echo ":recheck: no " > n-2
  67. echo ":recheck: $tab no" > n-3
  68. echo ":recheck: no $tab$tab " > n-4
  69. cat > n-5 <<END
  70. :foo:
  71. :recheck:no
  72. END
  73. cat > n-6 <<END
  74. :recheck: no
  75. :foo:
  76. END
  77. cat > n-7 <<END
  78. foo
  79. :recheck: no$tab$tab
  80. bar
  81. zardoz
  82. END
  83. echo " $tab $tab$tab :recheck: no" > n-8
  84. # The :test-result: fields should be irrelevant for the decision of
  85. # whether "make recheck" should or should not re-run a test.
  86. cat > n-100 <<END
  87. :test-result: FAIL
  88. :test-result: XPASS
  89. :test-result: ERROR
  90. :test-result: UNKNOWN
  91. :recheck: no
  92. END
  93. rechecked=$(echo y-[0-9]*)
  94. for t in [yn]-[0-9]*; do echo $t; done \
  95. | sed 's/.*/TESTS += &/' >> Makefile.am
  96. cat Makefile.am # For debugging.
  97. cat > dummy-driver <<'END'
  98. #!/bin/sh
  99. set -e; set -u
  100. while test $# -gt 0; do
  101. case $1 in
  102. --log-file) log_file=$2; shift;;
  103. --trs-file) trs_file=$2; shift;;
  104. --test-name) test_name=$2; shift;;
  105. --expect-failure|--color-tests|--enable-hard-errors) shift;;
  106. --) shift; break;;
  107. *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
  108. esac
  109. shift
  110. done
  111. : > $test_name.run
  112. : > $log_file
  113. cp $1 $trs_file
  114. END
  115. chmod a+x dummy-driver
  116. $ACLOCAL
  117. $AUTOCONF
  118. $AUTOMAKE
  119. ./configure
  120. # The ':test-result:' fields should be ignored by "make recheck",
  121. # but should cause the testsuite report to detect errors.
  122. $MAKE check && exit 1
  123. ls -l
  124. for t in $tests; do test -f $t.run; done
  125. rm -f *.run
  126. # But now the tests that actually get re-run have only ':test-result:'
  127. # fields indicating success, so "make recheck" must pass. Still, the
  128. # next "make recheck" call should still re-run the same set of tests.
  129. for iteration in 1 2; do
  130. using_gmake || $sleep # Required by BSD make.
  131. $MAKE recheck
  132. ls -l
  133. for t in $rechecked; do test -f $t.run; done
  134. find . -name 'n-*.run' | grep . && exit 1
  135. : For shells with busted 'set -e'.
  136. done
  137. :