File: wrapper

package info (click to toggle)
mpv-mpris 1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176 kB
  • sloc: ansic: 1,063; sh: 184; makefile: 79
file content (56 lines) | stat: -rwxr-xr-x 1,005 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

set -e


if [ -z "$MPV_MPRIS_TEST_LOG" ] ; then
        MPV_MPRIS_TEST_LOG=.
fi


test="$1"
exit_code="$MPV_MPRIS_TEST_LOG/$test.exit-code.log"
stderr="$MPV_MPRIS_TEST_LOG/$test.stderr.log"


rm -f "$exit_code" "$stderr"


# This construct directs stderr to what it currently is
# but also sends it to a file for checking afterwards
# and also saves the exit code to a file for checking.
exec 3>&1
{
	ret=0
	"./$test" 2>&1 >&3 ||
	ret=$?
	echo "$ret" > "$exit_code"
} |
tee "$stderr"


< "$exit_code" read -r ret


if [ -s "$stderr" ] ; then
	if [ -z "$MPV_MPRIS_TEST_NO_STDERR" ] ; then
		echo "test $test: stderr not empty!" >&2
		echo "test $test: start of stderr ---------------------" >&2
		cat "$stderr" >&2
		echo "test $test: end of stderr -----------------------" >&2
	fi
	echo "test $test: stderr not empty!" >&2
fi

if [ "$ret" -ne 0 ] ; then
	echo "test $test: failed with exit code $ret" >&2
fi


if [ "$ret" -ne 0 ] ; then
	 exit "$ret"
fi

if [ -s "$stderr" ] ; then
	 exit 1
fi