diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-10-26 01:30:58 -0700 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-10-26 02:00:58 -0700 |
commit | 316c29bbf36d3d36c459b7c955d921b29ca659d0 (patch) | |
tree | f8e95ef890acd6ee9fecb9d56a1093dfc4d1df8a /test/helpers.lua | |
parent | 996a057fb9b4b7d791adad19f07b2f9c53a88ab5 (diff) | |
download | rneovim-316c29bbf36d3d36c459b7c955d921b29ca659d0.tar.gz rneovim-316c29bbf36d3d36c459b7c955d921b29ca659d0.tar.bz2 rneovim-316c29bbf36d3d36c459b7c955d921b29ca659d0.zip |
test/pcall_err(): truncate full paths, omit linenr
ref #11271
Diffstat (limited to 'test/helpers.lua')
-rw-r--r-- | test/helpers.lua | 13 |
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 |