Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit e4c7ad62 authored by gama's avatar gama
Browse files

Add test with Doctest

parent 3b7ba99b
No related branches found
No related tags found
No related merge requests found
Pipeline #50129 passed
......@@ -11,6 +11,12 @@ lint:linux:
image: xianpengshen/clang-tools:18
before_script:
- apt update && apt -y install clang git ninja-build cmake
cache:
- key: cpm_cache
paths:
- cpm_cache/
variables:
CPM_SOURCE_CACHE: "cpm_cache"
script:
- cmake --preset x64-linux-debug
- cmake --build --preset x64-linux-debug --target sandbox_lib_analysis | tee analysis.log
......@@ -28,6 +34,12 @@ build:linux:
# - linux
before_script:
- apt update && apt -y install make autoconf ninja-build cmake
cache:
- key: cpm_cache
paths:
- cpm_cache/
variables:
CPM_SOURCE_CACHE: "cpm_cache"
script:
- cmake --preset x64-linux-ci
- cmake --build --preset x64-linux-ci --target install
......
......@@ -4,10 +4,26 @@
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/build/sandbox/implementation/standalone/sandbox",
"name": "cmd",
"program": "${workspaceFolder}/out/build/x64-linux-asan/cmd/sandbox_cmd",
"args": [],
"cwd": "${workspaceFolder}"
"cwd": "${workspaceFolder}",
"env": {
// LSAN not supported with debugger
"ASAN_OPTIONS" : "detect_leaks=0"
}
},
{
"type": "lldb",
"request": "launch",
"name": "test",
"program": "${workspaceFolder}/out/build/x64-linux-asan/test/sandbox_test",
"args": [],
"cwd": "${workspaceFolder}",
"env": {
// LSAN not supported with debugger
"ASAN_OPTIONS" : "detect_leaks=0"
}
}
]
}
......@@ -18,5 +18,9 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
include(cmake/static_analysis.cmake)
include(GNUInstallDirs)
include(cmake/dependencies.cmake)
setup_dependencies()
add_subdirectory(cmd)
add_subdirectory(lib)
add_subdirectory(test)
......@@ -8,7 +8,8 @@
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CPM_SOURCE_CACHE": "${sourceDir}/out/build/${presetName}/cpm_cache"
}
},
{
......
# Courtesy of https://github.com/TheLartians/ModernCppStarter/blob/master/cmake/CPM.cmake
set(CPM_DOWNLOAD_VERSION 0.40.2)
if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
function(download_cpm)
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endfunction()
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
download_cpm()
else()
# resume download if it previously failed
file(READ ${CPM_DOWNLOAD_LOCATION} check)
if("${check}" STREQUAL "")
download_cpm()
endif()
unset(check)
endif()
include(${CPM_DOWNLOAD_LOCATION})
# CPMLicenses
CPMAddPackage(
NAME CPMLicenses.cmake
GITHUB_REPOSITORY cpm-cmake/CPMLicenses.cmake
VERSION 0.0.7
)
include(cmake/cpm.cmake)
# Done as a function so that updates to variables like CMAKE_CXX_FLAGS don't
# propagate out to other targets
function(setup_dependencies)
# doctest
cpmaddpackage(GITHUB_REPOSITORY doctest/doctest GIT_TAG v2.4.11)
endfunction()
# CPM licenses target here
cpm_licenses_create_disclaimer_target(
write-licenses "${CMAKE_BINARY_SOURCE_DIR}/third_party.txt" "${CPM_PACKAGES}")
add_executable(sandbox_test)
set_target_properties(sandbox_test PROPERTIES CXX_STANDARD 11)
target_sources(sandbox_test PRIVATE "test.cpp")
target_link_libraries(sandbox_test PRIVATE doctest sandbox_lib)
install(
TARGETS sandbox_test
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
/// This file is part of SandBox
///
/// SandBox is free software: you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation, either version 3 of the License, or
/// (at your option) any later version.
///
/// SandBox is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with SandBox. If not, see <http://www.gnu.org/licenses/>.
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include <doctest/doctest.h>
#include "sandbox/dummygroup/dummygroup.h"
TEST_CASE("dummy test")
{
auto test = sandbox::dummygroup::DummyGroup::Make();
const char* kText(test->GetSomething());
CHECK(kText != nullptr);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment