From a10a5b50addd655ab8cfe1e0a9c75a6aa3cdd11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Thu, 5 Mar 2020 12:15:04 +0100 Subject: [PATCH] simple 'runcheck' target that tries to open all .pd patches --- tests/Makefile | 3 ++ tests/test-patches.sh | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 tests/test-patches.sh diff --git a/tests/Makefile b/tests/Makefile index 0d82d64..dfc84ce 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -8,5 +8,8 @@ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder buildcheck installcheck: $(makefiledirs) +runcheck: + PDBINDIR=$(PDBINDIR) ./test-patches.sh $(makefiledirs:%=%/*.pd) + projects: @echo $(makefiledirs) diff --git a/tests/test-patches.sh b/tests/test-patches.sh new file mode 100755 index 0000000..0d80177 --- /dev/null +++ b/tests/test-patches.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +## simple script to open patches via Pd, and check for errors +## - each patch is opened separately +## - if an error is encountered, the Pd-printout is displayed +## (else it is suppressed) +## - if any of the patches encountered an error, the script will +## exit with a non-0 code + +if [ "x${PD}" = "x" ]; then + if [ "x${PDBINDIR}" != "x" ]; then + for exe in pd.com pd pd.exe; do + if [ -x "${PDBINDIR}/${exe}" ]; then + PD="${PDBINDIR}/${exe}" + break + fi + done + if [ "x${PD}" = "x" ]; then + echo "WARNING: couldn't find a usable Pd in '${PDBINDIR}'" 1>&2 + fi + fi +fi +if [ "x${PD}" = "x" ]; then + PD=pd +fi +echo "using Pd: ${PD}" + +failed=0 +failed_tests="" +succeeded=0 + +open1patch() { + logfile=$(mktemp) + local patch=$1 + local patchdir=${patch%%/*} + local patchfile=${patch#*/} + patchfile=${patchfile#/} + #echo "INFO: running ${patchfile} in ${patchdir}" + cd "${patchdir}" && \ + ${PD} -batch -nrt -noprefs -nostdpath -open "${patchfile}" -send "pd quit" \ + >"${logfile}" 2>&1 + ret=$? + if grep "error: ... couldn't create" "${logfile}" >/dev/null; then + ret=1 + fi + if [ "x${ret}" != "x0" ]; then + echo "" + cat "${logfile}" + echo "FAILED[$ret]: ${patch}" + else + echo "SUCCEEDED: ${patch}" + fi + rm "${logfile}" + return $ret +} + +for p in "${@}"; do + if (open1patch "${p}"); then + succeeded=$((succeeded+1)) + else + failed=$((failed+1)) + failed_tests="${failed_tests} ${p}" + fi +done + +echo "" +echo "SUCCESS: ${succeeded}" +echo "FAILURE: ${failed}" +test ${failed} -eq 0 || echo "FAILS :${failed_tests}" +test ${failed} -eq 0