Skip to content

ctest unit tests are run twice #288

@LecrisUT

Description

@LecrisUT

If I read this part correctly

xtl/test/CMakeLists.txt

Lines 120 to 135 in 174e99d

foreach(filename IN LISTS XTL_TESTS)
get_filename_component(targetname ${filename} NAME_WE)
add_executable(${targetname} main.cpp ${filename} ${XTL_HEADERS})
target_include_directories(${targetname} PRIVATE ${XTL_INCLUDE_DIR})
target_link_libraries(${targetname} xtl doctest::doctest Threads::Threads ${nlohmann_json_TARGET})
add_test(NAME ${targetname} COMMAND ${targetname})
endforeach()
add_executable(test_xtl main.cpp ${XTL_TESTS} ${XTL_HEADERS})
target_include_directories(test_xtl PRIVATE ${XTL_INCLUDE_DIR})
target_link_libraries(test_xtl xtl doctest::doctest Threads::Threads ${nlohmann_json_TARGET})
add_custom_target(xtest COMMAND test_xtl DEPENDS test_xtl)
add_test(NAME xtest COMMAND test_xtl)

The ctest would run eact test twice, once in xtest and once in ${targetname}. Why not get rid of the former?

Also the custom target calling test_xtl is not very efficient because it would not be parallelized. I've seen implementations where the target is just a thin wrapper around ctest with appropriate filters/environment variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions