-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoverage.cmd
More file actions
216 lines (197 loc) · 5.55 KB
/
coverage.cmd
File metadata and controls
216 lines (197 loc) · 5.55 KB
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
@echo off
REM ============================================================================
REM WinDevices Code Coverage Script
REM ============================================================================
REM This script runs code coverage analysis for WinDevices
REM
REM Usage:
REM coverage.cmd [debug|release] [options]
REM
REM Arguments:
REM debug|release - Build configuration (default: debug)
REM
REM Options:
REM --unit - Run unit tests coverage only (default)
REM --e2e - Run E2E tests coverage only
REM --all - Run combined coverage (unit + E2E)
REM --rebuild - Rebuild before running coverage
REM --open - Open coverage report in browser
REM --help - Show this help message
REM
REM Examples:
REM coverage.cmd
REM coverage.cmd debug --open
REM coverage.cmd release --all --rebuild
REM coverage.cmd debug --e2e --open
REM ============================================================================
setlocal enabledelayedexpansion
REM Default values
set BUILD_TYPE=debug
set COVERAGE_TYPE=unit
set REBUILD=0
set OPEN_REPORT=0
REM Parse arguments
:parse_args
if "%~1"=="" goto :args_done
if /i "%~1"=="debug" (
set BUILD_TYPE=debug
shift
goto :parse_args
)
if /i "%~1"=="release" (
set BUILD_TYPE=release
shift
goto :parse_args
)
if /i "%~1"=="--unit" (
set COVERAGE_TYPE=unit
shift
goto :parse_args
)
if /i "%~1"=="--e2e" (
set COVERAGE_TYPE=e2e
shift
goto :parse_args
)
if /i "%~1"=="--all" (
set COVERAGE_TYPE=all
shift
goto :parse_args
)
if /i "%~1"=="--rebuild" (
set REBUILD=1
shift
goto :parse_args
)
if /i "%~1"=="--open" (
set OPEN_REPORT=1
shift
goto :parse_args
)
if /i "%~1"=="--help" (
echo.
echo WinDevices Code Coverage Script
echo.
echo Usage: coverage.cmd [debug^|release] [options]
echo.
echo Arguments:
echo debug^|release - Build configuration (default: debug)
echo.
echo Options:
echo --unit - Run unit tests coverage only (default)
echo --e2e - Run E2E tests coverage only
echo --all - Run combined coverage (unit + E2E)
echo --rebuild - Rebuild before running coverage
echo --open - Open coverage report in browser
echo --help - Show this help message
echo.
echo Examples:
echo coverage.cmd
echo coverage.cmd debug --open
echo coverage.cmd release --all --rebuild
echo coverage.cmd debug --e2e --open
echo.
exit /b 0
)
echo Unknown argument: %~1
exit /b 1
:args_done
REM Set preset name and config
if /i "%BUILD_TYPE%"=="debug" (
set PRESET=windows-debug
set CONFIG=Debug
) else (
set PRESET=windows-release
set CONFIG=Release
)
REM Set coverage target and report path
if /i "%COVERAGE_TYPE%"=="unit" (
set COVERAGE_TARGET=coverage
set REPORT_PATH=build\%PRESET%\coverage\index.html
) else if /i "%COVERAGE_TYPE%"=="e2e" (
set COVERAGE_TARGET=coverage-e2e
set REPORT_PATH=build\%PRESET%\coverage\e2e\index.html
) else (
set COVERAGE_TARGET=coverage-all
set REPORT_PATH=build\%PRESET%\coverage\all\index.html
)
echo.
echo ============================================================================
echo WinDevices Code Coverage
echo ============================================================================
echo Configuration: %BUILD_TYPE% (%CONFIG%)
echo Coverage type: %COVERAGE_TYPE%
echo Rebuild: %REBUILD%
echo ============================================================================
echo.
REM Check if OpenCppCoverage is installed
where OpenCppCoverage.exe >nul 2>&1
if errorlevel 1 (
echo ERROR: OpenCppCoverage not found!
echo.
echo Please install OpenCppCoverage:
echo Option 1: choco install opencppcoverage
echo Option 2: Download from https://github.com/OpenCppCoverage/OpenCppCoverage/releases
echo.
exit /b 1
)
REM Check if build exists
if not exist "build\%PRESET%" (
echo Build directory not found. Running initial configuration...
cmake --preset %PRESET%
if errorlevel 1 (
echo ERROR: CMake configuration failed!
exit /b 1
)
)
REM Rebuild if requested
if %REBUILD%==1 (
echo Rebuilding...
cmake --build build\%PRESET% --config %CONFIG% --clean-first
if errorlevel 1 (
echo ERROR: Build failed!
exit /b 1
)
echo.
)
REM Run coverage
echo Running %COVERAGE_TYPE% coverage analysis...
echo Target: %COVERAGE_TARGET%
echo.
cmake --build build\%PRESET% --target %COVERAGE_TARGET% --config %CONFIG%
set COVERAGE_EXIT=%errorlevel%
echo.
if %COVERAGE_EXIT% NEQ 0 (
echo WARNING: Coverage analysis completed with errors
echo Some tests may have failed, but coverage report was still generated
echo.
)
REM Check if report was generated
if not exist "%REPORT_PATH%" (
echo ERROR: Coverage report not found at: %REPORT_PATH%
exit /b 1
)
echo ============================================================================
echo Coverage Report Generated
echo ============================================================================
echo.
echo Report location: %REPORT_PATH%
echo.
REM Display summary if possible
if /i "%COVERAGE_TYPE%"=="all" (
echo Cobertura XML: build\%PRESET%\coverage\all\coverage.xml
echo.
)
REM Open report if requested
if %OPEN_REPORT%==1 (
echo Opening coverage report in browser...
start %REPORT_PATH%
) else (
echo To view the report, run:
echo start %REPORT_PATH%
echo.
echo Or run this script with --open flag:
echo coverage.cmd %BUILD_TYPE% --%COVERAGE_TYPE% --open
)
echo.
exit /b 0