test-spawn.lua: Also test exit statuses
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
44a3e27e81
commit
2f5ade49c2
|
@ -3,6 +3,7 @@
|
||||||
local spawn = require("awful.spawn")
|
local spawn = require("awful.spawn")
|
||||||
|
|
||||||
local spawns_done = 0
|
local spawns_done = 0
|
||||||
|
local exit_yay, exit_snd = nil, nil
|
||||||
|
|
||||||
local steps = {
|
local steps = {
|
||||||
function(count)
|
function(count)
|
||||||
|
@ -16,11 +17,16 @@ local steps = {
|
||||||
assert(steps_yay == 1)
|
assert(steps_yay == 1)
|
||||||
steps_yay = steps_yay + 1
|
steps_yay = steps_yay + 1
|
||||||
spawns_done = spawns_done + 1
|
spawns_done = spawns_done + 1
|
||||||
|
end, function(reason, code)
|
||||||
|
assert(reason == "exit")
|
||||||
|
assert(exit_yay == nil)
|
||||||
|
assert(code == 0)
|
||||||
|
exit_yay = code
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local steps_count = 0
|
local steps_count = 0
|
||||||
local err_count = 0
|
local err_count = 0
|
||||||
spawn.with_line_callback({ "sh", "-c", "printf line1\\\\nline2\\\\nline3 ; echo err >&2" },
|
spawn.with_line_callback({ "sh", "-c", "printf line1\\\\nline2\\\\nline3 ; echo err >&2 ; exit 42" },
|
||||||
function(line)
|
function(line)
|
||||||
assert(steps_count < 3)
|
assert(steps_count < 3)
|
||||||
steps_count = steps_count + 1
|
steps_count = steps_count + 1
|
||||||
|
@ -34,9 +40,16 @@ local steps = {
|
||||||
assert(err_count == 1)
|
assert(err_count == 1)
|
||||||
steps_count = steps_count + 1
|
steps_count = steps_count + 1
|
||||||
spawns_done = spawns_done + 1
|
spawns_done = spawns_done + 1
|
||||||
|
end, function(reason, code)
|
||||||
|
assert(reason == "exit")
|
||||||
|
assert(exit_snd == nil)
|
||||||
|
assert(code == 42)
|
||||||
|
exit_snd = code
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
if spawns_done == 2 then
|
if spawns_done == 2 then
|
||||||
|
assert(exit_yay == 0)
|
||||||
|
assert(exit_snd == 42)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue