aboutsummaryrefslogtreecommitdiff
path: root/test/helpers.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-10-26 02:30:40 -0700
committerGitHub <noreply@github.com>2019-10-26 02:30:40 -0700
commit19ba36d0e1bb4ef28f8aa92c7386345fbcf78cf2 (patch)
treef8e95ef890acd6ee9fecb9d56a1093dfc4d1df8a /test/helpers.lua
parent91b831da8b00319afba6a90b439d70960f90c3f7 (diff)
parent316c29bbf36d3d36c459b7c955d921b29ca659d0 (diff)
downloadrneovim-19ba36d0e1bb4ef28f8aa92c7386345fbcf78cf2.tar.gz
rneovim-19ba36d0e1bb4ef28f8aa92c7386345fbcf78cf2.tar.bz2
rneovim-19ba36d0e1bb4ef28f8aa92c7386345fbcf78cf2.zip
Merge #11271 from h-michael/add-more-info
lua/vim.shared: improve some validation messages
Diffstat (limited to 'test/helpers.lua')
-rw-r--r--test/helpers.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index 4c526d217f..3f29a28c0d 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -74,7 +74,8 @@ function module.matches(pat, actual)
error(string.format('Pattern does not match.\nPattern:\n%s\nActual:\n%s', pat, actual))
end
--- Invokes `fn` and returns the error string, or raises an error if `fn` succeeds.
+-- Invokes `fn` and returns the error string (may truncate full paths), or
+-- raises an error if `fn` succeeds.
--
-- Usage:
-- -- Match exact string.
@@ -88,7 +89,17 @@ function module.pcall_err(fn, ...)
if status == true then
error('expected failure, but got success')
end
+ -- From this:
+ -- /home/foo/neovim/runtime/lua/vim/shared.lua:186: Expected string, got number
+ -- to this:
+ -- Expected string, got number
local errmsg = tostring(rv):gsub('^[^:]+:%d+: ', '')
+ -- From this:
+ -- Error executing lua: /very/long/foo.lua:186: Expected string, got number
+ -- to this:
+ -- Error executing lua: .../foo.lua:186: Expected string, got number
+ errmsg = errmsg:gsub([[lua: [a-zA-Z]?:?[^:]-[/\]([^:/\]+):%d+: ]], 'lua: .../%1: ')
+ -- ^ Windows drive-letter (C:)
return errmsg
end