Skip to content

Commit 0960442

Browse files
committed
MAINT: Generate unique target names for tests
1 parent dfb1ead commit 0960442

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,25 @@ find_package(Parquet REQUIRED)
1111
add_library(xsf INTERFACE)
1212
target_include_directories(xsf INTERFACE ${CMAKE_SOURCE_DIR}/include)
1313

14+
set(TEST_BASE_DIR "${CMAKE_SOURCE_DIR}/tests")
15+
1416
file(GLOB TEST_SOURCES "*/test_*.cpp")
1517
foreach(test_file ${TEST_SOURCES})
18+
# Families of tests go in subfolders of xsf/tests. Test files in different
19+
# folders can have the same name. Try to generate a unique target name based
20+
# on the test name and its parent folder(s).
1621
get_filename_component(test_name ${test_file} NAME_WE)
17-
add_executable(${test_name}.test ${test_file})
18-
target_link_libraries(${test_name}.test PRIVATE Catch2::Catch2WithMain Arrow::arrow_shared Parquet::parquet_shared xsf)
19-
target_compile_definitions(${test_name}.test PRIVATE XSREF_TABLES_PATH="${XSREF_TABLES_PATH}")
22+
get_filename_component(test_dir ${test_file} DIRECTORY)
23+
file(RELATIVE_PATH test_dir ${TEST_BASE_DIR} ${test_dir})
24+
string(REPLACE "/" "-" test_dir ${test_dir})
25+
set(target_name ${test_dir}_${test_name})
26+
27+
add_executable(${target_name} ${test_file})
28+
29+
target_link_libraries(${target_name} PRIVATE Catch2::Catch2WithMain Arrow::arrow_shared Parquet::parquet_shared xsf)
30+
31+
target_compile_definitions(${target_name} PRIVATE XSREF_TABLES_PATH="${XSREF_TABLES_PATH}")
2032
include(CTest)
2133
include(Catch)
22-
catch_discover_tests(${test_name}.test)
34+
catch_discover_tests(${target_name})
2335
endforeach()

0 commit comments

Comments
 (0)