mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: simplify platform detection (#21020)
Extend the capabilities of is_os to detect more platforms such as
freebsd and openbsd. Also remove `iswin()` helper function as it can be
replaced by `is_os("win")`.
This commit is contained in:
@@ -3,12 +3,12 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear = helpers.clear
|
||||
local eq = helpers.eq
|
||||
local funcs = helpers.funcs
|
||||
local iswin = helpers.iswin
|
||||
local neq = helpers.neq
|
||||
local nvim_argv = helpers.nvim_argv
|
||||
local request = helpers.request
|
||||
local retry = helpers.retry
|
||||
local NIL = helpers.NIL
|
||||
local is_os = helpers.is_os
|
||||
|
||||
describe('API', function()
|
||||
before_each(clear)
|
||||
@@ -62,7 +62,7 @@ describe('API', function()
|
||||
it('returns process info', function()
|
||||
local pid = funcs.getpid()
|
||||
local pinfo = request('nvim_get_proc', pid)
|
||||
eq((iswin() and 'nvim.exe' or 'nvim'), pinfo.name)
|
||||
eq((is_os('win') and 'nvim.exe' or 'nvim'), pinfo.name)
|
||||
eq(pid, pinfo.pid)
|
||||
eq('number', type(pinfo.ppid))
|
||||
neq(pid, pinfo.ppid)
|
||||
|
||||
@@ -5,7 +5,7 @@ local eq, clear, eval, command, nvim, next_msg =
|
||||
local meths = helpers.meths
|
||||
local exec_lua = helpers.exec_lua
|
||||
local retry = helpers.retry
|
||||
local isCI = helpers.isCI
|
||||
local is_ci = helpers.is_ci
|
||||
local assert_alive = helpers.assert_alive
|
||||
local skip = helpers.skip
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('notify', function()
|
||||
end)
|
||||
|
||||
it('cancels stale events on channel close', function()
|
||||
skip(isCI(), 'hangs on CI #14083 #15251')
|
||||
skip(is_ci(), 'hangs on CI #14083 #15251')
|
||||
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
|
||||
local catpath = eval('exepath("cat")')
|
||||
eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[
|
||||
|
||||
@@ -250,7 +250,7 @@ describe('server -> client', function()
|
||||
pcall(funcs.jobstop, jobid)
|
||||
end)
|
||||
|
||||
if helpers.skip(helpers.iswin()) then return end
|
||||
if helpers.skip(helpers.is_os('win')) then return end
|
||||
|
||||
it('rpc and text stderr can be combined', function()
|
||||
local status, rv = pcall(funcs.rpcrequest, jobid, 'poll')
|
||||
|
||||
@@ -12,7 +12,6 @@ local exec = helpers.exec
|
||||
local eval = helpers.eval
|
||||
local expect = helpers.expect
|
||||
local funcs = helpers.funcs
|
||||
local iswin = helpers.iswin
|
||||
local meths = helpers.meths
|
||||
local matches = helpers.matches
|
||||
local pesc = helpers.pesc
|
||||
@@ -400,7 +399,7 @@ describe('API', function()
|
||||
end)
|
||||
|
||||
it('returns shell |:!| output', function()
|
||||
local win_lf = iswin() and '\r' or ''
|
||||
local win_lf = is_os('win') and '\r' or ''
|
||||
eq(':!echo foo\r\n\nfoo'..win_lf..'\n', nvim('command_output', [[!echo foo]]))
|
||||
end)
|
||||
|
||||
@@ -2125,7 +2124,7 @@ describe('API', function()
|
||||
pty='?',
|
||||
}
|
||||
local event = meths.get_var("opened_event")
|
||||
if not iswin() then
|
||||
if not is_os('win') then
|
||||
info.pty = event.info.pty
|
||||
neq(nil, string.match(info.pty, "^/dev/"))
|
||||
end
|
||||
@@ -2141,7 +2140,7 @@ describe('API', function()
|
||||
stream = 'job',
|
||||
id = 4,
|
||||
argv = (
|
||||
iswin() and {
|
||||
is_os('win') and {
|
||||
eval('&shell'),
|
||||
'/s',
|
||||
'/c',
|
||||
@@ -2163,7 +2162,7 @@ describe('API', function()
|
||||
-- :terminal with args + stopped process.
|
||||
eq(1, eval('jobstop(&channel)'))
|
||||
eval('jobwait([&channel], 1000)') -- Wait.
|
||||
expected2.pty = (iswin() and '?' or '') -- pty stream was closed.
|
||||
expected2.pty = (is_os('win') and '?' or '') -- pty stream was closed.
|
||||
eq(expected2, eval('nvim_get_chan_info(&channel)'))
|
||||
end)
|
||||
end)
|
||||
@@ -2724,7 +2723,7 @@ describe('API', function()
|
||||
eq({}, meths.get_runtime_file("foobarlang/", true))
|
||||
end)
|
||||
it('can handle bad patterns', function()
|
||||
skip(iswin())
|
||||
skip(is_os('win'))
|
||||
|
||||
eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user