mmp

The mini music player, an alternative to MPD

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

 1#!/bin/sh
 2
 3cd "${0%/*}"
 4
 5export MMP_TEST_ADDR="${MMP_TEST_ADDR:-localhost}"
 6export MMP_TEST_PORT="${MMP_TEST_PORT:-6600}"
 7
 8mkdir -p "${testdir:=${TMPDIR:-/tmp}/mmp-tests}"
 9trap 'rm -rf ${testdir} ; kill %1 2>/dev/null' INT EXIT
10
11export MMP_MUISC_DIRECTORY="${testdir}/music"
12mkdir -p "${MMP_MUISC_DIRECTORY}"
13
14export BEETSDIR="$(pwd)/testdata/beets"
15sed -e "s|@MMP_TEST_DIRECTORY@|${testdir}|g" \
16	-e "s|@MMP_MUISC_DIRECTORY@|${MMP_MUISC_DIRECTORY}|g" \
17	< "${BEETSDIR}/config.yaml.in" > "${BEETSDIR}/config.yaml"
18beet import --nowrite --noautotag --quiet \
19	./testdata/music >"${testdir}/beet-import-log" 2>&1
20
21for test in *; do
22	[ -e "${test}/commands" ] || continue
23	printf "Running test case '%s': " "${test##*/}"
24
25	hy ../mmp.hy -a "${MMP_TEST_ADDR}" -p "${MMP_TEST_PORT}" \
26		"${testdir}/beets.db" &
27	./wait_port.hy "${MMP_TEST_ADDR}" "${MMP_TEST_PORT}"
28
29	output="${testdir}/output"
30	env -i HOST="${MMP_TEST_ADDR}" PORT="${MMP_TEST_PORT}" \
31		MUSICDIR="${MMP_MUISC_DIRECTORY}" \
32		PATH="$(pwd):${PATH}" sh "${test}/commands" >"${output}" 2>&1
33
34	expected="${testdir}/expected"
35	sed "/./!d" < "${test}/output" > "${expected}"
36
37	if ! cmp -s "${output}" "${expected}"; then
38		printf "FAIL: Output didn't match.\n\n"
39		diff -u "${output}" "${expected}"
40		exit 1
41	fi
42
43	kill %1; wait %1
44	printf "OK.\n"
45done