aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/system_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2025-04-29 10:48:18 +0100
committerLewis Russell <me@lewisr.dev>2025-05-29 13:59:33 +0100
commit532610388bb09fef6d0de8929092d4dc32f781bf (patch)
tree26f0186a932a009a7846e9af9edb1995b1649b8c /test/functional/lua/system_spec.lua
parentcc264d51aba802d7f536cc3680b3af2d13ed1889 (diff)
downloadrneovim-532610388bb09fef6d0de8929092d4dc32f781bf.tar.gz
rneovim-532610388bb09fef6d0de8929092d4dc32f781bf.tar.bz2
rneovim-532610388bb09fef6d0de8929092d4dc32f781bf.zip
fix(vim.system): improve error message when cwd does not exist
Problem: vim.uv.spawn will emit ENOENT for either when the cmd or cwd do not exist and does not tell you which. Solution: If an error occurs, check if cwd was supplied and included in the error message if it does not exist.
Diffstat (limited to 'test/functional/lua/system_spec.lua')
-rw-r--r--test/functional/lua/system_spec.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/functional/lua/system_spec.lua b/test/functional/lua/system_spec.lua
index 5abd901a9d..52206b7906 100644
--- a/test/functional/lua/system_spec.lua
+++ b/test/functional/lua/system_spec.lua
@@ -55,9 +55,14 @@ describe('vim.system', function()
describe('(' .. name .. ')', function()
it('failure modes', function()
t.matches(
- 'ENOENT%: no such file .*: "non%-existent%-cmd"',
+ "ENOENT%: no such file .* %(cmd%): 'non%-existent%-cmd'",
t.pcall_err(system, { 'non-existent-cmd', 'arg1', 'arg2' }, { text = true })
)
+
+ t.matches(
+ "ENOENT%: no such file .* %(cwd%): 'non%-existent%-cwd'",
+ t.pcall_err(system, { 'echo', 'hello' }, { cwd = 'non-existent-cwd', text = true })
+ )
end)
it('can run simple commands', function()