1
1
cmake_minimum_required (VERSION 3.23 )
2
- project (cppfront-regression-tests LANGUAGES NONE )
2
+ project (cppfront-regression-tests LANGUAGES CXX )
3
3
4
4
option (CPPFRONT_DEVELOPING "Test results are updated." )
5
5
@@ -10,7 +10,31 @@ find_package(cppfront REQUIRED)
10
10
11
11
set (REGRESSION_TESTS_DIR "${CMAKE_CURRENT_LIST_DIR} /../cppfront/regression-tests" )
12
12
13
+ if (CPPFRONT_DEVELOPING )
14
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
15
+ set (compiler_id "gcc" )
16
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
17
+ set (compiler_id "apple-clang" )
18
+ else ()
19
+ string (TOLOWER "${CMAKE_CXX_COMPILER_ID} " compiler_id )
20
+ endif ()
21
+ string (REGEX MATCH "[0-9]+" compiler_major_version "${CMAKE_CXX_COMPILER_VERSION} " )
22
+
23
+ set (TEST_RESULTS_BUILD_DIR "${REGRESSION_TESTS_DIR} /test-results/${compiler_id} -${compiler_major_version} " )
24
+ file (MAKE_DIRECTORY "${TEST_RESULTS_BUILD_DIR} " )
25
+
26
+ set (compiler_version_command "${CMAKE_CXX_COMPILER} " "--version" )
27
+ if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang" )
28
+ set (compiler_id "clang" )
29
+ endif ()
30
+ execute_process (
31
+ COMMAND ${compiler_version_command}
32
+ OUTPUT_FILE "${TEST_RESULTS_BUILD_DIR} /${compiler_id} -version.output"
33
+ )
34
+ endif ()
35
+
13
36
configure_file ("cmake/ExecuteWithRedirection.cmake" "ExecuteWithRedirection.cmake" COPYONLY )
37
+ configure_file ("cmake/ExecuteTestCase.cmake.in" "ExecuteTestCase.cmake" @ONLY )
14
38
15
39
function (cppfront_command_tests )
16
40
cmake_parse_arguments (PARSE_ARGV 0 ARG "" "SOURCE;EXPECTED_FILE" "EXTRA_FLAGS" )
@@ -106,6 +130,7 @@ function(cppfront_build_tests)
106
130
107
131
configure_file ("${REGRESSION_TESTS_DIR} /${ARG_SOURCE} " "${test_dir} /${ARG_SOURCE} " COPYONLY )
108
132
configure_file ("cmake/CMakeLists.txt.in" "${test_dir} /CMakeLists.txt" @ONLY )
133
+ configure_file ("cmake/test-case-config.cmake.in" "${test_dir} /test-case-config.cmake.in" COPYONLY )
109
134
110
135
add_test (
111
136
NAME "build/${test_name} "
@@ -119,8 +144,48 @@ function(cppfront_build_tests)
119
144
"-Dcppfront_DIR=${cppfront_DIR} "
120
145
"-Dcppfront-exe_DIR=${cppfront-exe_DIR}"
121
146
"-DCPPFRONT_FLAGS=${ARG_EXTRA_FLAGS} "
147
+ # There's `CMAKE_CXX_LINKER_LAUNCHER`, too. So far, it's not needed.
148
+ "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_COMMAND} ;-D;OUTPUT_FILE=${gen_cpp_src} .output;-P;../../ExecuteWithRedirection.cmake;--"
149
+ )
150
+ set_tests_properties (
151
+ "build/${test_name} "
152
+ PROPERTIES
153
+ DEPENDS "${build_test_depends} ;codegen/check/${test_name} "
154
+ FIXTURES_SETUP "build/${test_name} "
122
155
)
123
- set_tests_properties ("build/${test_name} " PROPERTIES DEPENDS "${build_test_depends} ;codegen/check/${test_name} " )
156
+
157
+ if (CPPFRONT_DEVELOPING )
158
+ add_test (
159
+ NAME "build/execute/${test_name} "
160
+ COMMAND
161
+ "${CMAKE_COMMAND} "
162
+ -D "OUTPUT_FILE=${test_dir} /${gen_cpp_src} .execution"
163
+ -P "../ExecuteTestCase.cmake"
164
+ WORKING_DIRECTORY "${test_dir} "
165
+ )
166
+ set_tests_properties (
167
+ "build/execute/${test_name} "
168
+ PROPERTIES
169
+ FIXTURES_REQUIRED "build/${test_name} "
170
+ FIXTURES_SETUP "build/execute/${test_name} "
171
+ RESOURCE_LOCK "test.exe" )
172
+
173
+ add_test (
174
+ NAME "build/update/${test_name} "
175
+ COMMAND
176
+ "${CMAKE_COMMAND} "
177
+ -E copy_if_different
178
+ "build/${gen_cpp_src} .output"
179
+ "${gen_cpp_src} .execution"
180
+ "${TEST_RESULTS_BUILD_DIR} "
181
+ WORKING_DIRECTORY "${test_dir} "
182
+ )
183
+ set_tests_properties (
184
+ "build/update/${test_name} "
185
+ PROPERTIES
186
+ FIXTURES_CLEANUP "build/${test_name} ;build/execute/${test_name} "
187
+ )
188
+ endif ()
124
189
endfunction ()
125
190
126
191
function (cppfront_tests )
0 commit comments