| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 | #! /bin/sh# Copyright (C) 2011-2017 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# TAP support:#  - which global test result derives from different test results#    mixed in a single script?. test-init.sh. tap-setup.shcat > ok.test <<END1..3ok 1not ok 2 # TODOok 3 # SKIPENDcat > skip.test <<'END'1..3ok 1 # SKIPok 2 # SKIPok 3 # SKIPENDcat > skipall.test <<'END'1..0 # SKIPfoo# barENDcat > fail.test <<'END'1..1not ok 1END(sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.testcat > xpass.test <<'END'1..1ok 1 # TODOEND(sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.testecho 'Bail out!' > bail.test(cat ok.test && echo 'Bail out!') > bail2.testcat > bail3.test <<'END'1..0 # SKIPBail out!END# Too many tests.cat > error.test <<'END'1..2ok 1ok 2 # SKIPnot ok 3not ok 4 # TODOEND# Too few tests.cat > error2.test <<'END'1..4ok 1not ok 2 # TODOok 3 # SKIPEND# Repeated plan.cat > error3.test <<'END'1..21..2ok 1ok 2END# Too many tests, after a "SKIP" plan.cat > error4.test <<'END'1..0 # SKIPok 1ok 2END# Tests out of order.cat > error5.test <<'END'1..4not ok 1 # TODOok 3ok 2ok 4END# Wrong test number.cat > error6.test <<'END'1..2ok 1 # SKIPok 7END# No plan.cat > error7.test <<'END'ok 1 # SKIPok 2 # TODOnot ok 3 # TODOok 4ENDcat > hodgepodge.test <<'END'1..2not ok 1ok 2 # TODOBail out!ENDcat > hodgepodge-all.test <<'END'1..4ok 1ok 2 # SKIPnot ok 2 # TODOnot ok 3ok 4 # TODOBail out!ENDtests=$(echo *.test) # Also required later.run_make -O -e FAIL TESTS="$tests" check# Dirty trick required here.for tst in $(echo " $tests " | sed 's/\.test / /'); do  echo :copy-in-global-log: yes >> $tst.trsdonerm -f test-suite.logrun_make -e FAIL TESTS="$tests" test-suite.logcat test-suite.loghave_rst_section (){  eqeq=$(echo "$1" | sed 's/./=/g')  # Assume $1 contains no RE metacharacters.  sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got  (echo "$1" && echo "$eqeq") > exp  cat exp  cat got  diff exp got}have_rst_section 'PASS: ok'have_rst_section 'SKIP: skip'have_rst_section 'SKIP: skipall'have_rst_section 'FAIL: fail'have_rst_section 'FAIL: fail2'have_rst_section 'FAIL: xpass'have_rst_section 'FAIL: xpass2'have_rst_section 'ERROR: bail'have_rst_section 'ERROR: bail2'have_rst_section 'ERROR: bail3'have_rst_section 'ERROR: error'have_rst_section 'ERROR: error2'have_rst_section 'ERROR: error3'have_rst_section 'ERROR: error4'have_rst_section 'ERROR: error5'have_rst_section 'ERROR: error6'have_rst_section 'ERROR: error7'have_rst_section 'ERROR: hodgepodge'have_rst_section 'ERROR: hodgepodge-all':
 |