From e4b6fedfb96c8796e92f558b281e0dbdab5f5b66 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Fri, 27 Jun 2025 12:18:45 +0200 Subject: tester: simplify adding test files --- hyprtester/src/tests/main/groups.cpp | 4 +++- hyprtester/src/tests/main/misc.cpp | 4 +++- hyprtester/src/tests/main/tests.hpp | 14 ++++++++++---- hyprtester/src/tests/main/window.cpp | 4 +++- hyprtester/src/tests/main/workspaces.cpp | 4 +++- 5 files changed, 22 insertions(+), 8 deletions(-) (limited to 'hyprtester/src/tests') diff --git a/hyprtester/src/tests/main/groups.cpp b/hyprtester/src/tests/main/groups.cpp index ed8e4ba4..3cf15851 100644 --- a/hyprtester/src/tests/main/groups.cpp +++ b/hyprtester/src/tests/main/groups.cpp @@ -18,7 +18,7 @@ using namespace Hyprutils::Memory; #define UP CUniquePointer #define SP CSharedPointer -bool testGroups() { +static bool test() { NLog::log("{}Testing groups", Colors::GREEN); // test on workspace "window" @@ -175,3 +175,5 @@ bool testGroups() { return !ret; } + +REGISTER_TEST_FN(test) diff --git a/hyprtester/src/tests/main/misc.cpp b/hyprtester/src/tests/main/misc.cpp index db0d9092..a90214ce 100644 --- a/hyprtester/src/tests/main/misc.cpp +++ b/hyprtester/src/tests/main/misc.cpp @@ -18,7 +18,7 @@ using namespace Hyprutils::Memory; #define UP CUniquePointer #define SP CSharedPointer -bool testMisc() { +static bool test() { NLog::log("{}Testing config: misc:", Colors::GREEN); NLog::log("{}Testing close_special_on_empty", Colors::YELLOW); @@ -140,3 +140,5 @@ bool testMisc() { return !ret; } + +REGISTER_TEST_FN(test); diff --git a/hyprtester/src/tests/main/tests.hpp b/hyprtester/src/tests/main/tests.hpp index accde951..757052b6 100644 --- a/hyprtester/src/tests/main/tests.hpp +++ b/hyprtester/src/tests/main/tests.hpp @@ -1,6 +1,12 @@ #pragma once -bool testGroups(); -bool testWindows(); -bool testWorkspaces(); -bool testMisc(); \ No newline at end of file +#include +#include + +inline std::vector> testFns; + +#define REGISTER_TEST_FN(fn) \ + static auto _register_fn = [] { \ + testFns.emplace_back(fn); \ + return 1; \ + }(); diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index 4eecd68d..d79e6155 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -18,7 +18,7 @@ using namespace Hyprutils::Memory; #define UP CUniquePointer #define SP CSharedPointer -bool testWindows() { +static bool test() { NLog::log("{}Testing windows", Colors::GREEN); // test on workspace "window" @@ -94,3 +94,5 @@ bool testWindows() { return !ret; } + +REGISTER_TEST_FN(test) diff --git a/hyprtester/src/tests/main/workspaces.cpp b/hyprtester/src/tests/main/workspaces.cpp index ccacff28..96efacfa 100644 --- a/hyprtester/src/tests/main/workspaces.cpp +++ b/hyprtester/src/tests/main/workspaces.cpp @@ -18,7 +18,7 @@ using namespace Hyprutils::Memory; #define UP CUniquePointer #define SP CSharedPointer -bool testWorkspaces() { +static bool test() { NLog::log("{}Testing workspaces", Colors::GREEN); // test on workspace "window" @@ -347,3 +347,5 @@ bool testWorkspaces() { return !ret; } + +REGISTER_TEST_FN(test) -- cgit v1.2.3