blob: efd22bea9e81d997acbfacbc90d2c2c8743f4e39 (
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
|
include(RunCMake)
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-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_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
)
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_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()
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_GoogleTestXML(${DISCOVERY_MODE})
message("Testing ${DISCOVERY_MODE} discovery mode via DISCOVERY_MODE option...")
run_GoogleTest_discovery_timeout(${DISCOVERY_MODE})
endforeach()
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
message("Testing PRE_TEST discovery multi configuration...")
run_GoogleTest_discovery_multi_config()
endif()
|