summaryrefslogtreecommitdiff
path: root/test/glib-tap-test.sh
blob: 5e5e6e5f9fd4c490dedaa605091f1183aac0afff (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
#!/bin/sh
# Wrapper to make GTest tests output TAP syntax, because Automake's test
# drivers do not currently support passing the same command-line argument
# to each test executable. All GTest tests produce TAP output if invoked
# with the --tap option.
#
# Usage: "glib-tap-test.sh test-foo --verbose ..." is equivalent to
# "test-foo --tap --verbose ..."

set -e
t="$1"
shift

case "$t" in
    (*.exe)
        # We're running a Windows executable, possibly on a Unix
        # platform. Avoid having invalid TAP syntax like "ok 3\r\n"
        # where "ok 3\n" was intended.
        echo 1 > "$t".exit-status.tmp
        (
            set +e
            "$t" --tap "$@"
            echo "$?" > "$t".exit-status.tmp
        ) | sed -e 's/\r$//'
        e="$(cat "$t".exit-status.tmp)"
        rm "$t".exit-status.tmp
        exit "$e"
        ;;

    (*)
        exec "$t" --tap "$@"
        ;;
esac