Skip to content

Commit

Permalink
Fixed some issues on doctest
Browse files Browse the repository at this point in the history
Signed-off-by: Vinícius Ferrão <[email protected]>
  • Loading branch information
viniciusferrao committed Jul 11, 2023
1 parent c04f446 commit 0a50080
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 82 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,3 @@ set(CPACK_PACKAGE_FILE_NAME
)

include(CPack)

2 changes: 1 addition & 1 deletion Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(cloysterhpc_setup_dependencies)
# For each dependency, see if it's
# already been provided to us by a parent project

if(NOT TARGET boost::boost)
if(NOT (TARGET Boost::headers OR TARGET Boost::system OR TARGET Boost::thread))
if (cloysterhpc_ENABLE_CONAN)
CPMFindPackage(NAME Boost)
else()
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ target_link_system_libraries(
gsl::gsl-lite
magic_enum::magic_enum
resolv
${STDC++FS})
${STDC++FS}
doctest::doctest)

target_include_directories(main PRIVATE "${CMAKE_BINARY_DIR}/configured_files/include")
target_include_directories(main ${WARNING_GUARD} PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>)
Expand Down
2 changes: 1 addition & 1 deletion src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,4 @@ void Connection::dumpConnection() const

LOG_DEBUG("===================================")
}
#endif
#endif
82 changes: 8 additions & 74 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION)
endif()
endif()

# ---- Dependencies ----

# Provide a simple smoke test to make sure that the CLI works and can display a --help message
add_test(NAME cli.has_help COMMAND main --help)

Expand All @@ -40,7 +38,13 @@ target_link_libraries(
spdlog::spdlog
magic_enum::magic_enum
gsl::gsl-lite
boost::boost)
Boost::headers
Boost::system
Boost::thread)

target_include_directories(${PROJECT_NAME} ${WARNING_GUARD} PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/../include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/../include>)

set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})

Expand All @@ -52,17 +56,7 @@ if(WIN32 AND BUILD_SHARED_LIBS)
COMMAND_EXPAND_LISTS)
endif()

## enable compiler warnings
#if(NOT TEST_INSTALLED_VERSION)
# if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wpedantic -Wextra -Werror)
# elseif(MSVC)
# target_compile_options(${PROJECT_NAME} PUBLIC /W4 /WX)
# target_compile_definitions(${PROJECT_NAME} PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS)
# endif()
#endif()

# ---- Add CloysterHPCTests ----
# ---- Add Tests ----

# Note: doctest and similar testing frameworks can automatically configure CMake tests. For other
# testing frameworks add the tests target instead: add_test(NAME ${PROJECT_NAME} COMMAND
Expand All @@ -87,63 +81,3 @@ if(ENABLE_TEST_COVERAGE)
target_compile_options(${PROJECT_NAME} PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
target_link_options(${PROJECT_NAME} PUBLIC -fprofile-arcs -ftest-coverage)
endif()

# automatically discover tests that are defined in catch based test files you can modify the unittests. Set TEST_PREFIX
# to whatever you want, or use different for different binaries
#catch_discover_tests(
# tests
# TEST_PREFIX
# "unittests."
# REPORTER
# XML
# OUTPUT_DIR
# ../test-catch
# OUTPUT_PREFIX
# "unittests."
# OUTPUT_SUFFIX
# .xml)

# Add a file containing a set of constexpr tests
#add_executable(constexpr_tests ../test-catch/constexpr_tests.cpp)
#target_link_libraries(
# constexpr_tests
# PRIVATE cloysterhpc::cloysterhpc_warnings
# cloysterhpc::cloysterhpc_options
# doctest::doctest)
#
#catch_discover_tests(
# constexpr_tests
# TEST_PREFIX
# "constexpr."
# REPORTER
# XML
# OUTPUT_DIR
# ../test-catch
# OUTPUT_PREFIX
# "constexpr."
# OUTPUT_SUFFIX
# .xml)

# Disable the constexpr portion of the test, and build again this allows us to have an executable that we can debug when
# things go wrong with the constexpr testing
#add_executable(relaxed_constexpr_tests ../test-catch/constexpr_tests.cpp)
#target_link_libraries(
# relaxed_constexpr_tests
# PRIVATE cloysterhpc::cloysterhpc_warnings
# cloysterhpc::cloysterhpc_options
# doctest::doctest)
#
#target_compile_definitions(relaxed_constexpr_tests PRIVATE -DCATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
#
#catch_discover_tests(
# relaxed_constexpr_tests
# TEST_PREFIX
# "relaxed_constexpr."
# REPORTER
# XML
# OUTPUT_DIR
# ../test-catch
# OUTPUT_PREFIX
# "relaxed_constexpr."
# OUTPUT_SUFFIX
# .xml)
9 changes: 5 additions & 4 deletions test/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "../src/network.h"
#include "../src/connection.cpp"
#include "../src/connection.h"
#include "../src/network.cpp"
#include <cloysterhpc/network.h>
#include <cloysterhpc/connection.h>
#include "../src/network.cpp" // This is lame
#include "../src/connection.cpp" // This is also lame
#include <boost/asio.hpp>

#include <doctest/doctest.h>

TEST_SUITE("Network setters and getters")
Expand Down

0 comments on commit 0a50080

Please sign in to comment.