aboutsummaryrefslogtreecommitdiff
path: root/test/testutil.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2026-04-17 21:20:36 +0800
committerGitHub <noreply@github.com>2026-04-17 21:20:36 +0800
commitfefad0721a9d55a9bee352ceeec48c452e1d1802 (patch)
tree5b6a1b6dbd75c5ecc7dfaa89f70b97894bceba43 /test/testutil.lua
parent2c67daee88d789001c43948aa6350d573c039026 (diff)
downloadrneovim-fefad0721a9d55a9bee352ceeec48c452e1d1802.tar.gz
rneovim-fefad0721a9d55a9bee352ceeec48c452e1d1802.tar.bz2
rneovim-fefad0721a9d55a9bee352ceeec48c452e1d1802.zip
test: include test path in summary (#39141)
Ref: https://github.com/neovim/neovim/pull/38486#discussion_r3088483987
Diffstat (limited to 'test/testutil.lua')
-rw-r--r--test/testutil.lua20
1 files changed, 17 insertions, 3 deletions
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`.