blob: 6e064a703c40d8c539fb96be4fa1cfba03735e2a (
plain)
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
|
include(RunCMake)
# Isolate our ctest runs from external environment.
unset(ENV{CTEST_PARALLEL_LEVEL})
unset(ENV{CTEST_OUTPUT_ON_FAILURE})
if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
RunCMake_GENERATOR STREQUAL "Watcom WMake")
set(fs_delay 3)
else()
set(fs_delay 1.125)
endif()
function(run_GoogleTest DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTest -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTest-build
${CMAKE_COMMAND}
--build .
--config Debug
--target fake_gtest
)
run_cmake_command(GoogleTest-property-timeout-exe
${CMAKE_COMMAND}
--build .
--config Debug
--target property_timeout_test
)
run_cmake_command(GoogleTest-test1
${CMAKE_CTEST_COMMAND}
-C Debug
-L TEST1
--no-label-summary
)
run_cmake_command(GoogleTest-test2
${CMAKE_CTEST_COMMAND}
-C Debug
-L TEST2
--no-label-summary
)
run_cmake_command(GoogleTest-test3
${CMAKE_CTEST_COMMAND}
-C Debug
-L TEST3
--no-label-summary
)
run_cmake_command(GoogleTest-test4
${CMAKE_CTEST_COMMAND}
-C Debug
-L TEST4
--no-label-summary
)
run_cmake_command(GoogleTest-test-missing
${CMAKE_CTEST_COMMAND}
-C Debug
-R no_tests_defined
--no-label-summary
)
run_cmake_command(GoogleTest-property-timeout1
${CMAKE_CTEST_COMMAND}
-C Debug
-R property_timeout\\.case_no_discovery
--no-label-summary
)
run_cmake_command(GoogleTest-property-timeout2
${CMAKE_CTEST_COMMAND}
-C Debug
-R property_timeout\\.case_with_discovery
--no-label-summary
)
run_cmake_command(GoogleTest-build
${CMAKE_COMMAND}
--build .
--config Debug
--target skip_test
)
run_cmake_command(GoogleTest-skip-test
${CMAKE_CTEST_COMMAND}
-C Debug
-R skip_test
--no-label-summary
)
endfunction()
function(run_GoogleTestLauncher DISCOVERY_MODE)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "14.0")
return()
endif()
if(CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" AND CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "19.36")
return()
endif()
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTestLauncher-build)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
run_cmake_with_options(GoogleTestLauncher
-DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE}
)
set(RunCMake_TEST_NO_CLEAN 1)
# do not issue any warnings on stderr that would cause the build to fail
set(RunCMake_TEST_OUTPUT_MERGE 1)
run_cmake_command(GoogleTestLauncher-build
${CMAKE_COMMAND}
--build .
--config Debug
)
unset(RunCMake_TEST_OUTPUT_MERGE)
run_cmake_command(GoogleTestLauncher-test
${CMAKE_CTEST_COMMAND}
-C Debug
-V
--no-label-sumary
)
endfunction()
function(run_GoogleTestXML DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTestXML-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestXML -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTestXML-discovery
${CMAKE_COMMAND}
--build .
--config Debug
--target xml_output
)
run_cmake_command(GoogleTestXML-result
${CMAKE_CTEST_COMMAND}
-C Debug
-R GoogleTestXML
--no-label-summary
)
run_cmake_command(GoogleTestXML-special-result
${CMAKE_CTEST_COMMAND}
-C Debug
-R GoogleTestXMLSpecial
--no-label-summary
)
endfunction()
function(run_GoogleTest_discovery_timeout DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-timeout)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestDiscoveryTimeout -DDISCOVERY_MODE=${DISCOVERY_MODE})
set(RunCMake_TEST_OUTPUT_MERGE 1)
run_cmake_command(GoogleTest-discovery-${DISCOVERY_MODE}-timeout-build
${CMAKE_COMMAND}
--build .
--config Debug
--target discovery_timeout_test
)
set(RunCMake_TEST_OUTPUT_MERGE 0)
run_cmake_command(GoogleTest-discovery-${DISCOVERY_MODE}-timeout-test
${CMAKE_CTEST_COMMAND}
-C Debug
-R discovery_timeout_test
--no-label-sumary
)
endfunction()
function(run_GoogleTest_discovery_arg_change DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-arg-change)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestDiscoveryArgChange
-DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE}
-DTEST_FILTER=basic
)
run_cmake_command(GoogleTest-discovery-arg-change-build
${CMAKE_COMMAND}
--build .
--config Release
--target fake_gtest
)
run_cmake_command(GoogleTest-discovery-arg-change-basic
${CMAKE_CTEST_COMMAND}
-C Release
-N
)
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) # handle 1s resolution
run_cmake_with_options(GoogleTestDiscoveryArgChange
-DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE}
-DTEST_FILTER=typed
)
run_cmake_command(GoogleTest-discovery-arg-change-build
${CMAKE_COMMAND}
--build .
--config Release
--target fake_gtest
)
run_cmake_command(GoogleTest-discovery-arg-change-typed
${CMAKE_CTEST_COMMAND}
-C Release
-N
)
endfunction()
function(run_GoogleTest_discovery_multi_config)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-multi-config)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(GoogleTestDiscoveryMultiConfig)
run_cmake_command(GoogleTest-build-release
${CMAKE_COMMAND}
--build .
--config Release
--target configuration_gtest
)
run_cmake_command(GoogleTest-build-debug
${CMAKE_COMMAND}
--build .
--config Debug
--target configuration_gtest
)
run_cmake_command(GoogleTest-configuration-release
${CMAKE_CTEST_COMMAND}
-C Release
-L CONFIG
-N
)
run_cmake_command(GoogleTest-configuration-debug
${CMAKE_CTEST_COMMAND}
-C Debug
-L CONFIG
-N
)
endfunction()
function(run_GoogleTest_discovery_test_list DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-test-list-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestDiscoveryTestList -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTest-discovery-test-list-build
${CMAKE_COMMAND}
--build .
--config Debug
--target test_list_test
)
run_cmake_command(GoogleTest-discovery-test-list-test
${CMAKE_CTEST_COMMAND}
-C Debug
--no-label-summary
)
endfunction()
function(run_GoogleTest_discovery_flush_script DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-flush-script-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestDiscoveryFlushScript -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTest-discovery-flush-script-build
${CMAKE_COMMAND}
--build .
--config Debug
--target flush_script_test
)
run_cmake_command(GoogleTest-discovery-flush-script-test
${CMAKE_CTEST_COMMAND}
-C Debug
--no-label-summary
)
endfunction()
function(run_GoogleTest_discovery_test_list_scoped DISCOVERY_MODE)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-test-list-scoped-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake_with_options(GoogleTestDiscoveryTestListScoped -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
run_cmake_command(GoogleTest-discovery-test-list-scoped-build
${CMAKE_COMMAND}
--build .
--config Debug
--target test_list_scoped_test
)
run_cmake_command(GoogleTest-discovery-test-list-scoped-test
${CMAKE_CTEST_COMMAND}
-C Debug
--no-label-summary
)
endfunction()
foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
message("Testing ${DISCOVERY_MODE} discovery mode via CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE global override...")
run_GoogleTest(${DISCOVERY_MODE})
run_GoogleTestLauncher(${DISCOVERY_MODE})
run_GoogleTestXML(${DISCOVERY_MODE})
message("Testing ${DISCOVERY_MODE} discovery mode via DISCOVERY_MODE option...")
run_GoogleTest_discovery_timeout(${DISCOVERY_MODE})
if(# VS 9 does not rebuild if POST_BUILD command changes.
NOT "${DISCOVERY_MODE};${RunCMake_GENERATOR}" MATCHES "^POST_BUILD;Visual Studio 9")
run_GoogleTest_discovery_arg_change(${DISCOVERY_MODE})
endif()
run_GoogleTest_discovery_test_list(${DISCOVERY_MODE})
run_GoogleTest_discovery_test_list_scoped(${DISCOVERY_MODE})
run_GoogleTest_discovery_flush_script(${DISCOVERY_MODE})
endforeach()
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
message("Testing PRE_TEST discovery multi configuration...")
run_GoogleTest_discovery_multi_config()
endif()
|