File: runtests.sh

package info (click to toggle)
pd-iemmatrix 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,588 kB
  • sloc: ansic: 15,027; makefile: 285; sh: 125
file content (81 lines) | stat: -rwxr-xr-x 1,810 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh


: "${PD:=pd}"
: "${PDARGS:=-noprefs -nosound -nrt}"

builddir="$(cd ..; pwd)"
: "${libdir:=${builddir}}"
: "${absdir:=${builddir}/abs}"

: "${IEMMATRIX:=-lib "${libdir}/iemmatrix" -path "${absdir}"}"

RUNTESTS_TXT=runtests.txt
runtests_log=runtests.log

if [ "${RUNTESTS_LOG}" != "${RUNTESTS_LOG%/*}" ]; then
	mkdir -p "${RUNTESTS_LOG%/*}" || true
fi

XITCODE=0

for f in */*.pd; do
  test -e "${f}" && echo "${f%.pd};"
done | LC_ALL=C sort > "${RUNTESTS_TXT}"

run_nogui() {
 echo ${PD} ${PDARGS} ${IEMMATRIX} -nogui runtests_nogui.pd > "${RUNTESTS_LOG}" 2>&1
 ${PD} ${PDARGS} ${IEMMATRIX} -nogui runtests_nogui.pd >> "${RUNTESTS_LOG}" 2>&1
 pdexit="$?"
 NUMTESTS=$(grep -c . "${RUNTESTS_TXT}")
 echo "regression-test: ${NUMTESTS} tests total" >>  "${RUNTESTS_LOG}"

 cat "${RUNTESTS_LOG}" \
     | grep -E "^regression-test: " \
     | sed -e 's/^regression-test: //'
 FAILEDTESTS=$(cat "${RUNTESTS_LOG}" \
                   | grep -E "^regression-test: .*: failed$" \
                   | sed -e 's|^regression-test: ||' -e 's|: failed$||' \
                   | tr '\n' ' ' \
            )
 echo "failed tests: ${FAILEDTESTS}"
 if [ -n "${FAILEDTESTS}" ]; then
   XITCODE=1
 fi

 if [ "${pdexit}" != 0 ]; then
     echo "Pd exited with ${pdexit}"
     XITCODE=2
 fi
}

run_withgui() {
 ${PD} ${PDARGS} ${IEMMATRIX} -stderr runtests.pd 2>&1 | tee "${RUNTESTS_LOG}"
}

if test "$1" = "-gui"; then
 : "${RUNTESTS_LOG:=${runtests_log}}"
 run_withgui
else
 : "${RUNTESTS_LOG:=${runtests_log}.$(date +%Y%m%d-%H%M).$$}"
 run_nogui
fi

show_log=no
case "${RUNTESTS_SHOW_LOG}" in
	"always")
		show_log=yes
		;;
	"failure")
		test "${XITCODE}" = "0"  || show_log=yes
		;;
esac

if [ "${show_log}" = "yes" ]; then
	echo
	echo "output of ${RUNTESTS_LOG}:"
	cat "${RUNTESTS_LOG}"
	echo
fi

exit ${XITCODE}