-
Notifications
You must be signed in to change notification settings - Fork 186
/
runtests
executable file
·124 lines (110 loc) · 3.67 KB
/
runtests
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh
#
# CherryMusic - a standalone music server
# Copyright (c) 2012 - 2014 Tom Wallroth & Tilman Boerner
#
# Project page:
# http://fomori.org/cherrymusic/
# Sources on github:
# http://github.com/devsnd/cherrymusic/
#
# CherryMusic is based on
# jPlayer (GPL/MIT license) http://www.jplayer.org/
# CherryPy (BSD license) http://www.cherrypy.org/
#
# licensed under GNU GPL version 3 (or later)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
##############################################################################
#
# run a number of tests for the project
#
##############################################################################
USAGE="Usage: $(basename $0) [-d OUTPUT_DIR] [TEST_TARGET]"
PROJECTDIR=`dirname $0`
TEST_EXCLUDE_REGEX='cherrypy'
COVERAGE_OPTIONS="--with-coverage --cover-erase"
while getopts "d:" FLAG "$@" ; do
if [ "$FLAG" = ":" -o "$FLAG" = "?" ]; then
echo $USAGE >&2
exit 1
fi
if [ "$FLAG" = "d" ]; then
if [ ! -e "$OPTARG" ]; then
mkdir -p "$OPTARG"
fi
if [ ! -d "$OPTARG" ]; then
echo "output directory $OPTARG does not exist" >&2
exit 1
fi
COVERAGE_OPTIONS="${COVERAGE_OPTIONS} --cover-html --cover-html-dir=${OPTARG}"
fi
done
# The first non-flag argument is at index $OPTIND, so shift one fewer
# to move it into $1
shift `expr $OPTIND - 1`
SPECIFIC_TEST="$1"
if [ ! -d ${PROJECTDIR} -o ! -f ${PROJECTDIR}/cherrymusic ]; then
echo "cannot find main script: 'cherrymusic'" >&2
echo "PROJECTDIR not set correctly? to fix, edit $0" >&2
exit 1
fi
if [ $SPECIFIC_TEST ]; then
# transform $SPECIFIC_TEST into TEST_LOCATION:
# (BLA.)*(BLUB) --> cherrymusicserver.BLA.BLA.test.test_BLUB
TEST_LOCATION=$( echo $SPECIFIC_TEST | sed "s/\(\([^.]\+[.]\)*\)\(\)/cherrymusicserver.\1test.test_\3/" )
COVERAGE_TARGET="cherrymusicserver.${SPECIFIC_TEST}"
COVERAGE_OPTIONS="${COVERAGE_OPTIONS} --cover-package=${COVERAGE_TARGET} --cover-branches --cover-min-percentage=100"
else
TEST_LOCATION=""
COVERAGE_TARGET="audiotranscode,cherrymusicserver,cmbootstrap"
COVERAGE_OPTIONS="${COVERAGE_OPTIONS} --cover-package=${COVERAGE_TARGET} --cover-min-percentage=56"
echo
echo "[distribution]: setup.py check"
python ${PROJECTDIR}/setup.py check
if [ $? != 0 ]; then
echo "distribution metadata check failure" >&2
exit 1
fi
echo "done."
fi
# nosetests
if [ ! "$TESTERS" ]; then
for i in "" "2" "3"; do
TESTERS="${TESTERS} nosetests${i}"
done
fi
for TESTER in $TESTERS; do
if [ $(command -v $TESTER) ]; then
RUN="${TESTER} -e ${TEST_EXCLUDE_REGEX} ${COVERAGE_OPTIONS} ${TEST_LOCATION}"
echo
echo "[${TESTER}]: ${RUN}"
$RUN
if [ $? != 0 ]; then
failed="$failed $TESTER"
else
passed="$passed $TESTER"
fi
fi
done
if [ "$failed" ]; then
echo "FAILED: $failed" >&2
exit 1
fi
if [ ! "$passed" ]; then
echo "no unittest runners found!" >&2
echo "get nosetests from https://nose.readthedocs.org/en/latest/" >&2
exit 1
fi