Skip to content

Commit

Permalink
test: add test for CPM package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
rjaegers committed Oct 20, 2024
1 parent 9d1f52b commit 6634aa3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ add_subdirectory(clang-tools)
add_subdirectory(fuzzing)
add_subdirectory(gcc)
add_subdirectory(gcc-arm-none-eabi)
add_subdirectory(package-managers)
add_subdirectory(sanitizers)
add_subdirectory(test)
12 changes: 12 additions & 0 deletions .devcontainer/cpp/test/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"ENABLE_COVERAGE_TEST": "On"
}
},
{
"name": "cpm",
"inherits": "defaults",
"cacheVariables": {
"ENABLE_CPM_TEST": "On"
}
},
{
"name": "gcc",
"inherits": "defaults"
Expand Down Expand Up @@ -81,6 +88,11 @@
"configurePreset": "coverage",
"targets": ["test-coverage"]
},
{
"name": "cpm",
"configurePreset": "cpm",
"targets": ["cpm-test"]
},
{
"name": "fuzzing",
"configurePreset": "clang",
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/cpp/test/package-managers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(cpm)
8 changes: 8 additions & 0 deletions .devcontainer/cpp/test/package-managers/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
if (ENABLE_CPM_TEST)
include(CPM)

CPMAddPackage("gh:fmtlib/fmt#11.0.2")

add_executable(cpm-test EXCLUDE_FROM_ALL main.cpp)
target_link_libraries(cpm-test PRIVATE fmt::fmt)
endif()
7 changes: 7 additions & 0 deletions .devcontainer/cpp/test/package-managers/cpm/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <fmt/core.h>

int main()
{
fmt::print("Hello, world!\n");
return 0;
}
5 changes: 5 additions & 0 deletions .devcontainer/cpp/test/testsuite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ teardown() {
build_and_run_with_sanitizers clang
}

@test "using CPM as package manager should resolve external dependencies" {
cmake --preset cpm
cmake --build --preset cpm
}

function configure_and_build_with_ccache() {
local PRESET=${1:?}

Expand Down

0 comments on commit 6634aa3

Please sign in to comment.