-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun-mutation-tests.bat
More file actions
154 lines (127 loc) · 4.6 KB
/
run-mutation-tests.bat
File metadata and controls
154 lines (127 loc) · 4.6 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
@echo off
setlocal enabledelayedexpansion
:: ============================================================
:: BLite — Mutation Testing Runner
:: Usa: run-mutation-tests.bat [bson|core|netstandard|all]
:: Default: all
:: ============================================================
set "ROOT=%~dp0"
set "ROOT=%ROOT:~0,-1%"
set "TARGET=%~1"
if "%TARGET%"=="" set "TARGET=all"
:: Timestamp per la cartella dei risultati
for /f "tokens=1-6 delims=/: " %%a in ("%DATE% %TIME%") do (
set "YY=%%a"
set "MM=%%b"
set "DD=%%c"
set "HH=%%d"
set "MI=%%e"
)
set "MI=%MI: =0%"
set "TIMESTAMP=%YY%%MM%%DD%_%HH%%MI%"
set "OUT_ROOT=%ROOT%\mutation-testing\StrykerOutput"
set "SUMMARY=%OUT_ROOT%\summary_%TIMESTAMP%.txt"
:: Assicura che dotnet tool sia ripristinato
echo [INFO] Ripristino dotnet tools...
cd /d "%ROOT%"
dotnet tool restore >nul 2>&1
if errorlevel 1 (
echo [ERROR] dotnet tool restore fallito.
exit /b 1
)
if not exist "%OUT_ROOT%" mkdir "%OUT_ROOT%"
echo.
echo ============================================================
echo BLite Mutation Testing
echo Target : %TARGET%
echo Output : %OUT_ROOT%
echo Avvio : %DATE% %TIME%
echo ============================================================
echo.
set "EXITCODE=0"
:: ---- Funzione helper (goto-based) ----
goto :run_%TARGET% 2>nul || (
echo [ERROR] Target non riconosciuto: "%TARGET%"
echo Valori validi: bson, core, netstandard, all
exit /b 1
)
:: ============================================================
:run_bson
echo [RUN] BLite.Bson (via BLite.Tests)
call :run_stryker "%ROOT%\tests\BLite.Tests" "BLite.Bson.csproj" "BLite.Bson"
if "%TARGET%"=="bson" goto :collect_and_exit
goto :eof
:run_core
echo [RUN] BLite.Core (via BLite.Tests)
call :run_stryker "%ROOT%\tests\BLite.Tests" "BLite.Core.csproj" "BLite.Core"
if "%TARGET%"=="core" goto :collect_and_exit
goto :eof
:run_netstandard
echo [RUN] BLite.Core — .NET Standard 2.1 (via BLite.NetStandard21.Tests)
call :run_stryker "%ROOT%\tests\BLite.NetStandard21.Tests" "BLite.Core.csproj" "BLite.NetStandard21"
if "%TARGET%"=="netstandard" goto :collect_and_exit
goto :eof
:run_all
call :run_bson
call :run_core
call :run_netstandard
goto :collect_and_exit
:: ============================================================
:: Subroutine: run_stryker <test-dir> <project> <out-subdir>
:run_stryker
set "_DIR=%~1"
set "_PROJ=%~2"
set "_OUTDIR=%OUT_ROOT%\%~3"
echo Directory : %_DIR%
echo Progetto : %_PROJ%
echo Output : %_OUTDIR%
:: Pulizia StrykerOutput locale residuo da run precedenti
if exist "%_DIR%\StrykerOutput" rmdir /s /q "%_DIR%\StrykerOutput"
cd /d "%_DIR%"
:: --output scrive direttamente nella cartella centralizzata;
:: l'exitcode viene catturato SENZA pipe (pipe in CMD riflette exitcode del
:: comando a destra, non di Stryker — bug silenzioso con tee)
dotnet tool run dotnet-stryker -- --project "%_PROJ%" --output "%_OUTDIR%"
set "_EC=%ERRORLEVEL%"
if %_EC% neq 0 (
echo [WARN] Stryker ha restituito un errore (exitcode: %_EC%) per %_PROJ%
set "EXITCODE=1"
) else (
echo [OK] %_PROJ% completato.
)
echo.
cd /d "%ROOT%"
goto :eof
:: ============================================================
:collect_and_exit
echo.
echo ============================================================
echo Raccolta risultati...
echo ============================================================
:: Genera un sommario testuale con i percorsi dei report HTML
echo BLite Mutation Testing — %DATE% %TIME% > "%SUMMARY%"
echo Target: %TARGET% >> "%SUMMARY%"
echo. >> "%SUMMARY%"
set "FOUND=0"
for /r "%OUT_ROOT%" %%f in (mutation-report.html) do (
echo Report HTML : %%f >> "%SUMMARY%"
set /a "FOUND+=1"
)
for /r "%OUT_ROOT%" %%f in (mutation-report.json) do (
echo Report JSON : %%f >> "%SUMMARY%"
)
if "%FOUND%"=="0" (
echo (nessun report trovato) >> "%SUMMARY%"
)
echo.
echo [INFO] Riepilogo scritto in:
echo %SUMMARY%
echo.
:: Apri la cartella di output in Explorer
echo [INFO] Apertura cartella risultati...
start "" explorer "%OUT_ROOT%"
echo.
echo ============================================================
echo Fine — exitcode: %EXITCODE%
echo ============================================================
exit /b %EXITCODE%