-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitTestScripts.bat
74 lines (55 loc) · 1.55 KB
/
UnitTestScripts.bat
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
::
:: UnitTestScripts.bat
::
:: Author: Vincent Kocks (engineering@vingenuity.net)
:: v1.3.0
::
:: Runs unit test scripts for Python projects.
::
@echo off
:: Static Environment Variables
set PROJECT_NAME=VRROOMpy
set PROJECT_ROOT=.
set COVERAGE_REPORT_PATH=%PROJECT_ROOT%\htmlcov\index.html
set PYTHON=python
set OPEN_REPORT=True
rem set SKIP_INSTALL=True
set VERBOSE=True
:: Dynamic Environment Variables
if defined VERBOSE set VERBOSE_ARG=-v
:: Main Execution
if defined SKIP_INSTALL (
echo Skipping installation of required packages due to %%SKIP_INSTALL%% being set.
goto :main
)
echo Installing required Python packages for %PROJECT_NAME%...
%PYTHON% -m pip install -e .[dev]
if ERRORLEVEL 1 goto :package_install_error
echo Installed required packages successfully.
:main
pushd %PROJECT_ROOT%
echo Linting %PROJECT_NAME% scripts...
%PYTHON -m black .
echo Testing %PROJECT_NAME% scripts...
%PYTHON% -m coverage run --branch -m unittest discover %VERBOSE_ARG%
echo Generating coverage reports...
%PYTHON% -m coverage report
%PYTHON% -m coverage html
popd
if not defined OPEN_REPORT (
echo Environment variable %%OPEN_REPORT%% not set.
echo Skipping opening of coverage report.
goto :finish
)
if not exist %COVERAGE_REPORT_PATH% goto :report_open_error
echo Opening coverage report...
start "Coverage Report", "%COVERAGE_REPORT_PATH%"
goto :finish
:package_install_error
echo Python package installation failed!
goto :finish
:report_open_error
echo Unable to find coverage report to open!
goto :finish
:finish
if /I not "%1"=="-nopause" pause