diff --git a/devel/snitch/Makefile b/devel/snitch/Makefile index df096816c43b..3a6e2854eea6 100644 --- a/devel/snitch/Makefile +++ b/devel/snitch/Makefile @@ -1,51 +1,54 @@ PORTNAME= snitch DISTVERSIONPREFIX= v DISTVERSION= 1.3.2 CATEGORIES= devel PKGNAMESUFFIX= -testing MAINTAINER= yuri@FreeBSD.org COMMENT= Lightweight C++20 testing framework WWW= https://github.com/cschreib/snitch LICENSE= BSL LICENSE_FILE= ${WRKSRC}/LICENSE TEST_DEPENDS= doctest>0:devel/doctest USES= cmake:testing compiler:c++20-lang USE_LDCONFIG= yes USE_GITHUB= yes GH_ACCOUNT= cschreib FLAVORS= default headers_only FLAVOR?= ${FLAVORS:[1]} headers_only_PLIST= ${MASTERDIR}/pkg-plist-headers-only .if ${FLAVOR} == default CMAKE_ON= BUILD_SHARED_LIBS .endif .if ${FLAVOR} == headers_only PKGNAMESUFFIX:= ${PKGNAMESUFFIX}-headers-only CMAKE_ON= SNITCH_HEADER_ONLY NO_ARCH= yes CONFLICTS_INSTALL= snitch-testing # see https://github.com/cschreib/snitch/issues/125 .endif CMAKE_ON+= SNITCH_USE_SYSTEM_DOCTEST CMAKE_TESTING_ON= SNITCH_DO_TEST SNITCH_ENABLE CMAKE_TESTING_TARGET= snitch_runtime_tests_run \ snitch_runtime_tests_self_run \ snitch_approval_tests_run # unclear how to run all tests post-install: @${RM} ${STAGEDIR}${PREFIX}/doc/snitch/LICENSE @${RMDIR} \ ${STAGEDIR}${PREFIX}/doc/snitch \ ${STAGEDIR}${PREFIX}/doc -# many tests fail, see https://github.com/snitch-org/snitch/issues/206 +# tests as of 1.3.2: +# [doctest] test cases: 3 | 3 passed | 0 failed | 0 skipped +# [doctest] assertions: 3407 | 3407 passed | 0 failed | +# [doctest] Status: SUCCESS! .include diff --git a/devel/snitch/files/patch-include_snitch_snitch__registry.hpp b/devel/snitch/files/patch-include_snitch_snitch__registry.hpp new file mode 100644 index 000000000000..cf07fa10eda4 --- /dev/null +++ b/devel/snitch/files/patch-include_snitch_snitch__registry.hpp @@ -0,0 +1,16 @@ +-- Add SNITCH_EXPORT to abort_exception struct. +-- This ensures that the exception can be correctly caught across shared library boundaries +-- on ELF systems (like FreeBSD) when built with -fvisibility=hidden. +-- This fixes "unexpected unknown exception caught" errors in tests. + +--- include/snitch/snitch_registry.hpp.orig 2026-05-31 20:22:28 UTC ++++ include/snitch/snitch_registry.hpp +@@ -61,7 +61,7 @@ constexpr test_ptr to_test_case_ptr(const F&) noexcept + return []() { F{}.template operator()(); }; + } + +-struct abort_exception {}; ++struct SNITCH_EXPORT abort_exception {}; + + SNITCH_EXPORT bool parse_colour_mode_option(registry& reg, std::string_view color_option) noexcept; + SNITCH_EXPORT bool parse_color_option(registry& reg, std::string_view color_option) noexcept; diff --git a/devel/snitch/files/patch-tests_approval__tests_reporter__catch2__xml.cpp b/devel/snitch/files/patch-tests_approval__tests_reporter__catch2__xml.cpp new file mode 100644 index 000000000000..4a3ad195f738 --- /dev/null +++ b/devel/snitch/files/patch-tests_approval__tests_reporter__catch2__xml.cpp @@ -0,0 +1,31 @@ +-- Update regexes in approval tests to handle versioned directory names and 3-component versions. +-- The directory structure in FreeBSD ports often includes the version (e.g., snitch-1.3.2), +-- which was breaking the path-matching regexes. Also updated version matching for 1.3.2. + +--- tests/approval_tests/reporter_catch2_xml.cpp.orig 2026-05-31 20:22:28 UTC ++++ tests/approval_tests/reporter_catch2_xml.cpp +@@ -37,15 +37,15 @@ TEST_CASE("xml reporter", "[reporters]") { + + const std::vector ignores = { + std::regex{R"|(durationInSeconds="([0-9.e+\-]{12})")|"}, +- std::regex{R"(catch2-version="([0-9]+\.[0-9]+\.[0-9]+\.[0-9a-z]+).snitch)"}, +- std::regex{R"(filename="(.+/snitch/tests/approval_tests/))"}, +- std::regex{R"(filename="(.+/snitch/tests/))"}, +- std::regex{R"((.+/snitch/tests/approval_tests/))"}, +- std::regex{R"((.+/snitch/tests/))"}, +- std::regex{R"(filename="(.+\\snitch\\tests\\approval_tests\\))"}, +- std::regex{R"(filename="(.+\\snitch\\tests\\))"}, +- std::regex{R"((.+\\snitch\\tests\\approval_tests\\))"}, +- std::regex{R"((.+\\snitch\\tests\\))"}, ++ std::regex{R"(catch2-version="([0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9a-z]+)?).snitch)"}, ++ std::regex{R"(filename="(.+/snitch.*/tests/approval_tests/))"}, ++ std::regex{R"(filename="(.+/snitch.*/tests/))"}, ++ std::regex{R"((.+/snitch.*/tests/approval_tests/))"}, ++ std::regex{R"((.+/snitch.*/tests/))"}, ++ std::regex{R"(filename="(.+\\snitch.*\\tests\\approval_tests\\))"}, ++ std::regex{R"(filename="(.+\\snitch.*\\tests\\))"}, ++ std::regex{R"((.+\\snitch.*\\tests\\approval_tests\\))"}, ++ std::regex{R"((.+\\snitch.*\\tests\\))"}, + std::regex{R"|(line="([0-9]+)")|"}, + std::regex{R"(([0-9]+))"}}; + diff --git a/devel/snitch/files/patch-tests_approval__tests_reporter__console.cpp b/devel/snitch/files/patch-tests_approval__tests_reporter__console.cpp new file mode 100644 index 000000000000..935a99f4ebd3 --- /dev/null +++ b/devel/snitch/files/patch-tests_approval__tests_reporter__console.cpp @@ -0,0 +1,23 @@ +-- Update regexes in approval tests to handle versioned directory names and 3-component versions. +-- The directory structure in FreeBSD ports often includes the version (e.g., snitch-1.3.2), +-- which was breaking the path-matching regexes. Also updated version matching for 1.3.2. + +--- tests/approval_tests/reporter_console.cpp.orig 2026-05-31 20:22:28 UTC ++++ tests/approval_tests/reporter_console.cpp +@@ -22,11 +22,11 @@ TEST_CASE("console reporter", "[reporters]") { + + const std::vector ignores = { + std::regex{R"(, ([0-9.e+\-]{12}) seconds)"}, +- std::regex{R"(snitch v([0-9]+\.[0-9]+\.[0-9]+\.[0-9a-z]+))"}, +- std::regex{R"(at (.+/snitch/tests/approval_tests/).+:([0-9]+))"}, +- std::regex{R"(at (.+/snitch/tests/).+:([0-9]+))"}, +- std::regex{R"(at (.+\\snitch\\tests\\approval_tests\\).+:([0-9]+))"}, +- std::regex{R"(at (.+\\snitch\\tests\\).+:([0-9]+))"}, ++ std::regex{R"(snitch v([0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9a-z]+)?))"}, ++ std::regex{R"(at (.+/snitch.*/tests/approval_tests/).+:([0-9]+))"}, ++ std::regex{R"(at (.+/snitch.*/tests/).+:([0-9]+))"}, ++ std::regex{R"(at (.+\\snitch.*\\tests\\approval_tests\\).+:([0-9]+))"}, ++ std::regex{R"(at (.+\\snitch.*\\tests\\).+:([0-9]+))"}, + std::regex{R"(^finished: .+\(([0-9.e+\-]{12}s)\))"}}; + + SECTION("default") { diff --git a/devel/snitch/files/patch-tests_approval__tests_reporter__teamcity.cpp b/devel/snitch/files/patch-tests_approval__tests_reporter__teamcity.cpp new file mode 100644 index 000000000000..d6db5e139839 --- /dev/null +++ b/devel/snitch/files/patch-tests_approval__tests_reporter__teamcity.cpp @@ -0,0 +1,21 @@ +-- Update regexes in approval tests to handle versioned directory names. +-- The directory structure in FreeBSD ports often includes the version (e.g., snitch-1.3.2), +-- which was breaking the path-matching regexes. + +--- tests/approval_tests/reporter_teamcity.cpp.orig 2026-05-31 20:22:28 UTC ++++ tests/approval_tests/reporter_teamcity.cpp +@@ -29,10 +29,10 @@ TEST_CASE("teamcity reporter", "[reporters]") { + + const std::vector ignores = { + std::regex{R"( duration='([0-9]+)')"}, +- std::regex{R"( (?:message|out)='(.+/snitch/tests/approval_tests/).+:([0-9]+))"}, +- std::regex{R"( (?:message|out)='(.+/snitch/tests/).+:([0-9]+))"}, +- std::regex{R"( (?:message|out)='(.+\\snitch\\tests\\approval_tests\\).+:([0-9]+))"}, +- std::regex{R"( (?:message|out)='(.+\\snitch\\tests\\).+:([0-9]+))"}}; ++ std::regex{R"( (?:message|out)='(.+/snitch.*/tests/approval_tests/).+:([0-9]+))"}, ++ std::regex{R"( (?:message|out)='(.+/snitch.*/tests/).+:([0-9]+))"}, ++ std::regex{R"( (?:message|out)='(.+\\snitch.*\\tests\\approval_tests\\).+:([0-9]+))"}, ++ std::regex{R"( (?:message|out)='(.+\\snitch.*\\tests\\).+:([0-9]+))"}}; + + SECTION("default") { + const arg_vector args{"test", "--reporter", reporter_name}; diff --git a/devel/snitch/files/patch-tests_testing__event.hpp b/devel/snitch/files/patch-tests_testing__event.hpp new file mode 100644 index 000000000000..e7ac4f07d7b1 --- /dev/null +++ b/devel/snitch/files/patch-tests_testing__event.hpp @@ -0,0 +1,47 @@ +-- Increase message pool and event capacity in mock_framework and event_catcher. +-- This prevents "message pool is full" crashes in complex tests (like "multiple leaves") +-- that generate more events and strings than the previous small fixed-size buffers allowed. + +--- tests/testing_event.hpp.orig 2026-05-31 20:22:28 UTC ++++ tests/testing_event.hpp +@@ -177,16 +177,16 @@ struct mock_framework { + + struct mock_framework { + struct large_data { +- snitch::registry registry; +- snitch::small_string<4086> string_pool; +- snitch::small_vector events; ++ snitch::registry registry; ++ snitch::small_string<16384> string_pool; ++ snitch::small_vector events; + }; + + // Put large data on the heap; this can consume too much stack. +- std::unique_ptr data = std::make_unique(); +- snitch::registry& registry = data->registry; +- snitch::small_string<4086>& string_pool = data->string_pool; +- snitch::small_vector& events = data->events; ++ std::unique_ptr data = std::make_unique(); ++ snitch::registry& registry = data->registry; ++ snitch::small_string<16384>& string_pool = data->string_pool; ++ snitch::small_vector& events = data->events; + + snitch::impl::test_case test_case{ + .id = {"mock_test", "[mock_tag]", "mock_type"}, +@@ -267,14 +267,14 @@ struct event_catcher { + struct event_catcher { + struct large_data { + snitch::registry registry; +- snitch::small_string<1024> string_pool; ++ snitch::small_string<8192> string_pool; + snitch::small_vector events; + }; + + // Put large data on the heap; this can consume too much stack. + std::unique_ptr data = std::make_unique(); + snitch::registry& registry = data->registry; +- snitch::small_string<1024>& string_pool = data->string_pool; ++ snitch::small_string<8192>& string_pool = data->string_pool; + snitch::small_vector& events = data->events; + + snitch::impl::test_case mock_case{