From 45ffaee09361110c018e962dbb3d93f7f1ee8e09 Mon Sep 17 00:00:00 2001 From: Nikolai Nechaev Date: Thu, 30 Apr 2026 02:32:06 +0900 Subject: tests: Fix more tests failing on CI (#14159) * tests: Relax color management requirements in the colors test This continues the work from d4dd299 (#14142): - Fixes a missed check assuming a fixed value for `colorManagementPreset` - Stricten checks to require that the expected keywords are present as json keys * tests: Refactor `Tests::getAttribute` (was `Tests::getWindowAttribute`) - Improve ergonomics by consistently handling attribute name; - Remove 'window' from the function name, since it is compatible with other responses too; - Document the function. * tests: Fix solitary test assuming it knows the complete set of blockers The test was failing on the CI because new blockers appeared, which were not expected by the text. Fix the test, so that it just checks the set of expected blockers is a subset of actual blockers --- hyprtester/src/tests/main/window.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'hyprtester/src/tests/main/window.cpp') diff --git a/hyprtester/src/tests/main/window.cpp b/hyprtester/src/tests/main/window.cpp index 7f36cf7b..4a4da0cc 100644 --- a/hyprtester/src/tests/main/window.cpp +++ b/hyprtester/src/tests/main/window.cpp @@ -75,7 +75,7 @@ TEST_CASE(swapWindow) { // Test swapwindow by direction { getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_A' })"); - auto pos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); + auto pos = "at: " + Tests::getAttribute(getFromSocket("/activewindow"), "at"); NLog::log("{}Testing kitty_A {}, swapwindow with direction 'r'", Colors::YELLOW, pos); OK(getFromSocket("/dispatch hl.dsp.window.swap({ direction = 'right' })")); @@ -87,7 +87,7 @@ TEST_CASE(swapWindow) { // Test swapwindow by class { getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_A' })"); - auto pos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); + auto pos = "at: " + Tests::getAttribute(getFromSocket("/activewindow"), "at"); NLog::log("{}Testing kitty_A {}, swapwindow with class:kitty_B", Colors::YELLOW, pos); OK(getFromSocket("/dispatch hl.dsp.window.swap({ target = 'class:kitty_B' })")); @@ -101,7 +101,7 @@ TEST_CASE(swapWindow) { getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_B' })"); auto addr = getWindowAddress(getFromSocket("/activewindow")); getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_A' })"); - auto pos = Tests::getWindowAttribute(getFromSocket("/activewindow"), "at:"); + auto pos = "at: " + Tests::getAttribute(getFromSocket("/activewindow"), "at"); NLog::log("{}Testing kitty_A {}, swapwindow with address:0x{}(kitty_B)", Colors::YELLOW, pos, addr); OK(getFromSocket(std::format("/dispatch hl.dsp.window.swap({{ target = 'address:0x{}' }})", addr))); @@ -124,7 +124,7 @@ TEST_CASE(swapWindow) { { getFromSocket("/dispatch hl.dsp.focus({ window = 'class:kitty_B' })"); auto addr = getWindowAddress(getFromSocket("/activewindow")); - auto ws = Tests::getWindowAttribute(getFromSocket("/activewindow"), "workspace:"); + auto ws = "workspace: " + Tests::getAttribute(getFromSocket("/activewindow"), "workspace"); NLog::log("{}Sending address:0x{}(kitty_B) to workspace \"swapwindow2\"", Colors::YELLOW, addr); OK(getFromSocket("/dispatch hl.dsp.window.move({ workspace = 'name:swapwindow2', follow = false })")); @@ -190,9 +190,9 @@ TEST_CASE(windowGroupRules) { static bool isActiveWindow(const std::string& class_, char fullscreen = '0', bool log = true) { std::string activeWin = getFromSocket("/activewindow"); - auto winClass = Tests::getWindowAttribute(activeWin, "class:"); - auto winFullscreen = Tests::getWindowAttribute(activeWin, "fullscreen:").back(); - if (winClass.substr(strlen("class: ")) == class_ && winFullscreen == fullscreen) + auto winClass = Tests::getAttribute(activeWin, "class"); + auto winFullscreen = Tests::getAttribute(activeWin, "fullscreen").back(); + if (winClass == class_ && winFullscreen == fullscreen) return true; else { if (log) -- cgit v1.2.3