From fefad0721a9d55a9bee352ceeec48c452e1d1802 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 17 Apr 2026 21:20:36 +0800 Subject: test: include test path in summary (#39141) Ref: https://github.com/neovim/neovim/pull/38486#discussion_r3088483987 --- test/testutil.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'test/testutil.lua') diff --git a/test/testutil.lua b/test/testutil.lua index ac072e6bb8..b12f5827da 100644 --- a/test/testutil.lua +++ b/test/testutil.lua @@ -126,13 +126,27 @@ end --- @param pat string --- @param actual string +--- @param plain boolean? (default: false) --- @return boolean -function M.matches(pat, actual) +function M.matches(pat, actual, plain) assert(pat and pat ~= '', 'pat must be a non-empty string') - if nil ~= string.match(actual, pat) then + assert(plain == nil or type(plain) == 'boolean', 'plain must be nil or boolean') + if nil ~= string.find(actual, pat, 1, plain) then return true end - error(string.format('Pattern does not match.\nPattern:\n%s\nActual:\n%s', pat, actual)) + error(('Pattern does not match.\nPattern:\n%s\nActual:\n%s'):format(pat, actual)) +end + +--- @param pat string +--- @param actual string +--- @param plain boolean? (default: false) +--- @return boolean +function M.not_matches(pat, actual, plain) + assert(pat and pat ~= '', 'pat must be a non-empty string') + if nil == string.find(actual, pat, 1, plain) then + return true + end + error(('Pattern does match.\nPattern:\n%s\nActual:\n%s'):format(pat, actual)) end --- Asserts that `pat` matches (or *not* if inverse=true) any text in the tail of `logfile`. -- cgit