@@ -11,20 +11,21 @@ find_package(cppfront REQUIRED)
11
11
set (REGRESSION_TESTS_DIR "${CMAKE_CURRENT_LIST_DIR} /../cppfront/regression-tests" )
12
12
set (TEST_RESULTS_DIR "${REGRESSION_TESTS_DIR} /test-results" )
13
13
14
- if (CPPFRONT_DEVELOPING)
15
- # Set `compiler_id` and `compiler_major_version`.
16
- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU " )
17
- set (compiler_id "gcc " )
18
- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang " )
19
- set (compiler_id "apple-clang" )
20
- else ( )
21
- string (TOLOWER " ${CMAKE_CXX_COMPILER_ID} " compiler_id )
22
- endif ( )
23
- string ( REGEX MATCH "[0-9]+" compiler_major_version " ${CMAKE_CXX_COMPILER_VERSION } " )
14
+ # Set `COMPILER_ITEM_NAME`.
15
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
16
+ set (compiler_id "gcc " )
17
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang " )
18
+ set (compiler_id "apple-clang " )
19
+ else ( )
20
+ string (TOLOWER " ${CMAKE_CXX_COMPILER_ID} " compiler_id )
21
+ endif ( )
22
+ string ( REGEX MATCH "[0-9]+" compiler_major_version " ${CMAKE_CXX_COMPILER_VERSION} " )
23
+ set (COMPILER_ITEM_NAME " ${compiler_id} - ${compiler_major_version } " )
24
24
25
- # Setup `BUILD_RESULTS_DIR`.
26
- set (compiler_item_name "${compiler_id} -${compiler_major_version} " )
27
- set (BUILD_RESULTS_DIR "${TEST_RESULTS_DIR} /${compiler_item_name} " )
25
+ # Setup `BUILD_RESULTS_DIR`.
26
+ set (BUILD_RESULTS_DIR "${TEST_RESULTS_DIR} /${COMPILER_ITEM_NAME} " )
27
+
28
+ if (CPPFRONT_DEVELOPING)
28
29
file (MAKE_DIRECTORY "${BUILD_RESULTS_DIR} " )
29
30
30
31
# Write compiler version output.
@@ -36,23 +37,26 @@ if (CPPFRONT_DEVELOPING)
36
37
COMMAND ${compiler_version_command}
37
38
OUTPUT_FILE "${BUILD_RESULTS_DIR} /${compiler_id} -version.output"
38
39
)
39
-
40
- # Set `OLD_BUILD_RESULTS_DIRS`.
41
- file (
42
- GLOB build_result_dirs
43
- RELATIVE "${TEST_RESULTS_DIR} "
44
- "${TEST_RESULTS_DIR} /${compiler_id} -*"
45
- )
46
- list (SORT build_result_dirs)
47
- list (FIND build_result_dirs "${compiler_item_name} " i)
48
- list (SUBLIST build_result_dirs 0 ${i} OLD_BUILD_RESULTS_DIRS)
49
- list (REVERSE OLD_BUILD_RESULTS_DIRS)
50
40
endif ()
51
41
52
42
configure_file ("cmake/ExecuteWithRedirection.cmake" "ExecuteWithRedirection.cmake" COPYONLY )
53
43
configure_file ("cmake/ExecuteTestCase.cmake.in" "ExecuteTestCase.cmake" @ONLY)
44
+ configure_file ("cmake/FindBuildResultFile.cmake.in" "FindBuildResultFile.cmake" @ONLY)
54
45
configure_file ("cmake/UpdateBuildOutput.cmake.in" "UpdateBuildOutput.cmake" @ONLY)
55
46
47
+ include ("${CMAKE_CURRENT_BINARY_DIR} /FindBuildResultFile.cmake" )
48
+
49
+ function (cppfront_add_check_test)
50
+ cmake_parse_arguments (PARSE_ARGV 0 ARG "" "NAME;NEW_FILE;OLD_FILE;FIXTURES_REQUIRED" "" )
51
+
52
+ add_test (
53
+ NAME "${ARG_NAME} "
54
+ COMMAND "${CMAKE_COMMAND} " -E compare_files "${ARG_NEW_FILE} " "${ARG_OLD_FILE} "
55
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
56
+ )
57
+ set_tests_properties ("${ARG_NAME} " PROPERTIES FIXTURES_REQUIRED "${ARG_FIXTURES_REQUIRED} " )
58
+ endfunction ()
59
+
56
60
function (cppfront_command_tests)
57
61
cmake_parse_arguments (PARSE_ARGV 0 ARG "" "SOURCE;EXPECTED_FILE" "EXTRA_FLAGS" )
58
62
@@ -113,14 +117,13 @@ function(cppfront_command_tests)
113
117
114
118
if (ARG_EXPECTED_FILE)
115
119
configure_file ("${ARG_EXPECTED_FILE} " "${gen_cpp_src} .original" COPYONLY )
116
- add_test (
120
+ cppfront_add_check_test (
117
121
NAME "codegen/check/${test_name} "
118
- COMMAND "${CMAKE_COMMAND} " -E compare_files "${gen_cpp_src} " "${gen_cpp_src} .original"
119
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} "
122
+ NEW_FILE "${gen_cpp_src} "
123
+ OLD_FILE "${gen_cpp_src} .original"
124
+ FIXTURES_REQUIRED "codegen/${test_name} "
120
125
)
121
126
122
- set_tests_properties ("codegen/check/${test_name} " PROPERTIES FIXTURES_REQUIRED "codegen/${test_name} " )
123
-
124
127
cppfront_build_tests(
125
128
SOURCE ${ARG_SOURCE}
126
129
EXTRA_FLAGS ${ARG_EXTRA_FLAGS}
@@ -161,6 +164,16 @@ function(cppfront_build_tests)
161
164
FIXTURES_SETUP "build/${test_name} "
162
165
)
163
166
167
+ cppfront_find_build_result_file(expected_output_file RESULT_FILE "${gen_cpp_src} .output" )
168
+ if (expected_output_file)
169
+ cppfront_add_check_test(
170
+ NAME "build/check/${test_name} "
171
+ NEW_FILE "${test_dir} /build/${gen_cpp_src} .output"
172
+ OLD_FILE "${expected_output_file} "
173
+ FIXTURES_REQUIRED "build/${test_name} "
174
+ )
175
+ endif ()
176
+
164
177
add_test (
165
178
NAME "build/execute/${test_name} "
166
179
COMMAND
@@ -176,6 +189,16 @@ function(cppfront_build_tests)
176
189
FIXTURES_SETUP "build/execute/${test_name} "
177
190
RESOURCE_LOCK "test.exe" )
178
191
192
+ cppfront_find_build_result_file(expected_execution_file RESULT_FILE "${gen_cpp_src} .execution" )
193
+ if (expected_execution_file)
194
+ cppfront_add_check_test(
195
+ NAME "build/execute/check/${test_name} "
196
+ NEW_FILE "${test_dir} /${gen_cpp_src} .execution"
197
+ OLD_FILE "${expected_execution_file} "
198
+ FIXTURES_REQUIRED "build/execute/${test_name} "
199
+ )
200
+ endif ()
201
+
179
202
if (CPPFRONT_DEVELOPING)
180
203
add_test (
181
204
NAME "build/update/${test_name} "
0 commit comments