diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-19 22:57:13 +0000 |
commit | 9be89f131f87608f224f0ee06d199fcd09d32176 (patch) | |
tree | 11022dcfa9e08cb4ac5581b16734196128688d48 /test/functional/lua/loader_spec.lua | |
parent | ff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff) | |
parent | 88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff) | |
download | rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2 rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip |
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'test/functional/lua/loader_spec.lua')
-rw-r--r-- | test/functional/lua/loader_spec.lua | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/test/functional/lua/loader_spec.lua b/test/functional/lua/loader_spec.lua index f13e6664c5..8508f2aa14 100644 --- a/test/functional/lua/loader_spec.lua +++ b/test/functional/lua/loader_spec.lua @@ -12,14 +12,14 @@ describe('vim.loader', function() it('can work in compatibility with --luamod-dev #27413', function() clear({ args = { '--luamod-dev' } }) - exec_lua [[ + exec_lua(function() vim.loader.enable() - require("vim.fs") + require('vim.fs') -- try to load other vim submodules as well (Nvim Lua stdlib) for key, _ in pairs(vim._submodules) do - local modname = 'vim.' .. key -- e.g. "vim.fs" + local modname = 'vim.' .. key -- e.g. "vim.fs" local lhs = vim[key] local rhs = require(modname) @@ -28,28 +28,25 @@ describe('vim.loader', function() ('%s != require("%s"), %s != %s'):format(modname, modname, tostring(lhs), tostring(rhs)) ) end - ]] + end) end) it('handles changing files (#23027)', function() - exec_lua [[ + exec_lua(function() vim.loader.enable() - ]] + end) local tmp = t.tmpname() command('edit ' .. tmp) eq( 1, - exec_lua( - [[ - vim.api.nvim_buf_set_lines(0, 0, -1, true, {'_G.TEST=1'}) - vim.cmd.write() - loadfile(...)() - return _G.TEST - ]], - tmp - ) + exec_lua(function() + vim.api.nvim_buf_set_lines(0, 0, -1, true, { '_G.TEST=1' }) + vim.cmd.write() + loadfile(tmp)() + return _G.TEST + end) ) -- fs latency @@ -57,15 +54,12 @@ describe('vim.loader', function() eq( 2, - exec_lua( - [[ - vim.api.nvim_buf_set_lines(0, 0, -1, true, {'_G.TEST=2'}) - vim.cmd.write() - loadfile(...)() - return _G.TEST - ]], - tmp - ) + exec_lua(function() + vim.api.nvim_buf_set_lines(0, 0, -1, true, { '_G.TEST=2' }) + vim.cmd.write() + loadfile(tmp)() + return _G.TEST + end) ) end) @@ -74,8 +68,7 @@ describe('vim.loader', function() vim.loader.enable() ]] - local tmp = t.tmpname() - assert(os.remove(tmp)) + local tmp = t.tmpname(false) assert(t.mkdir(tmp)) assert(t.mkdir(tmp .. '/%')) local tmp1 = tmp .. '/%/x' @@ -88,4 +81,15 @@ describe('vim.loader', function() eq(1, exec_lua('return loadfile(...)()', tmp1)) eq(2, exec_lua('return loadfile(...)()', tmp2)) end) + + it('correct indent on error message (#29809)', function() + local errmsg = exec_lua [[ + vim.loader.enable() + local _, errmsg = pcall(require, 'non_existent_module') + return errmsg + ]] + local errors = vim.split(errmsg, '\n') + eq("\tcache_loader: module 'non_existent_module' not found", errors[3]) + eq("\tcache_loader_lib: module 'non_existent_module' not found", errors[4]) + end) end) |