Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CTest discovery broken for Windows #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fuchse-ego opened this issue Apr 28, 2025 · 2 comments · Fixed by #1850
Closed

CTest discovery broken for Windows #1849

fuchse-ego opened this issue Apr 28, 2025 · 2 comments · Fixed by #1850

Comments

@fuchse-ego
Copy link

Hey,

CTest discovery for windows is broken as the backslashes are not escaped. On the current master and Windows you get:

[build] CMake Error at C:/development/.../UnitTest/build/_deps/cpputest-src/cmake/Modules/_CppUTestDiscovery.cmake:34 (add_command):
[build]   Syntax error in cmake code at
[build] 
[build]     C:/development/.../UnitTest/build/_deps/cpputest-src/cmake/Modules/_CppUTestDiscovery.cmake:39
[build] 
[build]   when parsing string
[build] 
[build]     C:\development\...\UnitTest\Test\test_UnitUnderTest.cpp:55
[build] 
[build]   Invalid character escape '\d'.
[build] Call Stack (most recent call first):
[build]   C:/development/.../UnitTest/build/_deps/cpputest-src/cmake/Modules/_CppUTestDiscovery.cmake:93 (add_test_to_script)
[build] 

Tested on
Win11
cmake/4.0.1
mingw-builds/14.2.0

Suggested fix, let CMake handle path quirks:

diff --git a/cmake/Modules/_CppUTestDiscovery.cmake b/cmake/Modules/_CppUTestDiscovery.cmake
index 2b36a73e..a7faae98 100644
--- a/cmake/Modules/_CppUTestDiscovery.cmake
+++ b/cmake/Modules/_CppUTestDiscovery.cmake
@@ -68,14 +68,14 @@ if(TESTS_DETAILED)
     foreach(line IN LISTS discovered_test_lines)
         string(REGEX MATCH "${LL_LINE_REGEX}" __unused "${line}")
         set(test_name "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
-        set(test_location "${CMAKE_MATCH_3}:${CMAKE_MATCH_4}")
+        cmake_path(SET test_location "${CMAKE_MATCH_3}:${CMAKE_MATCH_4}")
         add_test_to_script("${test_name}" "${test_location}" -st)
     endforeach()
 else()
     foreach(line IN LISTS discovered_test_lines)
         string(REGEX MATCH "${LL_LINE_REGEX}" __unused "${line}")
         set(test_name "${CMAKE_MATCH_1}")
-        set(test_file "${CMAKE_MATCH_3}")
+        cmake_path(SET test_file "${CMAKE_MATCH_3}")
         set(test_line "${CMAKE_MATCH_4}")
         if (NOT _${test_name}_file)
             # if the group spans two files, arbitrarily choose the first one encountered
@thetic
Copy link
Contributor

thetic commented Apr 28, 2025

cmake_path requires cmake 3.20+ which is a significant jump from our current minimum of 3.8. I'll have to think about this.

@thetic
Copy link
Contributor

thetic commented Apr 28, 2025

I'm also concerned that this isn't failing the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants