Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: Use Catch2 instead of doctest #3618

Merged
merged 25 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 23 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
2 changes: 1 addition & 1 deletion dev/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies:
- yaml-cpp >=0.8.0
- sel(win): winreg
# libmamba test dependencies
- doctest
- catch2
# micromamba dependencies
- cli11 >=2.2
# micromamba test dependencies
Expand Down
2 changes: 1 addition & 1 deletion dev/environment-micromamba-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ dependencies:
- libnghttp2-static
- lz4-c-static
# libmamba test dependencies
- doctest
- catch2
# micromamba dependencies
- cli11 >=2.2,<3
10 changes: 6 additions & 4 deletions libmamba/ext/solv-cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmake_minimum_required(VERSION 3.16)
add_executable(
test_solv_cpp
src/main.cpp
src/msvc_catch_string_view.cpp
src/pool_data.cpp
src/test_pool.cpp
src/test_queue.cpp
Expand All @@ -19,7 +20,8 @@ add_executable(
src/test_transaction.cpp
)
target_include_directories(test_solv_cpp PRIVATE src/)
target_compile_definitions(test_solv_cpp PRIVATE DOCTEST_CONFIG_USE_STD_HEADERS)

find_package(doctest REQUIRED)
target_link_libraries(test_solv_cpp PRIVATE doctest::doctest solv::cpp)
find_package(Catch2 REQUIRED)
target_link_libraries(test_solv_cpp PRIVATE Catch2::Catch2WithMain solv::cpp)
set_target_properties(
test_solv_cpp PROPERTIES COMPILE_DEFINITIONS CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to enable nice output for many std types without having to write implementations ourselves (this is from Catch's source code):

#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
#  define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
#  define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
#  define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
#  define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
#endif

)
4 changes: 2 additions & 2 deletions libmamba/ext/solv-cpp/tests/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#define CATCH_CONFIG_MAIN

#include <doctest/doctest.h>
#include <catch2/catch_all.hpp>
22 changes: 22 additions & 0 deletions libmamba/ext/solv-cpp/tests/src/msvc_catch_string_view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifdef _WIN32

// Catch compiled on `conda-forge` for MSVC doesn't support outputting `string_view`.
// So we have to define StringMaker for it ourselves.
// The declaration is present though, so this only causes link errors.

#include <string>
#include <string_view>

#include <catch2/catch_tostring.hpp>

namespace Catch
{

std::string StringMaker<std::string_view>::convert(std::string_view str)
{
return std::string(str);
}

}

#endif
Loading
Loading