Skip to content

Commit

Permalink
CMake: enable testing
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed Jan 13, 2024
1 parent a643b5c commit 60de85a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ jobs:
cd bld\
cmake ..\cmake -DCMAKE_BUILD_TYPE=Release -DWITH_STATIC=ON
cmake --build . --target all_build --config Release
- name: Run tests
run: |
cd bld\
ctest -V
15 changes: 15 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,24 @@ if (WITH_TESTS)
add_executable(${TESTTCP} ${TESTTCP_SOURCES})
target_link_libraries(${TESTLO} PRIVATE Threads::Threads)
target_link_libraries(${TESTTCP} PRIVATE Threads::Threads)
if (WIN32)
# If you use the new syntax, on Windows, you need to run `cmake -C Release` instead of `cmake`.
# We do not want that, so we use the old syntax for Windows...
add_test(${TESTLO} "tests/${TESTLO}")
add_test("test-bidirectional-tcp" "tests/${TESTTCP}")
else()
add_test(NAME ${TESTLO} COMMAND ${TESTLO} WORKING_DIRECTORY $<TARGET_FILE_DIR:${TESTLO}>)
add_test(NAME "test-bidirectional-tcp" COMMAND ${TESTTCP} WORKING_DIRECTORY $<TARGET_FILE_DIR:${TESTTCP}>)
endif()
enable_testing()
endif()
if (WITH_CPP_TESTS)
add_executable(${CPPTEST} ${CPPTEST_SOURCES})
if (WIN32)
add_test(${CPPTEST} "tests/${CPPTEST}")
else()
add_test(NAME ${CPPTEST} COMMAND ${CPPTEST} WORKING_DIRECTORY $<TARGET_FILE_DIR:${CPPTEST}>)
endif()
endif()

# Examples
Expand Down

0 comments on commit 60de85a

Please sign in to comment.