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# - which global test result derives from different test results 19# mixed in a single script? 20 21. test-init.sh 22 23. tap-setup.sh 24 25cat > ok.test <<END 261..3 27ok 1 28not ok 2 # TODO 29ok 3 # SKIP 30END 31 32cat > skip.test <<'END' 331..3 34ok 1 # SKIP 35ok 2 # SKIP 36ok 3 # SKIP 37END 38 39cat > skipall.test <<'END' 401..0 # SKIP 41foo 42# bar 43END 44 45cat > fail.test <<'END' 461..1 47not ok 1 48END 49 50(sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.test 51 52cat > xpass.test <<'END' 531..1 54ok 1 # TODO 55END 56 57(sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.test 58 59echo 'Bail out!' > bail.test 60 61(cat ok.test && echo 'Bail out!') > bail2.test 62 63cat > bail3.test <<'END' 641..0 # SKIP 65Bail out! 66END 67 68# Too many tests. 69cat > error.test <<'END' 701..2 71ok 1 72ok 2 # SKIP 73not ok 3 74not ok 4 # TODO 75END 76 77# Too few tests. 78cat > error2.test <<'END' 791..4 80ok 1 81not ok 2 # TODO 82ok 3 # SKIP 83END 84 85# Repeated plan. 86cat > error3.test <<'END' 871..2 881..2 89ok 1 90ok 2 91END 92 93# Too many tests, after a "SKIP" plan. 94cat > error4.test <<'END' 951..0 # SKIP 96ok 1 97ok 2 98END 99 100# Tests out of order. 101cat > error5.test <<'END' 1021..4 103not ok 1 # TODO 104ok 3 105ok 2 106ok 4 107END 108 109# Wrong test number. 110cat > error6.test <<'END' 1111..2 112ok 1 # SKIP 113ok 7 114END 115 116# No plan. 117cat > error7.test <<'END' 118ok 1 # SKIP 119ok 2 # TODO 120not ok 3 # TODO 121ok 4 122END 123 124cat > hodgepodge.test <<'END' 1251..2 126not ok 1 127ok 2 # TODO 128Bail out! 129END 130 131cat > hodgepodge-all.test <<'END' 1321..4 133ok 1 134ok 2 # SKIP 135not ok 2 # TODO 136not ok 3 137ok 4 # TODO 138Bail out! 139END 140 141tests=$(echo *.test) # Also required later. 142 143run_make -O -e FAIL TESTS="$tests" check 144 145# Dirty trick required here. 146for tst in $(echo " $tests " | sed 's/\.test / /'); do 147 echo :copy-in-global-log: yes >> $tst.trs 148done 149 150rm -f test-suite.log 151run_make -e FAIL TESTS="$tests" test-suite.log 152cat test-suite.log 153 154have_rst_section () 155{ 156 eqeq=$(echo "$1" | sed 's/./=/g') 157 # Assume $1 contains no RE metacharacters. 158 sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got 159 (echo "$1" && echo "$eqeq") > exp 160 cat exp 161 cat got 162 diff exp got 163} 164 165have_rst_section 'PASS: ok' 166have_rst_section 'SKIP: skip' 167have_rst_section 'SKIP: skipall' 168have_rst_section 'FAIL: fail' 169have_rst_section 'FAIL: fail2' 170have_rst_section 'FAIL: xpass' 171have_rst_section 'FAIL: xpass2' 172have_rst_section 'ERROR: bail' 173have_rst_section 'ERROR: bail2' 174have_rst_section 'ERROR: bail3' 175have_rst_section 'ERROR: error' 176have_rst_section 'ERROR: error2' 177have_rst_section 'ERROR: error3' 178have_rst_section 'ERROR: error4' 179have_rst_section 'ERROR: error5' 180have_rst_section 'ERROR: error6' 181have_rst_section 'ERROR: error7' 182have_rst_section 'ERROR: hodgepodge' 183have_rst_section 'ERROR: hodgepodge-all' 184 185: 186