2 #Copyright (C) 2009-2010 :
3 # Gabes Jean, naparuba@gmail.com
4 # Gerhard Lausser, Gerhard.Lausser@consol.de
6 #This file is part of Shinken.
8 #Shinken is free software: you can redistribute it and/or modify
9 #it under the terms of the GNU Affero General Public License as published by
10 #the Free Software Foundation, either version 3 of the License, or
11 #(at your option) any later version.
13 #Shinken is distributed in the hope that it will be useful,
14 #but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #GNU Affero General Public License for more details.
18 #You should have received a copy of the GNU Affero General Public License
19 #along with Shinken. If not, see <http://www.gnu.org/licenses/>.
24 TESTLIST
=$
(readlink
-f $TESTLIST)
25 test "$COVERAGE" == "COVERAGE" || COVERAGE
="NOCOVERAGE"
26 test "$PYLINT" == "PYLINT" || PYLINT
="NOPYLINT"
27 test "$PYTHONVERS" == "" && PYTHONVERS
=27
28 test "$PYTHONVERS" == "27" && PYTHONVERS
=2.7.1
29 test "$PYTHONVERS" == "26" && PYTHONVERS
=2.6.6
30 test "$PYTHONVERS" == "24" && PYTHONVERS
=2.4.6
31 PYTHONBIN
=${PYTHONBIN:-/opt/python-${PYTHONVERS}/bin/python}
32 PYTHONTOOLS
=${PYTHONTOOLS:-/opt/python-${PYTHONVERS}/bin}
35 DIR
=$
(cd $
(dirname "$0"); pwd)
39 # Cleanup leftover files from former runs
41 test $COVERAGE == "COVERAGE" && rm -f coverage.xml
42 test $COVERAGE == "COVERAGE" && rm -f .coverage
44 function launch_and_assert
{
46 if test $COVERAGE == "NOCOVERAGE"; then
47 ${PYTHONTOOLS}/nosetests
-v -s --with-xunit .
/$SCRIPT
49 ${PYTHONTOOLS}/nosetests
-v -s --with-xunit --with-coverage .
/$SCRIPT
53 echo "Error : the test $SCRIPT failed"
56 echo "test $SCRIPT succeeded, next one"
65 *) launch_and_assert
$tfile
70 # Create the coverage file
71 if test $COVERAGE == "COVERAGE"; then
72 echo merging coverage files
73 ${PYTHONTOOLS}/coverage xml
--omit=/usr
/lib
75 if test $PYLINT == "PYLINT"; then
77 echo checking the code with pylint
78 ${PYTHONTOOLS}/pylint
--rcfile test
/jenkins
/pylint.rc shinken
> pylint.txt
81 if test $COVERAGE == "COVERAGE" && test $PYLINT == "PYLINT"; then
82 # this run's purpose was to collect metrics, so let jenkins think, it's ok