-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_coverage.bat
More file actions
143 lines (122 loc) · 4.49 KB
/
run_coverage.bat
File metadata and controls
143 lines (122 loc) · 4.49 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
@echo off
setlocal enabledelayedexpansion
REM Function: Compile project, run JaCoCo coverage analysis and generate report
echo [INFO] ------------------------------------------------------------------------
echo [INFO] Running coverage analysis
echo [INFO] ------------------------------------------------------------------------
REM Configure variables
set JACOCO_AGENT=jacoco\lib\jacocoagent.jar
set JACOCO_CLI=jacoco\lib\jacococli.jar
set APP_JAR=details\target\details-master.jar
set EXEC_FILE=jacoco.exec
set CLASS_FILES=code\classes
set SOURCE_FILES=code\src
set REPORT_DIR=jacoco\report
REM Check necessary files and directories
if not exist "jacoco\lib" (
echo [ERROR] Directory jacoco\lib does not exist
exit /b 1
)
if not exist "%JACOCO_AGENT%" (
echo [ERROR] File %JACOCO_AGENT% does not exist
exit /b 1
)
if not exist "%JACOCO_CLI%" (
echo [ERROR] File %JACOCO_CLI% does not exist
exit /b 1
)
if exist "%CLASS_FILES%" (
del /q "%CLASS_FILES%"\*.*
for /d %%i in ("%CLASS_FILES%"\*) do rmdir /s /q "%%i"
) else (
mkdir "%CLASS_FILES%"
)
if not exist "%SOURCE_FILES%" (
echo [ERROR] Source directory %SOURCE_FILES% does not exist
exit /b 1
)
if not exist "%SOURCE_FILES%\org\apache\iotdb" (
echo [ERROR] Source code does not exist, please supplement it before execution
exit /b 1
)
REM Build project
call mvn clean package -DskipTests
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Maven build failed
exit /b 1
)
timeout /t 2 /nobreak >nul
REM Extract org.apache class files from jar and move to class files directory
echo [INFO] ------------------------------------------------------------------------
echo [INFO] Extracting classes from JAR: %APP_JAR%
echo [INFO] ------------------------------------------------------------------------
jar -xf "%APP_JAR%" org/
if exist org\apache\iotdb (
xcopy org\apache\iotdb "%CLASS_FILES%\org\apache\iotdb\" /E /I /H /Y >nul
)
if exist org\apache\tsfile (
xcopy org\apache\tsfile "%CLASS_FILES%\org\apache\tsfile\" /E /I /H /Y >nul
)
REM Delete no need class directory
for /d /r "%CLASS_FILES%" %%i in (subscription) do (
if exist "%%i" (
rd /s /q "%%i"
)
)
for /d /r "%CLASS_FILES%" %%i in (template) do (
if exist "%%i" (
rd /s /q "%%i"
)
)
for /d /r "%CLASS_FILES%" %%i in (filter) do (
if exist "%%i" (
rd /s /q "%%i"
)
)
if exist "code\src\org\apache\iotdb\isession\pool" (
rd /s /q "code\src\org\apache\iotdb\isession\pool"
)
REM Clean up temporary directory
if exist org (
rd /s /q org
)
REM Check if IoTDB and TsFile class directories exist in the class files directory
if not exist "%CLASS_FILES%\org\apache\iotdb" (
echo [WARN] - IoTDB classes NOT found
exit /b 1
)
if not exist "%CLASS_FILES%\org\apache\tsfile" (
echo [WARN] - TsFile classes NOT found
exit /b 1
)
echo [INFO] ------------------------------------------------------------------------
echo [INFO] Running application and collecting coverage data
echo [INFO] ------------------------------------------------------------------------
REM Run application and collect coverage data
java -ea -javaagent:%JACOCO_AGENT%=includes=org.apache.*,output=file,destfile=%EXEC_FILE%,append=false -jar %APP_JAR%
REM Add delay waiting to ensure execution completion
timeout /t 5 /nobreak >nul
REM Check if execution data file exists
if not exist "%EXEC_FILE%" (
echo [ERROR] Execution data file %EXEC_FILE% was not generated
exit /b 1
)
echo [INFO] ------------------------------------------------------------------------
echo [INFO] Generating coverage report
echo [INFO] ------------------------------------------------------------------------
REM Check if class files are available for report generation
if not exist "%CLASS_FILES%\*" (
echo [ERROR] No class files found in %CLASS_FILES% for report generation
exit /b 1
)
REM Generate coverage report
java -jar %JACOCO_CLI% report %EXEC_FILE% --classfiles %CLASS_FILES%\org\apache\iotdb\isession --classfiles %CLASS_FILES%\org\apache\iotdb\session --classfiles %CLASS_FILES%\org\apache\iotdb\rpc --sourcefiles %SOURCE_FILES% --html %REPORT_DIR%
REM Check if the inspection report was generated successfully
if %ERRORLEVEL% NEQ 0 (
echo [ERROR] Failed to generate coverage report
exit /b 1
)
echo [INFO] ------------------------------------------------------------------------
echo [INFO] Coverage analysis completed!
echo [INFO] Report location: %REPORT_DIR%\index.html
echo [INFO] ------------------------------------------------------------------------