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