tap-recheck-logs.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. # - RECHECK_LOGS
  18. . test-init.sh
  19. cat > Makefile.am << 'END'
  20. TEST_LOG_COMPILER = cat
  21. TESTS = foo.test bar.test baz.test
  22. baz.log: zardoz
  23. END
  24. . tap-setup.sh
  25. : > zardoz
  26. cat > foo.test <<'END'
  27. 1..2
  28. ok 1
  29. ok 2
  30. END
  31. cat > bar.test <<'END'
  32. 1..1
  33. not ok 1
  34. END
  35. cat > baz.test <<'END'
  36. 1..1
  37. Bail out!
  38. END
  39. # Even the tests that are not re-run should contribute to the testsuite
  40. # summary when obtained by "make check RECHECK_LOGS=".
  41. grep_summary ()
  42. {
  43. grep '^# TOTAL: *4$' stdout
  44. grep '^# PASS: *2$' stdout
  45. grep '^# XPASS: *0$' stdout
  46. grep '^# FAIL: *1$' stdout
  47. grep '^# XFAIL: *0$' stdout
  48. grep '^# SKIP: *0$' stdout
  49. grep '^# ERROR: *1$' stdout
  50. }
  51. run_make -e FAIL check
  52. test -f foo.log
  53. test -f bar.log
  54. test -f baz.log
  55. rm -f foo.log bar.log
  56. run_make -O -e FAIL check RECHECK_LOGS=
  57. test -f foo.log
  58. test -f bar.log
  59. grep '^PASS: foo\.test 1$' stdout
  60. grep '^PASS: foo\.test 2$' stdout
  61. grep '^FAIL: bar\.test 1$' stdout
  62. grep 'baz\.test' stdout && exit 1
  63. grep_summary
  64. $sleep
  65. touch foo.test
  66. # We re-run only a successful test, but the tests that failed in the
  67. # previous run should still be taken into account, and cause an overall
  68. # failure.
  69. run_make -O -e FAIL check RECHECK_LOGS=
  70. grep '^PASS: foo\.test 1$' stdout
  71. grep '^PASS: foo\.test 2$' stdout
  72. grep 'ba[rz]\.test' stdout && exit 1
  73. is_newest foo.log foo.test
  74. grep_summary
  75. $sleep
  76. touch zardoz
  77. run_make -O -e FAIL check RECHECK_LOGS=
  78. grep '^ERROR: baz\.test' stdout
  79. $EGREP '(foo|bar)\.test' stdout && exit 1
  80. is_newest baz.log zardoz
  81. grep_summary
  82. # Now, explicitly retry with all test logs already updated, and ensure
  83. # that the summary is still displayed.
  84. run_make -O -e FAIL check RECHECK_LOGS=
  85. $EGREP '(foo|bar|baz)\.test' stdout && exit 1
  86. grep_summary
  87. # The following should re-run foo.test (and only foo.test), even if its
  88. # log file is up-to-date.
  89. : > older
  90. run_make -O -e FAIL check RECHECK_LOGS=foo.log
  91. grep '^PASS: foo\.test 1$' stdout
  92. grep '^PASS: foo\.test 2$' stdout
  93. grep 'ba[rz]\.test' stdout && exit 1
  94. is_newest foo.log older
  95. grep_summary
  96. :