summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-06-27 12:18:45 +0200
committerVaxry <vaxry@vaxry.net>2025-06-27 12:18:45 +0200
commite4b6fedfb96c8796e92f558b281e0dbdab5f5b66 (patch)
tree15d5f9c597ab6d8b1cb8004007054c977abdfe66
parent1fc7e80bdb112e9b5b06287d19c85d6e6d2cc1d5 (diff)
tester: simplify adding test files
-rw-r--r--hyprtester/src/main.cpp17
-rw-r--r--hyprtester/src/tests/main/groups.cpp4
-rw-r--r--hyprtester/src/tests/main/misc.cpp4
-rw-r--r--hyprtester/src/tests/main/tests.hpp14
-rw-r--r--hyprtester/src/tests/main/window.cpp4
-rw-r--r--hyprtester/src/tests/main/workspaces.cpp4
6 files changed, 25 insertions, 22 deletions
diff --git a/hyprtester/src/main.cpp b/hyprtester/src/main.cpp
index 176eb702..6fd42e1a 100644
--- a/hyprtester/src/main.cpp
+++ b/hyprtester/src/main.cpp
@@ -218,20 +218,9 @@ int main(int argc, char** argv, char** envp) {
NLog::log("{}Loaded plugin", Colors::YELLOW);
- // now we can start issuing stuff.
- NLog::log("{}testing windows", Colors::YELLOW);
- EXPECT(testWindows(), true);
-
- std::this_thread::sleep_for(std::chrono::milliseconds(2000));
-
- NLog::log("{}testing groups", Colors::YELLOW);
- EXPECT(testGroups(), true);
-
- NLog::log("{}testing workspaces", Colors::YELLOW);
- EXPECT(testWorkspaces(), true);
-
- NLog::log("{}testing misc variables", Colors::YELLOW);
- EXPECT(testMisc(), true);
+ for (const auto& fn : testFns) {
+ EXPECT(fn(), true);
+ }
NLog::log("{}running plugin test", Colors::YELLOW);
EXPECT(testPlugin(), true);
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 <vector>
+#include <functional>
+
+inline std::vector<std::function<bool()>> 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)