dbus/test/glib-tap-test.sh
Simon McVittie 24342d5912 When running TAP tests, filter out trailing \r from Windows .exe
If we're running Windows executables using Wine, then tap-driver.sh
won't accept "1..4\r\n" as TAP syntax.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92538
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-10-29 05:50:27 +01:00

33 lines
901 B
Bash
Executable file

#!/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