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# TAP support: 18# - all input (valid TAP lines, invalid TAP lines, non-TAP lines) 19# are passed through in the log file 20# - TAP errors are reported in the log file too 21# See also related test 'tap-passthrough-exit.sh'. 22 23. test-init.sh 24 25weirdchars=\''"\$@!&()[]<>#;,:.^?*/' 26 27. tap-setup.sh 28 29# 30# Only successful tests. 31# 32 33# The whitespace in this test might be normalized in the testsuite 34# progress output, but should be copied verbatim in the log files. 35cat > ok.test <<END 361..6 37TAP plan in the previous line. 38ok${tab} 39ok 2 40ok - foo 41ok 4 - x 42 This is not a TAP line, but should still be copied in the log file! 43# some diagnostic${tab} 44not ok # TODO low priority 45ok # SKIP who cares? 46$weirdchars 47END 48 49run_make TESTS=ok.test check || { cat ok.log; exit 1; } 50cat ok.log 51 52for rx in \ 53 '1\.\.6' \ 54 'TAP plan in the previous line\.' \ 55 "ok${tab}" \ 56 'ok 2' \ 57 'ok - foo' \ 58 'ok 4 - x' \ 59 ' This is not a TAP line, but should still be copied in the log file!' \ 60 "# some diagnostic${tab}" \ 61 'not ok # TODO low priority' \ 62 'ok # SKIP who cares?' \ 63; do 64 grep "^$rx$" ok.log 65done 66$FGREP "$weirdchars" ok.log 67 68# 69# Mixed failing/successful tests. 70# 71 72cat > tiny.test <<END 731..1 74ok 75END 76 77cat > ok.test <<END 781..1 79ok 80only one success here 81END 82 83cat > ko.test <<END 841..5 85foo foo foo 86ok${tab} 87ok 2 88not ok - foo 89not ok 4 - x 90# diagnostic ko 91 bar${tab}bar${tab}bar 92ok # TODO dunno 93$weirdchars 94END 95 96cat > bail.test <<END 97Bail out! Test is taking too long! 98END 99 100cat > skip.test <<END 1011..0 # Skipped: WWW::Mechanize not installed 102END 103 104cat > err.test <<END 1051..3 106ok 1 107Invalid test count 108ok 23 109Misplaced plan 1101..13 111ok 112Extra test 113ok 114Last line 115END 116 117st=0 118run_make check \ 119 TESTS='tiny.test ok.test ko.test bail.test skip.test err.test' || st=$? 120cat tiny.log 121cat ok.log 122cat ko.log 123cat bail.log 124cat skip.log 125cat err.log 126test $st -gt 0 || exit 1 127 128grep '^1\.\.1$' tiny.log 129grep '^ok$' tiny.log 130grep '^only one success here$' ok.log 131 132for rx in \ 133 '1\.\.5' \ 134 'foo foo foo' \ 135 "ok${tab}" \ 136 'ok 2' \ 137 'not ok - foo' \ 138 'not ok 4 - x' \ 139 '# diagnostic ko' \ 140 " bar${tab}bar${tab}bar" \ 141 'ok # TODO dunno' \ 142; do 143 grep "^$rx$" ko.log 144done 145$FGREP "$weirdchars" ko.log 146 147grep '^Bail out! Test is taking too long!$' bail.log 148grep '^1\.\.0 # Skipped: WWW::Mechanize not installed$' skip.log 149 150for rx in \ 151 '^1\.\.3$' \ 152 '^Invalid test count$' \ 153 '^ok 23$' \ 154 '^Misplaced plan$' \ 155 '^1\.\.13$' \ 156 '^ERROR:.* multiple test plans' \ 157 '^Extra test$' \ 158 '^Last line$' \ 159 '^ERROR:.* [tT]oo many tests run.*expected 3, got 4' \ 160 '^ERROR:.* err\.test 23 .*OUT[ -]OF[ -]ORDER.*expecting 2' \ 161; do 162 grep "$rx" err.log 163done 164 165: 166