From 514788410ebd23a68edbe97bc4dd25be4cec8ec6 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 2 Aug 2024 11:37:47 -0400 Subject: [PATCH 1/4] Add cpp2regex.h. Update cppfront & C++23 test lists. --- CMakeLists.txt | 1 + cppfront | 2 +- regression-tests/CMakeLists.txt | 89 ++-------------------- regression-tests/Cxx23Tests.cmake | 119 ++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+), 85 deletions(-) create mode 100644 regression-tests/Cxx23Tests.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d0a334a..b77eed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ target_sources( FILE_SET HEADERS BASE_DIRS cppfront/include FILES cppfront/include/cpp2util.h + cppfront/include/cpp2regex.h ) if (NOT CPPFRONT_NO_SYSTEM) diff --git a/cppfront b/cppfront index 2ea1950..3a2d11e 160000 --- a/cppfront +++ b/cppfront @@ -1 +1 @@ -Subproject commit 2ea1950989ec24b03b49a388a7b65be980d20bfe +Subproject commit 3a2d11edf818c2cd88d730d9d62f803336dfeaf6 diff --git a/regression-tests/CMakeLists.txt b/regression-tests/CMakeLists.txt index c49e2eb..6b7c088 100644 --- a/regression-tests/CMakeLists.txt +++ b/regression-tests/CMakeLists.txt @@ -11,6 +11,8 @@ find_package(cppfront REQUIRED) set(REGRESSION_TESTS_DIR "${CMAKE_CURRENT_LIST_DIR}/../cppfront/regression-tests") set(TEST_RESULTS_DIR "${REGRESSION_TESTS_DIR}/test-results") +include(./Cxx23Tests.cmake) + # Set `COMPILER_ITEM_NAME`. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(compiler_id "gcc") @@ -153,90 +155,9 @@ function(cppfront_build_tests) configure_file("cmake/CMakeLists.txt.in" "${test_dir}/CMakeLists.txt" @ONLY) configure_file("cmake/test-case-config.cmake.in" "${test_dir}/test-case-config.cmake.in" COPYONLY) - set( - cxx_23_tests - pure2-assert-expected-not-null - pure2-assert-optional-not-null - pure2-assert-shared-ptr-not-null - pure2-assert-unique-ptr-not-null - pure2-bounds-safety-span - pure2-break-continue - pure2-bugfix-for-assign-expression-list - pure2-bugfix-for-discard-precedence - pure2-bugfix-for-empty-index - pure2-bugfix-for-indexed-call - pure2-bugfix-for-max-munch - pure2-bugfix-for-memberwise-base-assignment - pure2-bugfix-for-name-lookup-and-value-decoration - pure2-bugfix-for-non-local-function-expression - pure2-bugfix-for-non-local-initialization - pure2-bugfix-for-optional-template-argument-list - pure2-bugfix-for-requires-clause-in-forward-declaration - pure2-bugfix-for-requires-clause-unbraced-function-initializer - pure2-bugfix-for-template-argument - pure2-bugfix-for-ufcs-arguments - pure2-bugfix-for-ufcs-name-lookup - pure2-bugfix-for-ufcs-noexcept - pure2-bugfix-for-ufcs-sfinae - pure2-bugfix-for-unbraced-function-expression - pure2-bugfix-for-variable-template - pure2-chained-comparisons - pure2-concept-definition - pure2-contracts - pure2-defaulted-comparisons-and-final-types - pure2-enum - pure2-for-loop-range-with-lambda - pure2-forward-return - pure2-function-multiple-forward-arguments - pure2-hello - pure2-initialization-safety-with-else-if - pure2-inspect-expression-in-generic-function-multiple-types - pure2-inspect-expression-with-as-in-generic-function - pure2-inspect-fallback-with-variant-any-optional - pure2-inspect-generic-void-empty-with-variant-any-optional - pure2-interpolation - pure2-intro-example-hello-2022 - pure2-intro-example-three-loops - pure2-is-with-free-functions-predicate - pure2-is-with-unnamed-predicates - pure2-is-with-variable-and-value - pure2-last-use - pure2-look-up-parameter-across-unnamed-function - pure2-main-args - pure2-more-wildcards - pure2-print - pure2-raw-string-literal-and-interpolation - pure2-repeated-call - pure2-requires-clauses - pure2-return-tuple-operator - pure2-statement-scope-parameters - pure2-stdio - pure2-stdio-with-raii - pure2-synthesize-rightshift-and-rightshifteq - pure2-template-parameter-lists - pure2-trailing-commas - pure2-type-and-namespace-aliases - pure2-type-safety-1 - pure2-type-safety-2-with-inspect-expression - pure2-types-basics - pure2-types-down-upcast - pure2-types-inheritance - pure2-types-order-independence-and-nesting - pure2-types-ordering-via-meta-functions - pure2-types-smf-and-that-1-provide-everything - pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign - pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign - pure2-types-smf-and-that-4-provide-cpassign-and-mvassign - pure2-types-smf-and-that-5-provide-nothing-but-general-case - pure2-types-that-parameters - pure2-types-value-types-via-meta-functions - pure2-ufcs-member-access-and-chaining - pure2-union - pure2-variadics - pure2-various-string-literals - ) - set(extra_flags) - if (test_name IN_LIST cxx_23_tests) + set(extra_flags "") + test_requires_cxx23(OUTPUT_VARIABLE cxx23 TEST_NAME "${test_name}") + if (cxx23) list(APPEND extra_flags "-DCMAKE_CXX_STANDARD=23") endif () diff --git a/regression-tests/Cxx23Tests.cmake b/regression-tests/Cxx23Tests.cmake new file mode 100644 index 0000000..5b33de9 --- /dev/null +++ b/regression-tests/Cxx23Tests.cmake @@ -0,0 +1,119 @@ +function(test_requires_cxx23) + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "OUTPUT_VARIABLE;TEST_NAME" "") + + _is_cxx23_test_list(cxx_23_tests) + + if (ARG_TEST_NAME IN_LIST cxx_23_tests) + set(${ARG_OUTPUT_VARIABLE} 1 PARENT_SCOPE) + else () + set(${ARG_OUTPUT_VARIABLE} 0 PARENT_SCOPE) + endif () +endfunction() + +macro(_is_cxx23_test_list OUTPUT_VARIABLE) + set(${OUTPUT_VARIABLE} + pure2-assert-expected-not-null + pure2-assert-optional-not-null + pure2-assert-shared-ptr-not-null + pure2-assert-unique-ptr-not-null + pure2-bounds-safety-span + pure2-break-continue + pure2-bugfix-for-assign-expression-list + pure2-bugfix-for-discard-precedence + pure2-bugfix-for-empty-index + pure2-bugfix-for-indexed-call + pure2-bugfix-for-max-munch + pure2-bugfix-for-memberwise-base-assignment + pure2-bugfix-for-name-lookup-and-value-decoration + pure2-bugfix-for-non-local-function-expression + pure2-bugfix-for-non-local-initialization + pure2-bugfix-for-optional-template-argument-list + pure2-bugfix-for-requires-clause-in-forward-declaration + pure2-bugfix-for-requires-clause-unbraced-function-initializer + pure2-bugfix-for-template-argument + pure2-bugfix-for-ufcs-arguments + pure2-bugfix-for-ufcs-name-lookup + pure2-bugfix-for-ufcs-noexcept + pure2-bugfix-for-ufcs-sfinae + pure2-bugfix-for-unbraced-function-expression + pure2-bugfix-for-variable-template + pure2-chained-comparisons + pure2-concept-definition + pure2-contracts + pure2-defaulted-comparisons-and-final-types + pure2-enum + pure2-for-loop-range-with-lambda + pure2-forward-return + pure2-function-multiple-forward-arguments + pure2-function-typeids + pure2-hello + pure2-initialization-safety-with-else-if + pure2-inspect-expression-in-generic-function-multiple-types + pure2-inspect-expression-with-as-in-generic-function + pure2-inspect-fallback-with-variant-any-optional + pure2-inspect-generic-void-empty-with-variant-any-optional + pure2-interpolation + pure2-intro-example-hello-2022 + pure2-intro-example-three-loops + pure2-is-with-free-functions-predicate + pure2-is-with-unnamed-predicates + pure2-is-with-variable-and-value + pure2-last-use + pure2-look-up-parameter-across-unnamed-function + pure2-main-args + pure2-more-wildcards + pure2-print + pure2-range-operators + pure2-raw-string-literal-and-interpolation + pure2-regex_01_char_matcher + pure2-regex_02_ranges + pure2-regex_03_wildcard + pure2-regex_04_start_end + pure2-regex_05_classes + pure2-regex_06_boundaries + pure2-regex_07_short_classes + pure2-regex_08_alternatives + pure2-regex_09_groups + pure2-regex_10_escapes + pure2-regex_11_group_references + pure2-regex_12_case_insensitive + pure2-regex_13_possessive_modifier + pure2-regex_14_multiline_modifier + pure2-regex_15_group_modifiers + pure2-regex_16_perl_syntax_modifier + pure2-regex_17_comments + pure2-regex_18_branch_reset + pure2-regex_19_lookahead + pure2-repeated-call + pure2-requires-clauses + pure2-return-tuple-operator + pure2-statement-scope-parameters + pure2-stdio + pure2-stdio-with-raii + pure2-synthesize-rightshift-and-rightshifteq + pure2-template-parameter-lists + pure2-trailing-comma-assert + pure2-trailing-commas + pure2-type-and-namespace-aliases + pure2-type-constraints + pure2-type-safety-1 + pure2-type-safety-2-with-inspect-expression + pure2-types-basics + pure2-types-down-upcast + pure2-types-inheritance + pure2-types-order-independence-and-nesting + pure2-types-ordering-via-meta-functions + pure2-types-smf-and-that-1-provide-everything + pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign + pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign + pure2-types-smf-and-that-4-provide-cpassign-and-mvassign + pure2-types-smf-and-that-5-provide-nothing-but-general-case + pure2-types-that-parameters + pure2-types-value-types-via-meta-functions + pure2-ufcs-member-access-and-chaining + pure2-union + pure2-unsafe + pure2-variadics + pure2-various-string-literals + ) +endmacro() From cea3cd2a9b27e2b6cf495791a5e8ebc4198cce3b Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 2 Aug 2024 11:52:30 -0400 Subject: [PATCH 2/4] Increase job timeout --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b30be13..86f5160 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: run: sudo apt-get install ninja-build libc++-18-dev libc++abi-18-dev - name: Run test script - timeout-minutes: 12 + timeout-minutes: 30 run: ./test-all.sh env: CC: ${{ matrix.CC }} @@ -44,7 +44,7 @@ jobs: submodules: true - name: Run test script - timeout-minutes: 12 + timeout-minutes: 30 run: ./test-all.ps1 test-macos: name: Test macOS @@ -61,5 +61,5 @@ jobs: run: brew install ninja llvm@18 - name: Run test script - timeout-minutes: 12 + timeout-minutes: 30 run: ./test-all.sh From 1868b2d340f217f5ab4d13fe2f24aed2a2d22f72 Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 2 Aug 2024 13:29:54 -0400 Subject: [PATCH 3/4] Detect cxx_std_23 from cppfront flags. --- cmake/CppfrontHelpers.cmake | 92 ++++++++++++++++------- regression-tests/CMakeLists.txt | 25 ++----- regression-tests/Cxx23Tests.cmake | 119 ------------------------------ 3 files changed, 75 insertions(+), 161 deletions(-) delete mode 100644 regression-tests/Cxx23Tests.cmake diff --git a/cmake/CppfrontHelpers.cmake b/cmake/CppfrontHelpers.cmake index c4aa870..e41701a 100644 --- a/cmake/CppfrontHelpers.cmake +++ b/cmake/CppfrontHelpers.cmake @@ -1,3 +1,11 @@ +set(CPPFRONT_FLAGS "" + CACHE STRING "Global flags to pass to cppfront when generating code") + +define_property( + TARGET PROPERTY CPPFRONT_FLAGS + BRIEF_DOCS "Target-specific flags to pass to cppfront when generating code" +) + function(_cppfront_unique_name base hash outvar) string(LENGTH "${hash}" len) foreach (i RANGE 0 "${len}") @@ -20,6 +28,8 @@ function(_cppfront_unique_name base hash outvar) endfunction() function(_cppfront_generate_source src out) + cmake_parse_arguments(PARSE_ARGV 2 ARG "" "TARGET" "") + file(REAL_PATH "${src}" src) string(SHA256 src_hash "${src}") @@ -34,17 +44,25 @@ function(_cppfront_generate_source src out) # assume no SHA256 collisions file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/_cppfront/") - if(src MATCHES [[.*\.h2]]) - set(ext ".h") - else() - set(ext ".cpp") - endif() + if (src MATCHES [[.*\.h2]]) + set(ext ".h") + else () + set(ext ".cpp") + endif () set(out_file "${CMAKE_BINARY_DIR}/_cppfront/${basename}${ext}") + if (ARG_TARGET) + set(target_flags "$") + set(target_flags "$") + else () + set(target_flags "") + endif () + add_custom_command( OUTPUT "${out_file}" - COMMAND cppfront::cppfront "${src}" -o "${out_file}" ${CPPFRONT_FLAGS} + COMMAND cppfront::cppfront "${src}" -o "${out_file}" ${CPPFRONT_FLAGS} ${target_flags} DEPENDS cppfront::cppfront "${src}" + COMMAND_EXPAND_LISTS VERBATIM ) @@ -52,13 +70,46 @@ function(_cppfront_generate_source src out) set("${out}" "${out_file}" PARENT_SCOPE) endfunction() -function(cppfront_generate_cpp srcs) - set(cpp2srcs "") - foreach (src IN LISTS ARGN) - _cppfront_generate_source("${src}" cpp2) - list(APPEND cpp2srcs "${cpp2}") +function(cppfront_target_sources) + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "TARGET" "SOURCES") + + if (NOT TARGET "${ARG_TARGET}") + message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION}: TARGET argument assigned non-existent target `${ARG_TARGET}`") + endif () + + if (NOT ARG_SOURCES) + return() + endif () + + # Determine flag visibility + get_target_property(type "${ARG_TARGET}" TYPE) + if (type STREQUAL "INTERFACE_LIBRARY") + set(visibility "INTERFACE") + else () + set(visibility "PRIVATE") + endif () + + # Check if flags imply we need C++23 + set(flags ${CPPFRONT_FLAGS} "$") + set(flags "$") + set(flags "$") # -p[ure-cpp2] implies -im[port-std] + set(flags "$") # -im[port-std] can be overridden by -in[clude-std] + set(flags "$") # normalize to short flag + set(flags "$,0,1>") # get the last flag or none + target_compile_features("${ARG_TARGET}" ${visibility} "$<$:cxx_std_23>") + + # Link to utility libraries + target_link_libraries("${ARG_TARGET}" ${visibility} cppfront::cpp2util) + + set(cpp1sources "") + foreach (src IN LISTS ARG_SOURCES) + _cppfront_generate_source("${src}" cpp2 TARGET ${ARG_TARGET}) + list(APPEND cpp1sources "${cpp2}") endforeach () - set("${srcs}" "${cpp2srcs}" PARENT_SCOPE) + + set_source_files_properties(${cpp1sources} PROPERTIES CXX_SCAN_FOR_MODULES ON) + + target_sources("${ARG_TARGET}" ${visibility} ${cpp1sources}) endfunction() function(cppfront_enable) @@ -68,19 +119,10 @@ function(cppfront_enable) get_property(sources TARGET "${tgt}" PROPERTY SOURCES) list(FILTER sources INCLUDE REGEX "\\.(cpp|h)2$") - if (sources) - get_target_property(type "${tgt}" TYPE) - if (type STREQUAL "INTERFACE_LIBRARY") - set(visibility "INTERFACE") - else () - set(visibility "PRIVATE") - endif () - - target_link_libraries("${tgt}" ${visibility} cppfront::cpp2util) - cppfront_generate_cpp(cpp1sources ${sources}) - target_sources("${tgt}" ${visibility} ${cpp1sources}) - set_source_files_properties(${cpp1sources} PROPERTIES CXX_SCAN_FOR_MODULES ON) - endif () + cppfront_target_sources( + TARGET "${tgt}" + SOURCES ${sources} + ) endforeach () endfunction() diff --git a/regression-tests/CMakeLists.txt b/regression-tests/CMakeLists.txt index 6b7c088..b43835b 100644 --- a/regression-tests/CMakeLists.txt +++ b/regression-tests/CMakeLists.txt @@ -11,8 +11,6 @@ find_package(cppfront REQUIRED) set(REGRESSION_TESTS_DIR "${CMAKE_CURRENT_LIST_DIR}/../cppfront/regression-tests") set(TEST_RESULTS_DIR "${REGRESSION_TESTS_DIR}/test-results") -include(./Cxx23Tests.cmake) - # Set `COMPILER_ITEM_NAME`. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(compiler_id "gcc") @@ -60,7 +58,7 @@ function(cppfront_add_check_test) endfunction() function(cppfront_command_tests) - cmake_parse_arguments(PARSE_ARGV 0 ARG "" "SOURCE;EXPECTED_FILE" "EXTRA_FLAGS") + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "SOURCE;EXPECTED_FILE" "CPPFRONT_FLAGS") configure_file("${REGRESSION_TESTS_DIR}/${ARG_SOURCE}" "${ARG_SOURCE}" COPYONLY) @@ -77,7 +75,7 @@ function(cppfront_command_tests) -D "OUTPUT_FILE=${ARG_SOURCE}.output" -P "ExecuteWithRedirection.cmake" -- - "${CPPFRONT_EXECUTABLE}" "${ARG_SOURCE}" ${ARG_EXTRA_FLAGS} + "${CPPFRONT_EXECUTABLE}" "${ARG_SOURCE}" ${ARG_CPPFRONT_FLAGS} ${COMMAND_ERROR_IS_FATAL} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) @@ -131,13 +129,13 @@ function(cppfront_command_tests) if (DEFINED build_test_depends AND DEFINED gen_cpp_src) cppfront_build_tests( SOURCE ${ARG_SOURCE} - EXTRA_FLAGS ${ARG_EXTRA_FLAGS} + CPPFRONT_FLAGS ${ARG_CPPFRONT_FLAGS} ) endif () endfunction() function(cppfront_build_tests) - cmake_parse_arguments(PARSE_ARGV 0 ARG "" "SOURCE" "EXTRA_FLAGS") + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "SOURCE" "CPPFRONT_FLAGS") cmake_path(GET ARG_SOURCE STEM test_name) @@ -155,12 +153,6 @@ function(cppfront_build_tests) configure_file("cmake/CMakeLists.txt.in" "${test_dir}/CMakeLists.txt" @ONLY) configure_file("cmake/test-case-config.cmake.in" "${test_dir}/test-case-config.cmake.in" COPYONLY) - set(extra_flags "") - test_requires_cxx23(OUTPUT_VARIABLE cxx23 TEST_NAME "${test_name}") - if (cxx23) - list(APPEND extra_flags "-DCMAKE_CXX_STANDARD=23") - endif () - add_test( NAME "build/${test_name}" COMMAND @@ -172,8 +164,7 @@ function(cppfront_build_tests) "-DCMAKE_BUILD_TYPE=Release" "-Dcppfront_DIR=${cppfront_DIR}" "-Dcppfront-exe_DIR=${cppfront-exe_DIR}" - "-DCPPFRONT_FLAGS=${ARG_EXTRA_FLAGS}" - ${extra_flags} + "-DCPPFRONT_FLAGS=${ARG_CPPFRONT_FLAGS}" # There's `CMAKE_CXX_LINKER_LAUNCHER`, too. So far, it's not needed. "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_COMMAND};-D;OUTPUT_FILE=${gen_cpp_src}.output;-P;../../ExecuteWithRedirection.cmake;--" ) @@ -244,7 +235,7 @@ function(cppfront_build_tests) endfunction() function(cppfront_tests) - cmake_parse_arguments(PARSE_ARGV 0 ARG "" "GROUP" "EXTRA_FLAGS") + cmake_parse_arguments(PARSE_ARGV 0 ARG "" "GROUP" "CPPFRONT_FLAGS") # Naughty, but needed for quick rebasing... :( file( @@ -265,10 +256,10 @@ function(cppfront_tests) cppfront_command_tests( SOURCE ${src} EXPECTED_FILE ${expected_file} - EXTRA_FLAGS ${ARG_EXTRA_FLAGS} + CPPFRONT_FLAGS ${ARG_CPPFRONT_FLAGS} ) endforeach () endfunction() cppfront_tests(GROUP mixed) -cppfront_tests(GROUP pure2 EXTRA_FLAGS -p) +cppfront_tests(GROUP pure2 CPPFRONT_FLAGS -p) diff --git a/regression-tests/Cxx23Tests.cmake b/regression-tests/Cxx23Tests.cmake deleted file mode 100644 index 5b33de9..0000000 --- a/regression-tests/Cxx23Tests.cmake +++ /dev/null @@ -1,119 +0,0 @@ -function(test_requires_cxx23) - cmake_parse_arguments(PARSE_ARGV 0 ARG "" "OUTPUT_VARIABLE;TEST_NAME" "") - - _is_cxx23_test_list(cxx_23_tests) - - if (ARG_TEST_NAME IN_LIST cxx_23_tests) - set(${ARG_OUTPUT_VARIABLE} 1 PARENT_SCOPE) - else () - set(${ARG_OUTPUT_VARIABLE} 0 PARENT_SCOPE) - endif () -endfunction() - -macro(_is_cxx23_test_list OUTPUT_VARIABLE) - set(${OUTPUT_VARIABLE} - pure2-assert-expected-not-null - pure2-assert-optional-not-null - pure2-assert-shared-ptr-not-null - pure2-assert-unique-ptr-not-null - pure2-bounds-safety-span - pure2-break-continue - pure2-bugfix-for-assign-expression-list - pure2-bugfix-for-discard-precedence - pure2-bugfix-for-empty-index - pure2-bugfix-for-indexed-call - pure2-bugfix-for-max-munch - pure2-bugfix-for-memberwise-base-assignment - pure2-bugfix-for-name-lookup-and-value-decoration - pure2-bugfix-for-non-local-function-expression - pure2-bugfix-for-non-local-initialization - pure2-bugfix-for-optional-template-argument-list - pure2-bugfix-for-requires-clause-in-forward-declaration - pure2-bugfix-for-requires-clause-unbraced-function-initializer - pure2-bugfix-for-template-argument - pure2-bugfix-for-ufcs-arguments - pure2-bugfix-for-ufcs-name-lookup - pure2-bugfix-for-ufcs-noexcept - pure2-bugfix-for-ufcs-sfinae - pure2-bugfix-for-unbraced-function-expression - pure2-bugfix-for-variable-template - pure2-chained-comparisons - pure2-concept-definition - pure2-contracts - pure2-defaulted-comparisons-and-final-types - pure2-enum - pure2-for-loop-range-with-lambda - pure2-forward-return - pure2-function-multiple-forward-arguments - pure2-function-typeids - pure2-hello - pure2-initialization-safety-with-else-if - pure2-inspect-expression-in-generic-function-multiple-types - pure2-inspect-expression-with-as-in-generic-function - pure2-inspect-fallback-with-variant-any-optional - pure2-inspect-generic-void-empty-with-variant-any-optional - pure2-interpolation - pure2-intro-example-hello-2022 - pure2-intro-example-three-loops - pure2-is-with-free-functions-predicate - pure2-is-with-unnamed-predicates - pure2-is-with-variable-and-value - pure2-last-use - pure2-look-up-parameter-across-unnamed-function - pure2-main-args - pure2-more-wildcards - pure2-print - pure2-range-operators - pure2-raw-string-literal-and-interpolation - pure2-regex_01_char_matcher - pure2-regex_02_ranges - pure2-regex_03_wildcard - pure2-regex_04_start_end - pure2-regex_05_classes - pure2-regex_06_boundaries - pure2-regex_07_short_classes - pure2-regex_08_alternatives - pure2-regex_09_groups - pure2-regex_10_escapes - pure2-regex_11_group_references - pure2-regex_12_case_insensitive - pure2-regex_13_possessive_modifier - pure2-regex_14_multiline_modifier - pure2-regex_15_group_modifiers - pure2-regex_16_perl_syntax_modifier - pure2-regex_17_comments - pure2-regex_18_branch_reset - pure2-regex_19_lookahead - pure2-repeated-call - pure2-requires-clauses - pure2-return-tuple-operator - pure2-statement-scope-parameters - pure2-stdio - pure2-stdio-with-raii - pure2-synthesize-rightshift-and-rightshifteq - pure2-template-parameter-lists - pure2-trailing-comma-assert - pure2-trailing-commas - pure2-type-and-namespace-aliases - pure2-type-constraints - pure2-type-safety-1 - pure2-type-safety-2-with-inspect-expression - pure2-types-basics - pure2-types-down-upcast - pure2-types-inheritance - pure2-types-order-independence-and-nesting - pure2-types-ordering-via-meta-functions - pure2-types-smf-and-that-1-provide-everything - pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign - pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign - pure2-types-smf-and-that-4-provide-cpassign-and-mvassign - pure2-types-smf-and-that-5-provide-nothing-but-general-case - pure2-types-that-parameters - pure2-types-value-types-via-meta-functions - pure2-ufcs-member-access-and-chaining - pure2-union - pure2-unsafe - pure2-variadics - pure2-various-string-literals - ) -endmacro() From 0f0468e32f51e4b3941e9137cdb1f0370ffcb40b Mon Sep 17 00:00:00 2001 From: Alex Reinking Date: Fri, 2 Aug 2024 14:05:51 -0400 Subject: [PATCH 4/4] Correct test-results directory detection --- regression-tests/CMakeLists.txt | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/regression-tests/CMakeLists.txt b/regression-tests/CMakeLists.txt index b43835b..bfb4eaa 100644 --- a/regression-tests/CMakeLists.txt +++ b/regression-tests/CMakeLists.txt @@ -16,10 +16,22 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(compiler_id "gcc") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") set(compiler_id "apple-clang") -else () +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19) + set(compiler_major_version 2022) + elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18) + set(compiler_major_version 2019) + endif () +endif () + +if (NOT compiler_id) string(TOLOWER "${CMAKE_CXX_COMPILER_ID}" compiler_id) endif () -string(REGEX MATCH "[0-9]+" compiler_major_version "${CMAKE_CXX_COMPILER_VERSION}") + +if (NOT compiler_major_version) + string(REGEX MATCH "[0-9]+" compiler_major_version "${CMAKE_CXX_COMPILER_VERSION}") +endif () + set(COMPILER_ITEM_NAME "${compiler_id}-${compiler_major_version}") # Setup `BUILD_RESULTS_DIR`. @@ -144,7 +156,7 @@ function(cppfront_build_tests) mixed-bugfix-for-ufcs-non-local ) if (test_name IN_LIST "skip_tests_${CMAKE_CXX_COMPILER_ID}") - return () + return() endif () set(test_dir "${CMAKE_CURRENT_BINARY_DIR}/${test_name}") @@ -183,7 +195,7 @@ function(cppfront_build_tests) OLD_FILE "${expected_output_file}" FIXTURES_REQUIRED "build/${test_name}" ) - endif() + endif () add_test( NAME "build/execute/${test_name}" @@ -208,13 +220,13 @@ function(cppfront_build_tests) OLD_FILE "${expected_execution_file}" FIXTURES_REQUIRED "build/execute/${test_name}" ) - endif() + endif () if (CPPFRONT_DEVELOPING) # Trigger regeneration to add the `check` tests for newly added results. if (NOT DEFINED expected_output_file OR NOT DEFINED expected_execution_file) file(GLOB unused CONFIGURE_DEPENDS "${BUILD_RESULTS_DIR}/${gen_cpp_src}.*") - endif() + endif () add_test( NAME "build/update/${test_name}"