Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ jobs:
image: epitechcontent/epitest-docker
steps:
- uses: actions/checkout@v4
- name: Check compilation
timeout-minutes: 2
- name: Build tests
timeout-minutes: 5
run: |
cmake -S . -B build
cmake -S . -B build -DBUILD_TESTS=ON
cmake --build build --parallel
ctest --test-dir build --output-on-failure
- name: Run tests
timeout-minutes: 3
run: ctest --test-dir build --output-on-failure
- name: Cleaning
run: rm -rf build
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ install(TARGETS kronknet-static kronknet-shared
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/kronknet
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

option(BUILD_TESTS "Build the unit tests (run them with ctest)" OFF)

if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
13 changes: 6 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.20)
project(kronknet_tests LANGUAGES C)
# NOTE: Included from the root CMakeLists.txt with -DBUILD_TESTS=ON

include(FetchContent)

Expand All @@ -11,11 +10,6 @@ FetchContent_Declare(

FetchContent_MakeAvailable(kronklab)

# NOTE: Build kronknet from this repository, not the installed one
if(NOT TARGET kronknet)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/kronknet)
endif()

file(GLOB_RECURSE SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/utils/*.c
${CMAKE_CURRENT_SOURCE_DIR}/network/*.c
Expand All @@ -26,3 +20,8 @@ add_executable(kronknet_tests ${SOURCES})
target_include_directories(kronknet_tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/)

target_link_libraries(kronknet_tests PRIVATE kronklab kronknet)

add_test(NAME kronknet_tests COMMAND kronknet_tests)

# NOTE: kronklab has no per-test timeout, so a stuck test must not hang CI
set_tests_properties(kronknet_tests PROPERTIES TIMEOUT 120)
Loading