Skip to content

Commit

Permalink
[ci] download utest.h from cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
lvntky committed Aug 8, 2024
1 parent dbd01d1 commit 3bd4735
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
if: always()
run: cmake -DFIX=YES -P cmake/spell.cmake

- name: Download utest.h
run: |
curl -o ./test/source/utest.h https://raw.githubusercontent.com/sheredom/utest.h/master/utest.h


coverage:
Expand Down
13 changes: 13 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ if(PROJECT_IS_TOP_LEVEL)
enable_testing()
endif()

# ---- Download utest.h ----

set(UTEST_HEADER_URL "https://raw.githubusercontent.com/sheredom/utest.h/master/utest.h")
set(UTEST_HEADER_PATH "${CMAKE_BINARY_DIR}/utest.h")

if(NOT EXISTS ${UTEST_HEADER_PATH})
message(STATUS "Downloading utest.h...")
file(DOWNLOAD ${UTEST_HEADER_URL} ${UTEST_HEADER_PATH})
endif()

# ---- Tests ----

# Create a list of test sources
Expand All @@ -25,6 +35,9 @@ add_executable(ccontainer_tests ${TEST_SOURCES})
# Ensure the implementation macro is defined
target_compile_definitions(ccontainer_tests PRIVATE CC_VECTOR_IMPLEMENTATION)

# Include the downloaded utest.h
target_include_directories(ccontainer_tests PRIVATE ${CMAKE_BINARY_DIR})

# Link against the ccontainer library
target_link_libraries(ccontainer_tests PRIVATE ccontainer::ccontainer)

Expand Down
2 changes: 1 addition & 1 deletion test/source/cc_vector_test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define CC_VECTOR_IMPLEMENTATIONs
#include "../../include/ccontainer/cc_vector.h"
#include "utest.h"
#include "../build/utest.h"

UTEST(cc_vector, create)
{
Expand Down
2 changes: 1 addition & 1 deletion test/source/main_test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "utest.h"
#include "../build/utest.h"

UTEST_MAIN()

0 comments on commit 3bd4735

Please sign in to comment.