mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
refactor: format test/*
This commit is contained in:
@ -4,7 +4,8 @@ local exec_lua = helpers.exec_lua
|
||||
local eq = helpers.eq
|
||||
|
||||
local function system_sync(cmd, opts)
|
||||
return exec_lua([[
|
||||
return exec_lua(
|
||||
[[
|
||||
local cmd, opts = ...
|
||||
local obj = vim.system(...)
|
||||
|
||||
@ -21,11 +22,15 @@ local function system_sync(cmd, opts)
|
||||
assert(not proc, 'process still exists')
|
||||
|
||||
return res
|
||||
]], cmd, opts)
|
||||
]],
|
||||
cmd,
|
||||
opts
|
||||
)
|
||||
end
|
||||
|
||||
local function system_async(cmd, opts)
|
||||
return exec_lua([[
|
||||
return exec_lua(
|
||||
[[
|
||||
local cmd, opts = ...
|
||||
_G.done = false
|
||||
local obj = vim.system(cmd, opts, function(obj)
|
||||
@ -44,7 +49,10 @@ local function system_async(cmd, opts)
|
||||
assert(not proc, 'process still exists')
|
||||
|
||||
return _G.ret
|
||||
]], cmd, opts)
|
||||
]],
|
||||
cmd,
|
||||
opts
|
||||
)
|
||||
end
|
||||
|
||||
describe('vim.system', function()
|
||||
@ -52,10 +60,10 @@ describe('vim.system', function()
|
||||
clear()
|
||||
end)
|
||||
|
||||
for name, system in pairs{ sync = system_sync, async = system_async, } do
|
||||
describe('('..name..')', function()
|
||||
for name, system in pairs { sync = system_sync, async = system_async } do
|
||||
describe('(' .. name .. ')', function()
|
||||
it('can run simple commands', function()
|
||||
eq('hello\n', system({'echo', 'hello' }, { text = true }).stdout)
|
||||
eq('hello\n', system({ 'echo', 'hello' }, { text = true }).stdout)
|
||||
end)
|
||||
|
||||
it('handle input', function()
|
||||
@ -67,7 +75,7 @@ describe('vim.system', function()
|
||||
code = 124,
|
||||
signal = 15,
|
||||
stdout = '',
|
||||
stderr = ''
|
||||
stderr = '',
|
||||
}, system({ 'sleep', '10' }, { timeout = 1000 }))
|
||||
end)
|
||||
end)
|
||||
@ -96,5 +104,4 @@ describe('vim.system', function()
|
||||
assert(signal == 2)
|
||||
]])
|
||||
end)
|
||||
|
||||
end)
|
||||
|
Reference in New Issue
Block a user