From 53e6871e8e60ad8ef7d73f4c890df95a9f3ab968 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 25 Sep 2024 00:22:50 -0500 Subject: [PATCH] tests: add multi-match test in direct mode 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 --- tests/test_multimatch.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_multimatch.lua diff --git a/tests/test_multimatch.lua b/tests/test_multimatch.lua new file mode 100644 index 0000000..250c7ac --- /dev/null +++ b/tests/test_multimatch.lua @@ -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())