tap-basic.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. # Basic TAP support:
  17. # - LOG_COMPILER support;
  18. # - basic support for TODO and SKIP directives, and "Bail out!" magic;
  19. # - testsuite progress output on console;
  20. # - runtime overriding of TESTS and TEST_LOGS;
  21. # - correct counts of test results (both in summary and in progress
  22. # output on console).
  23. # Note that some of the features checked here are checked in other
  24. # test cases too, usually in a more thorough and detailed way.
  25. . test-init.sh
  26. fetch_tap_driver
  27. cat >> configure.ac <<END
  28. AC_OUTPUT
  29. END
  30. cat > Makefile.am << 'END'
  31. TEST_LOG_DRIVER = $(srcdir)/tap-driver
  32. ## Defining LOG_COMPILER should work and not intefere with the
  33. ## tap-driver script.
  34. TEST_LOG_COMPILER = cat
  35. TESTS = success.test
  36. ok.test:
  37. echo '1..3' > $@-t
  38. echo 'ok 1' >> $@-t
  39. echo 'not ok 2 # TODO' >>$@-t
  40. echo 'ok 3 # SKIP' >>$@-t
  41. cat $@-t ;: For debugging.
  42. mv -f $@-t $@
  43. END
  44. cat > success.test << 'END'
  45. 1..20
  46. ok 1
  47. ok 2 two
  48. ok 3 - three
  49. ok 4 four four
  50. not ok 5
  51. not ok 6 six
  52. not ok 7 - seven
  53. not ok 8 eight eight
  54. ok 9 # TODO
  55. ok 10 ten # TODO
  56. ok 11 - eleven # TODO
  57. ok 12 twelve twelve # TODO
  58. not ok 13 # TODO
  59. not ok 14 fourteen # TODO
  60. not ok 15 - fifteen # TODO
  61. not ok 16 sixteen sixteen # TODO
  62. ok 17 # SKIP
  63. ok 18 eighteen # SKIP
  64. ok 19 - nineteen # SKIP
  65. ok 20 twenty twenty # SKIP
  66. END
  67. $ACLOCAL
  68. $AUTOCONF
  69. $AUTOMAKE
  70. ./configure
  71. # Basilar usage and testsuite progress output.
  72. run_make -O -e FAIL check
  73. count_test_results total=20 pass=4 fail=4 xpass=4 xfail=4 skip=4 error=0
  74. test -f success.log
  75. test -f test-suite.log
  76. cat > exp << 'END'
  77. PASS: success.test 1
  78. PASS: success.test 2 two
  79. PASS: success.test 3 - three
  80. PASS: success.test 4 four four
  81. FAIL: success.test 5
  82. FAIL: success.test 6 six
  83. FAIL: success.test 7 - seven
  84. FAIL: success.test 8 eight eight
  85. XPASS: success.test 9 # TODO
  86. XPASS: success.test 10 ten # TODO
  87. XPASS: success.test 11 - eleven # TODO
  88. XPASS: success.test 12 twelve twelve # TODO
  89. XFAIL: success.test 13 # TODO
  90. XFAIL: success.test 14 fourteen # TODO
  91. XFAIL: success.test 15 - fifteen # TODO
  92. XFAIL: success.test 16 sixteen sixteen # TODO
  93. SKIP: success.test 17 # SKIP
  94. SKIP: success.test 18 eighteen # SKIP
  95. SKIP: success.test 19 - nineteen # SKIP
  96. SKIP: success.test 20 twenty twenty # SKIP
  97. END
  98. $FGREP ': success.test' stdout > got
  99. cat exp
  100. cat got
  101. diff exp got
  102. # Override TESTS from the command line.
  103. rm -f *.log *.test
  104. cat > bail.test <<'END'
  105. 1..1
  106. Bail out!
  107. ok 1
  108. END
  109. run_make -O -e FAIL check TESTS=bail.test
  110. count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
  111. test ! -e success.log
  112. test -f bail.log
  113. test -f test-suite.log
  114. grep '^ERROR: bail\.test - Bail out!' stdout
  115. grep '^PASS:' stdout && exit 1
  116. test $($FGREP -c ': bail.test' stdout) -eq 1
  117. $FGREP 'success.test' stdout && exit 1
  118. # Override TEST_LOGS from the command line, making it point to a test
  119. # (ok.test) that has to be generated at make time.
  120. rm -f *.log *.test
  121. run_make -O check TEST_LOGS=ok.log
  122. count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
  123. test -f ok.test
  124. test -f ok.log
  125. test ! -e success.log
  126. test ! -e bail.log
  127. test -f test-suite.log
  128. $EGREP '(bail|success)\.test' stdout && exit 1
  129. cat > exp << 'END'
  130. PASS: ok.test 1
  131. XFAIL: ok.test 2 # TODO
  132. SKIP: ok.test 3 # SKIP
  133. END
  134. $FGREP ': ok.test' stdout > got
  135. cat exp
  136. cat got
  137. diff exp got
  138. :