Skip to content

Commit

Permalink
tests: add multi-match test in direct mode
Browse files Browse the repository at this point in the history
This reveals that it's relatively useless, as we really should have some way
to inspect the buffer at a minimum.  Need to think about it.

Signed-off-by: Kyle Evans <[email protected]>
  • Loading branch information
kevans91 committed Sep 25, 2024
1 parent 4f4b220 commit 53e6871
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_multimatch.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local ltest = require('./libtest')
local porch = require('porch')

local cat = assert(porch.spawn("cat"))
cat.timeout = 3

assert(cat:write("PANIC: foo\r"))
assert(cat:write("login: \r"))

local panic_match, login_match

cat:match({
["PANIC:.+"] = {
callback = function()
panic_match = true
end,
},
["login:"] = {
callback = function()
login_match = true
end,
},
})

assert(panic_match, "Panic should have been found first")
assert(not login_match, "No matches should have happened after panic")

assert(cat:close())

0 comments on commit 53e6871

Please sign in to comment.