This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
install-all-tests.bat
216 lines (172 loc) · 5.22 KB
/
install-all-tests.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
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
setlocal enabledelayedexpansion
set pwdd=%CD%
set logfile=log.txt
set TE_BASE=%1
if NOT DEFINED TE_BASE (
echo.
echo [FAIL] Require a directory where TE_BASE is located, as the fist argument.
echo.
call :printHelp
GOTO END
) else if NOT EXIST "!TE_BASE!" (
echo.
echo [FAIL] Argument 1 '!TE_BASE!' is not a directory. The TE_BASE directory is required.
echo.
call :printHelp
GOTO END
)
set TE=%2
if NOT DEFINED TE (
echo.
echo [FAIL] Require a directory where TEAM Engine has been deployed as a war file, as the second argument.
echo.
call :printHelp
GOTO END
) else if NOT EXIST "!TE!" (
echo.
echo [FAIL] Argument 2 '!TE!' is not a directory.
echo A directory where TEAM Engine has been deployed as a war file, is required.
echo.
call :printHelp
GOTO END
)
set CSV=%3
if NOT DEFINED CSV (
echo.
echo [FAIL] Require a CSV file that provides a git url and revision of the tests, as third argument.
echo.
call :printHelp
GOTO END
) else if NOT EXIST "!CSV!" (
echo.
echo [FAIL] Argument 3 '!CSV!' is not a file. A CSV file that provides a git url and revision number.
echo.
call :printHelp
GOTO END
)
set TEMP_DIR=%4
if NOT DEFINED TEMP_DIR (
echo.
echo [FAIL] Require temporary directory to build tests.
echo.
call :printHelp
GOTO END
) else if NOT EXIST "!TEMP_DIR!" (
echo.
echo [FAIL] Argument 4 '!TEMP_DIR!' is not a directory.
echo.
call :printHelp
GOTO END
)
set status=%5
if DEFINED status (
if "!status!" == "true" (
echo [INFO] Tests will be skipped when packaging using -DskipTests
SET "SKIP=true"
) else (
echo [WARNING] Fifth argument was provided, but it is not 'true'.
echo Tests will run when building mvn
)
) else (
echo.
echo [INFO] 5th argument was not provided. Tests will not be skipped.
echo.
)
echo.
echo [INFO] The provided TE_BASE directory, TEAMEngine directory and CSV file appeared to be fine.
:: continue is everything is fine
echo '[INFO] Removing all tests from TE_BASE'
if EXIST "!TE_BASE!\scripts\" (
pushd !TE_BASE!\scripts\
for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do del /q "%%A"
popd
REM rd /q !TE_BASE!\scripts\
) else (
echo [WARNING] the following directory was not found: '!TE_BASE!\scripts\'.
)
SET failures=0
SET "fail_message="
for /f "usebackq tokens=1-2 delims=," %%a in ("!CSV!") do (
echo.
echo.
SET url=%%a
SET tag=%%b
SET res=false
if NOT "!url!" == "Repository" SET res=true
if "!res!" == "true" (
echo '[INFO] Found ' !url! !tag!
cd !pwdd!
if DEFINED url (
echo '[INFO] Processing ' !url! !tag!
echo "TEMP: " !TEMP_DIR!
REM Delete all the data from the temp directory.
if EXIST "!TEMP_DIR!" (
pushd !TEMP_DIR!
for /f "Tokens=*" %%A in ('dir /B /S /A:-D^|FIND /V "%~nx0"') do del /s /q "%%A" >NUL 2>&1
for /f "Tokens=*" %%A in ('dir /B /A:D') do rd /s /q "%%A" >NUL 2>&1
popd
)
pushd !TEMP_DIR!
call git clone !url! 2>nul
If !errorlevel! NEQ 0 (
SET "err=[ERROR] - Repository doesn't exist: !url!"
echo !err! >>!logfile!
echo "!err!"
GOTO END
)
REM Get the test name
FOR /f "tokens=1*delims=\/" %%i IN ("!url!") DO SET basename=%%~nxj
SET "ets_name=!basename:.="!^&REM #
echo "[URL]: " !ets_name!
cd !ets_name!
REM get all the tag list into array.
for /F "delims=" %%f in ('call git tag') do (
SET /a output_cnt+=1
SET "output[!output_cnt!]=%%f"
)
SET NL=^ & echo.
SET "tag_status=false"
REM Check tag is exist or not.
for /L %%n in (1 1 !output_cnt!) DO if "!tag!" == "!output[%%n]!" SET "tag_status=true"
If "!tag_status!"=="true" (
echo "[INFO] !tag! of !ets_name! exists. Checking it out."
REM Checkout the test to specified tag.
call git checkout !tag! 2>NUL
REM Call another batch script 'build_test.bat' to build the test.
call !pwdd!\build_test.bat !TE_BASE! !TE! !SKIP! >log_build_test.txt
REM Check the log file if the test is successfully build or not
>nul find "FAIL" log_build_test.txt && (
SET "fail_message=!fail_message!!NL! !ets_name! !tag!"
set /A failures+=1
echo "After Check...."
)
) else (
echo "[ERROR] TAG NOT FOUND tag:'!tag! 'it was not build"
echo "[ERROR] TAG NOT FOUND tag:'!tag! 'it was not build" >>!logfile!
)
)
)
)
If !failures! GTR 0 (
echo "Total failures: "!failures!
echo !fail_message!
echo.
)
echo "------------- End -----------"
GOTO END
:printHelp
echo.
echo Usage install-all-tests.sh TE_BASE TEAM_ENGINE CSV_FILE DIR_TO_BUILD SKIP_TESTS
echo.
echo where:
echo.
echo TE_BASE is the TE_BASE directory
echo TEAM_ENGINE is the TEAM_ENGINE directory
echo CSV_FILE is a CSV file that provides per test a git url and revision number
echo DIR_TO_BUILD temporary directory to build tests
echo SKIP_TESTS true or false to skip tests while building mvn
echo.
echo More information: https://github.com/opengeospatial/teamengine-builder/
GOTO END
:END