aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.sh
blob: fa2128bd4aa69283e69f7b7e9009678f796ea5f5 (plain)
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
#!/bin/sh

## TODO:
##  find zexy (either in ../src or ../)
##  if it is not there, assume it is split into externals

if [ "x${PD}" = "x" ]
then
 PD=pd
fi


#SUFFIX="$$"
SUFFIX=$(date +%y%m%d-%H%M%S)

RUNTESTS_TXT=runtests.txt
RUNTESTS_LOG=log-runtests.${SUFFIX}

LIBFLAGS="-path ../src:../ -lib zexy -path ../abs/"

function list_tests() {
#  find . -mindepth 2  -name "*.pd" | sed 's|\.pd$|;|' 
 ls -1 */*.pd | sed 's|\.pd$|;|'
}

function debug() {
 :
# echo $@
}


function evaluate_tests() {
 local logfile
 local testfile
 local numtests

 testfile=$1
 logfile=$2

 debug "now evaluating results in ${logfile} (${testfile}"

 numtests=$(grep -c . ${testfile})
 debug "number of tests = ${numtests}"
 echo "regression-test: ${numtests} tests total" >>  ${logfile}
 debug "show results"
 cat ${logfile} | egrep "^regression-test: " | sed -e 's/^regression-test: //'
}


function run_nogui() {
 debug "running test without gui"
 ${PD} ${LIBFLAGS} -nogui runtests_nogui.pd > ${RUNTESTS_LOG} 2>&1 
 debug "testing done"
 evaluate_tests ${RUNTESTS_TXT} ${RUNTESTS_LOG}
 debug "testing finished"
}

function run_withgui() {
 debug "running test with gui"
 ${PD} ${LIBFLAGS} -stderr runtests.pd > ${RUNTESTS_LOG} 2>&1
 debug "testing completed, no evaluation will be done; see ${RUNTESTS_LOG} for results"
}

list_tests > ${RUNTESTS_TXT}

if test "x$1" = "x-gui"; then
 run_withgui
else
 run_nogui
fi