Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
21 changes: 16 additions & 5 deletions include/ut/ut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cstdlib>
#include <iostream>
#include <source_location>
#include <string>
#include <string_view>

namespace ut
Expand All @@ -40,6 +41,20 @@ namespace ut
{
using type = T;
};

[[nodiscard]] inline const std::string& run_filter()
{
static const std::string filter = [] {
#if defined(_MSC_VER)
#pragma warning(suppress : 4996)
#endif
const char* const env = std::getenv("UT_RUN");

return env != nullptr ? std::string{env} : std::string{};
}();

return filter;
}
}

template <size_t Size>
Expand Down Expand Up @@ -231,11 +246,7 @@ namespace ut
}
}
else {
static const std::string_view filter = []() -> std::string_view {
if (const char* env = std::getenv("UT_RUN")) return env;
return {};
}();

const auto& filter = detail::run_filter();
auto matches_filter = [](std::string_view test_name, std::string_view f) {
if (f.empty()) return true;

Expand Down
19 changes: 14 additions & 5 deletions modules/ut.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ namespace ut
{
using type = T;
};
[[nodiscard]] inline const std::string& run_filter()
{
static const std::string filter = [] {
#if defined(_MSC_VER)
#pragma warning(suppress : 4996)
#endif
const char* const env = std::getenv("UT_RUN");

return env != nullptr ? std::string{env} : std::string{};
}();

return filter;
}
}

export template <std::size_t Size>
Expand Down Expand Up @@ -225,11 +238,7 @@ namespace ut
}
}
else {
static const std::string_view filter = []() -> std::string_view {
if (const char* env = std::getenv("UT_RUN")) return env;
return {};
}();

const auto& filter = detail::run_filter();
auto matches_filter = [](std::string_view test_name, std::string_view f) {
if (f.empty()) return true;

Expand Down
Loading