mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: is_os() #10933
- Move os_name() up to "global helpers". - Rename it to is_os(). - Make it depend on uname() instead of a running Nvim instance.
This commit is contained in:
parent
9cc8064864
commit
540360a775
@ -180,7 +180,7 @@ describe('server -> client', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('recursive (child) nvim client', function()
|
describe('recursive (child) nvim client', function()
|
||||||
if helpers.isCI('travis') and helpers.os_name() == 'osx' then
|
if helpers.isCI('travis') and helpers.is_os('mac') then
|
||||||
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||||
pending("[Hangs on Travis macOS. #5002]", function() end)
|
pending("[Hangs on Travis macOS. #5002]", function() end)
|
||||||
return
|
return
|
||||||
@ -339,7 +339,7 @@ describe('server -> client', function()
|
|||||||
|
|
||||||
describe('connecting to its own pipe address', function()
|
describe('connecting to its own pipe address', function()
|
||||||
it('does not deadlock', function()
|
it('does not deadlock', function()
|
||||||
if not helpers.isCI('travis') and helpers.os_name() == 'osx' then
|
if not helpers.isCI('travis') and helpers.is_os('mac') then
|
||||||
-- It does, in fact, deadlock on QuickBuild. #6851
|
-- It does, in fact, deadlock on QuickBuild. #6851
|
||||||
pending("deadlocks on QuickBuild", function() end)
|
pending("deadlocks on QuickBuild", function() end)
|
||||||
return
|
return
|
||||||
|
@ -11,7 +11,7 @@ local iswin = helpers.iswin
|
|||||||
local meth_pcall = helpers.meth_pcall
|
local meth_pcall = helpers.meth_pcall
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
|
local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed
|
||||||
local os_name = helpers.os_name
|
local is_os = helpers.is_os
|
||||||
local parse_context = helpers.parse_context
|
local parse_context = helpers.parse_context
|
||||||
local request = helpers.request
|
local request = helpers.request
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
@ -83,7 +83,7 @@ describe('API', function()
|
|||||||
nvim('command', 'w')
|
nvim('command', 'w')
|
||||||
local f = io.open(fname)
|
local f = io.open(fname)
|
||||||
ok(f ~= nil)
|
ok(f ~= nil)
|
||||||
if os_name() == 'windows' then
|
if is_os('win') then
|
||||||
eq('testing\r\napi\r\n', f:read('*a'))
|
eq('testing\r\napi\r\n', f:read('*a'))
|
||||||
else
|
else
|
||||||
eq('testing\napi\n', f:read('*a'))
|
eq('testing\napi\n', f:read('*a'))
|
||||||
|
@ -7,7 +7,7 @@ local sleep = helpers.sleep
|
|||||||
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
|
||||||
local set_session = helpers.set_session
|
local set_session = helpers.set_session
|
||||||
local nvim_prog = helpers.nvim_prog
|
local nvim_prog = helpers.nvim_prog
|
||||||
local os_name = helpers.os_name
|
local is_os = helpers.is_os
|
||||||
local retry = helpers.retry
|
local retry = helpers.retry
|
||||||
local expect_twostreams = helpers.expect_twostreams
|
local expect_twostreams = helpers.expect_twostreams
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ describe('channels', function()
|
|||||||
command("call chansend(id, 'incomplet\004')")
|
command("call chansend(id, 'incomplet\004')")
|
||||||
|
|
||||||
local is_bsd = not not string.find(uname(), 'bsd')
|
local is_bsd = not not string.find(uname(), 'bsd')
|
||||||
local bsdlike = is_bsd or (os_name() == "osx")
|
local bsdlike = is_bsd or is_os('mac')
|
||||||
local extra = bsdlike and "^D\008\008" or ""
|
local extra = bsdlike and "^D\008\008" or ""
|
||||||
expect_twoline(id, "stdout",
|
expect_twoline(id, "stdout",
|
||||||
"incomplet"..extra, "[1, ['incomplet'], 'stdin']", true)
|
"incomplet"..extra, "[1, ['incomplet'], 'stdin']", true)
|
||||||
|
@ -206,7 +206,7 @@ describe('jobs', function()
|
|||||||
|
|
||||||
it("will not buffer data if it doesn't end in newlines", function()
|
it("will not buffer data if it doesn't end in newlines", function()
|
||||||
if helpers.isCI('travis') and os.getenv('CC') == 'gcc-4.9'
|
if helpers.isCI('travis') and os.getenv('CC') == 'gcc-4.9'
|
||||||
and helpers.os_name() == "osx" then
|
and helpers.is_os('mac') then
|
||||||
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||||
pending("[Hangs on Travis macOS. #5002]", function() end)
|
pending("[Hangs on Travis macOS. #5002]", function() end)
|
||||||
return
|
return
|
||||||
|
@ -15,6 +15,7 @@ local check_logs = global_helpers.check_logs
|
|||||||
local dedent = global_helpers.dedent
|
local dedent = global_helpers.dedent
|
||||||
local eq = global_helpers.eq
|
local eq = global_helpers.eq
|
||||||
local filter = global_helpers.filter
|
local filter = global_helpers.filter
|
||||||
|
local is_os = global_helpers.is_os
|
||||||
local map = global_helpers.map
|
local map = global_helpers.map
|
||||||
local ok = global_helpers.ok
|
local ok = global_helpers.ok
|
||||||
local sleep = global_helpers.sleep
|
local sleep = global_helpers.sleep
|
||||||
@ -271,22 +272,6 @@ function module.eval(expr)
|
|||||||
return module.request('nvim_eval', expr)
|
return module.request('nvim_eval', expr)
|
||||||
end
|
end
|
||||||
|
|
||||||
module.os_name = (function()
|
|
||||||
local name = nil
|
|
||||||
return (function()
|
|
||||||
if not name then
|
|
||||||
if module.eval('has("win32")') == 1 then
|
|
||||||
name = 'windows'
|
|
||||||
elseif module.eval('has("macunix")') == 1 then
|
|
||||||
name = 'osx'
|
|
||||||
else
|
|
||||||
name = 'unix'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return name
|
|
||||||
end)
|
|
||||||
end)()
|
|
||||||
|
|
||||||
-- Executes a VimL function.
|
-- Executes a VimL function.
|
||||||
-- Fails on VimL error, but does not update v:errmsg.
|
-- Fails on VimL error, but does not update v:errmsg.
|
||||||
function module.call(name, ...)
|
function module.call(name, ...)
|
||||||
@ -609,7 +594,7 @@ local function do_rmdir(path)
|
|||||||
-- Try Nvim delete(): it handles `readonly` attribute on Windows,
|
-- Try Nvim delete(): it handles `readonly` attribute on Windows,
|
||||||
-- and avoids Lua cross-version/platform incompatibilities.
|
-- and avoids Lua cross-version/platform incompatibilities.
|
||||||
if -1 == module.call('delete', abspath) then
|
if -1 == module.call('delete', abspath) then
|
||||||
local hint = (module.os_name() == 'windows'
|
local hint = (is_os('win')
|
||||||
and ' (hint: try :%bwipeout! before rmdir())' or '')
|
and ' (hint: try :%bwipeout! before rmdir())' or '')
|
||||||
error('delete() failed'..hint..': '..abspath)
|
error('delete() failed'..hint..': '..abspath)
|
||||||
end
|
end
|
||||||
@ -626,7 +611,7 @@ end
|
|||||||
|
|
||||||
function module.rmdir(path)
|
function module.rmdir(path)
|
||||||
local ret, _ = pcall(do_rmdir, path)
|
local ret, _ = pcall(do_rmdir, path)
|
||||||
if not ret and module.os_name() == "windows" then
|
if not ret and is_os('win') then
|
||||||
-- Maybe "Permission denied"; try again after changing the nvim
|
-- Maybe "Permission denied"; try again after changing the nvim
|
||||||
-- process to the top-level directory.
|
-- process to the top-level directory.
|
||||||
module.command([[exe 'cd '.fnameescape(']]..start_dir.."')")
|
module.command([[exe 'cd '.fnameescape(']]..start_dir.."')")
|
||||||
|
@ -21,7 +21,7 @@ describe('Test getting and setting file permissions', function()
|
|||||||
eq(9, call('len', call('getfperm', tempfile)))
|
eq(9, call('len', call('getfperm', tempfile)))
|
||||||
|
|
||||||
eq(1, call('setfperm', tempfile, 'rwx------'))
|
eq(1, call('setfperm', tempfile, 'rwx------'))
|
||||||
if helpers.os_name() == 'windows' then
|
if helpers.is_os('win') then
|
||||||
eq('rw-rw-rw-', call('getfperm', tempfile))
|
eq('rw-rw-rw-', call('getfperm', tempfile))
|
||||||
else
|
else
|
||||||
eq('rwx------', call('getfperm', tempfile))
|
eq('rwx------', call('getfperm', tempfile))
|
||||||
|
@ -190,6 +190,15 @@ module.uname = (function()
|
|||||||
end)
|
end)
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
|
function module.is_os(s)
|
||||||
|
if not (s == 'win' or s == 'mac' or s == 'unix') then
|
||||||
|
error('unknown platform: '..tostring(s))
|
||||||
|
end
|
||||||
|
return ((s == 'win' and module.iswin())
|
||||||
|
or (s == 'mac' and module.uname() == 'darwin')
|
||||||
|
or (s == 'unix'))
|
||||||
|
end
|
||||||
|
|
||||||
local function tmpdir_get()
|
local function tmpdir_get()
|
||||||
return os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
|
return os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user