Merge branch 'master' of ssh://lausser,shinken@shinken.git.sourceforge.net/gitroot...
[shinken.git] / test / jenkins / runtests.bat
blob64ce445a6d48563c65e4db887cd80308e6e1840a
1 :: Copyright (C) 2009-2011 :
2 ::     Gabes Jean, naparuba@gmail.com
3 ::     Gerhard Lausser, Gerhard.Lausser@consol.de
4 ::
5 :: This file is part of Shinken.
6 ::
7 :: Shinken is free software: you can redistribute it and/or modify
8 :: it under the terms of the GNU Affero General Public License as published by
9 :: the Free Software Foundation, either version 3 of the License, or
10 :: (at your option) any later version.
12 :: Shinken is distributed in the hope that it will be useful,
13 :: but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 :: GNU Affero General Public License for more details.
17 :: You should have received a copy of the GNU Affero General Public License
18 :: along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
20 REM USAGE: RUNTESTS LIST_WITH_TESTS.txt [NO]COVERAGE [NO]PYLINT
22 @ECHO OFF
23 ECHO RUNNING SHORT TESTS
25 SET TESTLIST=%~dpnx1
26 SET COVERAGE=%2
27 SET PYLINT=%3
29 IF NOT (%COVERAGE%) == (COVERAGE) SET COVERAGE=NOCOVERAGE
30 IF NOT (%PYLINT%) == (PYLINT) SET PYLINT=NOPYLINT
31 IF (%PYTHONVERS%) == (%PYTHONVERS%) SET PYTHONVERS=27
32 IF (%PYTHONVERS%) == (271) SET PYTHONVERS=27
33 IF (%PYTHONVERS%) == (266) SET PYTHONVERS=26
34 IF (%PYTHONVERS%) == (246) SET PYTHONVERS=24
35 SET PYTHONBIN=C:\Python%PYTHONVERS%
36 SET PYTHONTOOLS=C:\Python%PYTHONVERS%\Scripts
37 SET PATH=%PYTHONBIN%;%PYTHONTOOLS%;%PATH%
39 REM This script is located in test/jenkins but needs to be run from test.
40 REM Find out the script's directory and then go to the dir one level above. 
41 CD %~dp0\..
43 REM Clean up leftovers from a former run
44 DEL nosetests.xml
45 IF %COVERAGE% == COVERAGE DEL coverage.xml
46 IF %COVERAGE% == COVERAGE DEL .coverage
48 REM Now run a list of test files in a loop. Abort the loop if a test failed.
49 REM If this is a simple functional test, abort the loop if a test failed.
50 REM For a run with coverage, execute them all.
51 FOR /F "eol=# tokens=1" %%f in (%TESTLIST%) DO (
52 CALL :FUNC1 %%f
53 IF %COVERAGE% == NOCOVERAGE IF %PYLINT% == NOPYLINT IF ERRORLEVEL 1 GOTO FAIL
56 IF %COVERAGE% == COVERAGE CALL :DOCOVERAGE
57 CD ..
58 IF %PYLINT% == PYLINT CALL :DOPYLINT
59 ECHO THATS IT
60 EXIT /B 0
62 :FAIL
63 ECHO One of the tests failed, so i give up.
64 EXIT /B 1
66 :DOCOVERAGE
67 %PYTHONTOOLS%\coverage xml --omit=/usr/lib
68 IF NOT ERRORLEVEL 0 ECHO COVERAGE HAD A PROBLEM
69 GOTO :EOF [Return to Main]
71 :DOPYLINT
72 CALL %PYTHONTOOLS%\pylint --rcfile test\jenkins\pylint.rc shinken > pylint.txt
73 IF NOT ERRORLEVEL 0 ECHO PYLINT HAD A PROBLEM
74 GOTO :EOF [Return to Main]
76 REM Here is where the tests actually run
77 :FUNC1 
78 ECHO I RUN %1
79 IF %COVERAGE% == NOCOVERAGE IF %PYLINT% == NOPYLINT %PYTHONTOOLS%\nosetests -v -s --with-xunit %1
80 IF %COVERAGE% == COVERAGE %PYTHONTOOLS%\nosetests -v -s --with-xunit --with-coverage %1
81 IF ERRORLEVEL 1 GOTO :EOF
82 ECHO successfully ran %1
83 GOTO :EOF [Return to Main]