summaryrefslogtreecommitdiff
path: root/tests/prove-runner
blob: 33dab1979f0f040402bf74d2a55298da303d0a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Helper script to run the automake testsuite through the `prove' utility.
# See the "prove" and "installprove" targets in tests/Makefile.am.

# Copyright (C) 2012 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/>.

set -u

nl='
'

tst=$1
shift

case $tst in
  *.test)
    echo 1..1
    # Protect the output contents of the test script, since it might
    # sometimes contain TAP lines that would confuse `prove'.  This
    # has already happened in practice, especially for the tests
    # checking TAP support in automake-generated test harnesses.
    (${TEST_RUNNER-} "$tst" ${1+"$@"}; echo exit status: $?) 2>&1 | awk '
      BEGIN { lastine = "exit status: 255"; }
      { print " " $0; lastline = $0; }
      END { st = lastline; sub("^exit status: *", "", st); exit st; }
    '
    st=$?
    if test $st -eq 99; then
      echo "not ok - $tst: hard failure (exit status $st)"
    elif test $st -eq 77; then
      echo "ok - $tst # SKIP"
    else
      case " ${XFAIL_TESTS-} " in
        *" $tst "*) xs=' # TODO';;
        *) xs='';;
      esac
      if test $st -eq 0; then
        echo "ok - test script $tst passed$xs"
      else
        echo "not ok - test script $tst failed (exit status $st)$xs"
      fi
    fi
    exit 0
    ;;
  *.tap)
    ${TAP_RUNNER-} "$tst" ${1+"$@"} 2>&1
    exit $?
    ;;
esac

echo "Bail out! Invalid test script name '$tst'"
exit 99