tap-doc2.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. # Check that an example given in the documentation really works.
  17. # See section "Using the TAP test protocol", subsection "Use TAP
  18. # with the Automake test harness".
  19. am_create_testdir=empty
  20. . test-init.sh
  21. cat > Makefile.am <<'END'
  22. TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
  23. $(top_srcdir)/build-aux/tap-driver.sh
  24. TESTS = foo.test bar.test baz.test
  25. EXTRA_DIST = $(TESTS)
  26. END
  27. cat > configure.ac <<'END'
  28. AC_INIT([GNU Try Tap], [1.0], [bug-automake@gnu.org])
  29. AC_CONFIG_AUX_DIR([build-aux])
  30. AM_INIT_AUTOMAKE([foreign -Wall -Werror])
  31. AC_CONFIG_FILES([Makefile])
  32. AC_REQUIRE_AUX_FILE([tap-driver.sh])
  33. AC_OUTPUT
  34. END
  35. cat > foo.test <<'END'
  36. #!/bin/sh
  37. echo 1..4 # Number of tests to be executed.
  38. echo 'ok 1 - Swallows fly'
  39. echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
  40. echo 'ok 3 - Pigs fly # SKIP not enough acid'
  41. echo '# I just love word plays...'
  42. echo 'ok 4 - Flies fly too :-)'
  43. END
  44. cat > bar.test <<'END'
  45. #!/bin/sh
  46. echo 1..3
  47. echo 'not ok 1 - Bummer, this test has failed.'
  48. echo 'ok 2 - This passed though.'
  49. echo 'Bail out! Ennui kicking in, sorry...'
  50. echo 'ok 3 - This will not be seen.'
  51. END
  52. cat > baz.test <<'END'
  53. #!/bin/sh
  54. echo 1..1
  55. echo ok 1
  56. # Exit with error, even if all the tests have been successful.
  57. exit 7
  58. END
  59. chmod a+x *.test
  60. # Strip extra "informative" lines that could be printed by Solaris
  61. # Distributed Make.
  62. mkdir build-aux
  63. cp "$am_scriptdir"/tap-driver.sh build-aux \
  64. || framework_failure_ "fetching the perl TAP driver"
  65. (export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || exit 1
  66. ./configure --help # Sanity check.
  67. ./configure || skip_ "configure failed"
  68. case $MAKE in *\ -j*) skip_ "can't work easily with concurrent make";; esac
  69. # Prevent Sun Distributed Make from trying to run in parallel.
  70. DMAKE_MODE=serial; export DMAKE_MODE
  71. run_make -O -e FAIL check
  72. cat > exp <<'END'
  73. PASS: foo.test 1 - Swallows fly
  74. XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
  75. SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
  76. PASS: foo.test 4 - Flies fly too :-)
  77. FAIL: bar.test 1 - Bummer, this test has failed.
  78. PASS: bar.test 2 - This passed though.
  79. ERROR: bar.test - Bail out! Ennui kicking in, sorry...
  80. PASS: baz.test 1
  81. ERROR: baz.test - exited with status 7
  82. END
  83. sed -n '/^PASS: foo\.test/,/^ERROR: baz\.test/p' stdout > got
  84. cat exp
  85. cat got
  86. diff exp got
  87. grep '^Please report to bug-automake@gnu\.org$' stdout
  88. run_make -O check \
  89. TESTS='foo.test baz.test' \
  90. TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit'
  91. cat > exp <<'END'
  92. PASS: foo.test 1 - Swallows fly
  93. XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
  94. SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
  95. # foo.test: I just love word plays...
  96. PASS: foo.test 4 - Flies fly too :-)
  97. PASS: baz.test 1
  98. END
  99. sed -n '/^PASS: foo\.test/,/^PASS: baz\.test/p' stdout > got
  100. cat exp
  101. cat got
  102. diff exp got
  103. # Sanity check the distribution.
  104. cat > bar.test <<'END'
  105. #!/bin/sh
  106. echo 1..1
  107. echo ok 1
  108. END
  109. echo AM_TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile.in
  110. ./config.status Makefile
  111. $MAKE distcheck
  112. rm -f Makefile.in # To avoid a maintainer-check failure.
  113. :