From 083462e0c1df1d042943159fdc3e651082d78bde Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 17 Feb 2019 10:21:18 +0100 Subject: [PATCH 1/2] naughty test: Warn about missing dependencies Signed-off-by: Uli Schlachter --- tests/test-naughty-legacy.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test-naughty-legacy.lua b/tests/test-naughty-legacy.lua index 5a0ad5f3b..99d0a83e1 100644 --- a/tests/test-naughty-legacy.lua +++ b/tests/test-naughty-legacy.lua @@ -44,7 +44,14 @@ check_cmd() -- Can't test anything of value the documentation example tests don't already -- hit. -if not has_cmd_send then require("_runner").run_steps {}; return end +if not has_cmd_send then + require("gears.debug").print_warning("Did not find dbus-send, skipping test") + require("_runner").run_steps {} + return +end +if not has_cmd_notify then + require("gears.debug").print_warning("Did not find notify-send, skipping some tests") +end local active, destroyed, reasons, counter = {}, {}, {}, 0 From a54eb67de0ee568f5a2b65e28a1c6e82a9324a21 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 17 Feb 2019 10:30:31 +0100 Subject: [PATCH 2/2] naughty test: Use array-style spawn() calls When a string is spawned, the C code has to split this into an array for the execve() syscall. When an array is given directly, this array does not need to be transformed in any way. This makes it much more clear what is actually started. This commit removes some quotation marks that were previously removed by the C code. For example, array:string:1,"four",2,"five",3,"six" became array:string:1,four,2,five,3,six because otherwise the action was called "four" instead of four and the test failed. Signed-off-by: Uli Schlachter --- tests/test-naughty-legacy.lua | 76 ++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/tests/test-naughty-legacy.lua b/tests/test-naughty-legacy.lua index 99d0a83e1..4e6235955 100644 --- a/tests/test-naughty-legacy.lua +++ b/tests/test-naughty-legacy.lua @@ -88,7 +88,7 @@ naughty.connect_signal("destroyed", destroyed_callback) table.insert(steps, function() if not has_cmd_notify then return true end - spawn('notify-send title message -t 25000') + spawn{ 'notify-send', 'title', 'message', '-t', '25000' } return true end) @@ -128,7 +128,7 @@ table.insert(steps, function() -- There is some magic behind this, check it works assert(naughty.suspended) - spawn('notify-send title message -t 25000') + spawn{ 'notify-send', 'title', 'message', '-t', '25000' } return true end) @@ -150,7 +150,7 @@ table.insert(steps, function(count) active[1]:destroy() assert(#active == 0) - spawn('notify-send title message -t 1') + spawn{ 'notify-send', 'title', 'message', '-t', '1' } return true end) @@ -175,7 +175,7 @@ table.insert(steps, function() -- There is some magic behind this, make sure it works assert(naughty.expiration_paused) - spawn('notify-send title message -t 1') + spawn{ 'notify-send', 'title', 'message', '-t', '1' } return true end) @@ -209,9 +209,9 @@ table.insert(steps, function() -- so better not "document" the instantaneous clearing of the queue. if #active > 0 then return end - spawn('notify-send low message -t 25000 -u low') - spawn('notify-send normal message -t 25000 -u normal') - spawn('notify-send critical message -t 25000 -u critical') + spawn{ 'notify-send', 'low', 'message', '-t', '25000', '-u', 'low' } + spawn{ 'notify-send', 'normal', 'message', '-t', '25000', '-u', 'normal' } + spawn{ 'notify-send', 'critical', 'message', '-t', '25000', '-u', 'critical' } return true end) @@ -236,7 +236,7 @@ table.insert(steps, function() -- Everything should fit, otherwise the math is wrong in -- `neughty.layout.legacy` and its a regression. for i=1, max_notif do - spawn('notify-send "notif '..i..'" message -t 25000 -u low') + spawn{ 'notify-send', 'notif '..i, 'message', '-t', '25000', '-u', 'low' } end return true @@ -285,7 +285,7 @@ table.insert(steps, function() -- Now add even more! for i=1, 5 do - spawn('notify-send "notif '..i..'" message -t 25000 -u low') + spawn{ 'notify-send', 'notif '..i, 'message', '-t', '25000', '-u', 'low' } end return true @@ -566,20 +566,21 @@ end) -- Test more advanced features than what notify-send can provide. if has_cmd_send then - local cmd = [[dbus-send \ - --type=method_call \ - --print-reply=literal \ - --dest=org.freedesktop.Notifications \ - /org/freedesktop/Notifications \ - org.freedesktop.Notifications.Notify \ - string:"Awesome test" \ - uint32:0 \ - string:"" \ - string:"title" \ - string:"message body" \ - array:string:1,"one",2,"two",3,"three" \ - dict:string:string:"","" \ - int32:25000]] + local cmd = { 'dbus-send', + '--type=method_call', + '--print-reply=literal', + '--dest=org.freedesktop.Notifications', + '/org/freedesktop/Notifications', + 'org.freedesktop.Notifications.Notify', + 'string:"Awesome test"', + 'uint32:0', + 'string:""', + 'string:"title"', + 'string:"message body"', + 'array:string:1,one,2,two,3,three', + 'dict:string:string:"",""', + 'int32:25000' + } -- Test the actions. table.insert(steps, function() @@ -632,20 +633,21 @@ if has_cmd_send then n:connect_signal("property::message", function() message_u = true end) n:connect_signal("property::actions", function() actions_u = true end) - local update = [[dbus-send \ - --type=method_call \ - --print-reply=literal \ - --dest=org.freedesktop.Notifications \ - /org/freedesktop/Notifications \ - org.freedesktop.Notifications.Notify \ - string:"Awesome test" \ - uint32:]].. nid ..[[ \ - string:"" \ - string:"updated title" \ - string:"updated message body" \ - array:string:1,"four",2,"five",3,"six" \ - dict:string:string:"","" \ - int32:25000]] + local update = { 'dbus-send', + '--type=method_call', + '--print-reply=literal', + '--dest=org.freedesktop.Notifications', + '/org/freedesktop/Notifications', + 'org.freedesktop.Notifications.Notify', + 'string:"Awesome test"', + 'uint32:' .. nid, + 'string:""', + 'string:updated title', + 'string:updated message body', + 'array:string:1,four,2,five,3,six', + 'dict:string:string:"",""', + 'int32:25000', + } spawn(update)