From efbf366c188368f4683e1d6b132a138a35d0ae70 Mon Sep 17 00:00:00 2001 From: sami Date: Thu, 10 Sep 2026 20:19:11 +0400 Subject: [PATCH] core: add test-name filters to the vtest harness run_all() takes an optional substring list; vtest_main forwards argv and a comma-separated $VT_ONLY. No filter => run everything, as before. Makes iterating on one slow end-to-end case (the engine suite) practical without a framework swap. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01HPPSGhiArbvQgwC2DNiURS --- core/tests/support/vtest.hpp | 10 +++++++++- core/tests/support/vtest_main.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/core/tests/support/vtest.hpp b/core/tests/support/vtest.hpp index fa48322..79b84a2 100644 --- a/core/tests/support/vtest.hpp +++ b/core/tests/support/vtest.hpp @@ -81,9 +81,17 @@ std::string show(const T &v) { } } -inline int run_all() { +inline int run_all(const std::vector &filters = {}) { int failed_cases = 0; for (const auto &c : registry()) { + if (!filters.empty()) { + bool match = false; + for (const auto &f : filters) + if (std::string_view(c.name).find(f) != std::string_view::npos) + match = true; + if (!match) + continue; + } int before = stats().failures; stats().current_fatal = false; std::fprintf(stderr, "[ RUN ] %s\n", c.name); diff --git a/core/tests/support/vtest_main.cpp b/core/tests/support/vtest_main.cpp index e80cce7..6c15fbf 100644 --- a/core/tests/support/vtest_main.cpp +++ b/core/tests/support/vtest_main.cpp @@ -1,6 +1,29 @@ // vtest_main.cpp — shared entry point for every CORE test binary. +#include +#include +#include + #include "vtest.hpp" -int main() { - return ::vt::run_all(); +// Optional filters: each argv argument (or a comma-separated entry in $VT_ONLY) is a +// substring; a test runs only if its name contains one of them. No filters => run all. +int main(int argc, char **argv) { + std::vector filters; + for (int i = 1; i < argc; ++i) + filters.emplace_back(argv[i]); + if (const char *env = std::getenv("VT_ONLY")) { + std::string cur; + for (const char *p = env;; ++p) { + if (*p == ',' || *p == '\0') { + if (!cur.empty()) + filters.push_back(cur); + cur.clear(); + if (*p == '\0') + break; + } else { + cur.push_back(*p); + } + } + } + return ::vt::run_all(filters); }