mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
Add a test for awful.util.spawn_with_line_callback
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
0e20fef2bd
commit
3c4a80ca7e
1 changed files with 45 additions and 0 deletions
45
tests/test-spawn.lua
Normal file
45
tests/test-spawn.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
--- Tests for spawn
|
||||
|
||||
local util = require("awful.util")
|
||||
|
||||
local spawns_done = 0
|
||||
|
||||
local steps = {
|
||||
function(count)
|
||||
if count == 1 then
|
||||
local steps_yay = 0
|
||||
util.spawn_with_line_callback("echo yay", function(line)
|
||||
assert(line == "yay", "line == '" .. tostring(line) .. "'")
|
||||
assert(steps_yay == 0)
|
||||
steps_yay = steps_yay + 1
|
||||
end, nil, function()
|
||||
assert(steps_yay == 1)
|
||||
steps_yay = steps_yay + 1
|
||||
spawns_done = spawns_done + 1
|
||||
end)
|
||||
|
||||
local steps_count = 0
|
||||
local err_count = 0
|
||||
util.spawn_with_line_callback({ "sh", "-c", "printf line1\\\\nline2\\\\nline3 ; echo err >&2" },
|
||||
function(line)
|
||||
assert(steps_count < 3)
|
||||
steps_count = steps_count + 1
|
||||
assert(line == "line" .. steps_count, "line == '" .. tostring(line) .. "'")
|
||||
end, function(line)
|
||||
assert(err_count == 0)
|
||||
err_count = err_count + 1
|
||||
assert(line == "err", "line == '" .. tostring(line) .. "'")
|
||||
end, function()
|
||||
assert(steps_count == 3)
|
||||
assert(err_count == 1)
|
||||
steps_count = steps_count + 1
|
||||
spawns_done = spawns_done + 1
|
||||
end)
|
||||
end
|
||||
if spawns_done == 2 then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
require("_runner").run_steps(steps)
|
Loading…
Reference in a new issue