test(vim.ui.open): mock failure on Windows

Problem:
On Windows, `rundll32` exits zero (success) even when given
a non-existent file.

Solution:
Mock vim.system() on Windows to force a "failure" case.
This commit is contained in:
Justin M. Keyes 2023-07-21 13:34:38 +02:00
parent 519b9929e9
commit 7907b1fca5

View File

@ -6,6 +6,7 @@ local clear = helpers.clear
local feed = helpers.feed local feed = helpers.feed
local eval = helpers.eval local eval = helpers.eval
local is_ci = helpers.is_ci local is_ci = helpers.is_ci
local is_os = helpers.is_os
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = helpers.poke_eventloop
describe('vim.ui', function() describe('vim.ui', function()
@ -134,8 +135,11 @@ describe('vim.ui', function()
describe('open()', function() describe('open()', function()
it('validation', function() it('validation', function()
if is_ci('github') then if is_os('win') or not is_ci('github') then
matches('vim.ui.open: command failed %(%d%): { "[^"]+", "non%-existent%-file" }', exec_lua[[vim.system = function() return { wait=function() return { code=3} end } end]]
end
if not is_os('bsd') then
matches('vim.ui.open: command failed %(%d%): { "[^"]+", .*"non%-existent%-file" }',
exec_lua[[local _, err = vim.ui.open('non-existent-file') ; return err]]) exec_lua[[local _, err = vim.ui.open('non-existent-file') ; return err]])
end end