libmpdserver

Parser combinator library for MPD client commands

git clone https://git.8pit.net/libmpdserver.git

 1#!/bin/sh
 2
 3TESTRUNNER="$(pwd)/../cmd2yaml"
 4
 5dir=${TMPDIR:-/tmp}/libmpdserver
 6trap "rm -rf '${dir}' 2>/dev/null" INT EXIT
 7mkdir -p "${dir}"
 8
 9result=0
10for test in *; do
11	[ -d "${test}" ] || continue
12
13	name=${test##*/}
14	printf "Running test case '%s': " "${name}"
15
16	(cd "${test}" && "${TESTRUNNER}" <input >"${dir}/out.pre")
17	ret=$?
18
19	test -r "${test}/output.yml"
20	expected=$?
21
22	if [ ${ret} -ne ${expected} ]; then
23		printf "FAIL: Expected '%d', got '%d'.\n" \
24			"${expected}" "${ret}"
25
26		result=1
27		continue
28	fi
29
30	sed 's/[ \t]*$//' < "${dir}/out.pre" > "${dir}/out"
31	if [ ${ret} -eq 0 ] && ! cmp -s "${dir}/out" "${test}/output.yml"; then
32		printf "FAIL: Output didn't match.\n"
33		diff -u "${dir}/out" "${test}/output.yml"
34
35		result=1
36		continue
37	fi
38
39	printf "OK.\n"
40done
41
42exit "${result}"