config: fix rules with no parameters not being counted as invalid (#11849)

Quite a big whoopsie to insert invalid rules.

Also adds special: cases.
This commit is contained in:
ItsOhen 2025-09-27 01:04:22 +02:00 committed by GitHub
parent ae445606e2
commit 6f1d2e771d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 72 additions and 36 deletions

View file

@ -237,7 +237,30 @@ static bool test() {
EXPECT_CONTAINS(str, "floating: 1");
EXPECT_CONTAINS(str, std::format("size: {},{}", SIZE, SIZE));
EXPECT_NOT_CONTAINS(str, "pinned: 1");
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable, class:wr_kitty"));
OK(getFromSocket("/keyword windowrule plugin:someplugin:variable 10, class:wr_kitty"));
OK(getFromSocket("/keyword windowrule workspace 1, class:wr_kitty"));
OK(getFromSocket("/keyword windowrule workspace special:magic, class:magic_kitty"));
if (!spawnKitty("magic_kitty"))
return false;
EXPECT_CONTAINS(getFromSocket("/activewindow"), "special:magic");
}
NLog::log("{}Testing faulty rules", Colors::YELLOW);
{
const auto PARAM = "Invalid parameter";
const auto RULE = "Invalid value";
const auto NORULE = "no rules provided";
EXPECT_CONTAINS(getFromSocket("/keyword windowrule notarule, class:wr_kitty"), RULE)
EXPECT_CONTAINS(getFromSocket("/keyword windowrule class:wr_kitty"), NORULE)
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, class:wr_kitty, size"), PARAM)
EXPECT_CONTAINS(getFromSocket("/keyword windowrule float, classI:wr_kitty"), PARAM)
EXPECT_CONTAINS(getFromSocket("/keyword windowrule workspace:, class:wr_kitty"), NORULE)
}
NLog::log("{}Reloading config", Colors::YELLOW);
OK(getFromSocket("/reload"));
NLog::log("{}Killing all windows", Colors::YELLOW);
Tests::killAllWindows();