aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-04 06:58:04 -0700
committerGitHub <noreply@github.com>2019-09-04 06:58:04 -0700
commit540360a775a62db5c2722bfd89b6aa91b577d945 (patch)
tree9c0d0f5a95da8151468a26964dc2a36b586aa7bc
parent9cc8064864374cf85c4273299d42094e3c687941 (diff)
downloadrneovim-540360a775a62db5c2722bfd89b6aa91b577d945.tar.gz
rneovim-540360a775a62db5c2722bfd89b6aa91b577d945.tar.bz2
rneovim-540360a775a62db5c2722bfd89b6aa91b577d945.zip
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.
-rw-r--r--test/functional/api/server_requests_spec.lua4
-rw-r--r--test/functional/api/vim_spec.lua4
-rw-r--r--test/functional/core/channels_spec.lua4
-rw-r--r--test/functional/core/job_spec.lua2
-rw-r--r--test/functional/helpers.lua21
-rw-r--r--test/functional/legacy/file_perm_spec.lua2
-rw-r--r--test/helpers.lua9
7 files changed, 20 insertions, 26 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index ddd044a10f..a20667de40 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -180,7 +180,7 @@ describe('server -> client', function()
end)
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.
pending("[Hangs on Travis macOS. #5002]", function() end)
return
@@ -339,7 +339,7 @@ describe('server -> client', function()
describe('connecting to its own pipe address', 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
pending("deadlocks on QuickBuild", function() end)
return
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 07c0c5c8f3..b80b1c87af 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -11,7 +11,7 @@ local iswin = helpers.iswin
local meth_pcall = helpers.meth_pcall
local meths = helpers.meths
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 request = helpers.request
local source = helpers.source
@@ -83,7 +83,7 @@ describe('API', function()
nvim('command', 'w')
local f = io.open(fname)
ok(f ~= nil)
- if os_name() == 'windows' then
+ if is_os('win') then
eq('testing\r\napi\r\n', f:read('*a'))
else
eq('testing\napi\n', f:read('*a'))
diff --git a/test/functional/core/channels_spec.lua b/test/functional/core/channels_spec.lua
index 852d9808f5..1ef34c7318 100644
--- a/test/functional/core/channels_spec.lua
+++ b/test/functional/core/channels_spec.lua
@@ -7,7 +7,7 @@ local sleep = helpers.sleep
local spawn, nvim_argv = helpers.spawn, helpers.nvim_argv
local set_session = helpers.set_session
local nvim_prog = helpers.nvim_prog
-local os_name = helpers.os_name
+local is_os = helpers.is_os
local retry = helpers.retry
local expect_twostreams = helpers.expect_twostreams
@@ -140,7 +140,7 @@ describe('channels', function()
command("call chansend(id, 'incomplet\004')")
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 ""
expect_twoline(id, "stdout",
"incomplet"..extra, "[1, ['incomplet'], 'stdin']", true)
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 88951e5b51..94b34ef05b 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -206,7 +206,7 @@ describe('jobs', 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'
- and helpers.os_name() == "osx" then
+ and helpers.is_os('mac') then
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
pending("[Hangs on Travis macOS. #5002]", function() end)
return
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index c34849b439..cf9f5f9858 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -15,6 +15,7 @@ local check_logs = global_helpers.check_logs
local dedent = global_helpers.dedent
local eq = global_helpers.eq
local filter = global_helpers.filter
+local is_os = global_helpers.is_os
local map = global_helpers.map
local ok = global_helpers.ok
local sleep = global_helpers.sleep
@@ -271,22 +272,6 @@ function module.eval(expr)
return module.request('nvim_eval', expr)
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.
-- Fails on VimL error, but does not update v:errmsg.
function module.call(name, ...)
@@ -609,7 +594,7 @@ local function do_rmdir(path)
-- Try Nvim delete(): it handles `readonly` attribute on Windows,
-- and avoids Lua cross-version/platform incompatibilities.
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 '')
error('delete() failed'..hint..': '..abspath)
end
@@ -626,7 +611,7 @@ end
function module.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
-- process to the top-level directory.
module.command([[exe 'cd '.fnameescape(']]..start_dir.."')")
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua
index d61fdc9b83..8fdee95e91 100644
--- a/test/functional/legacy/file_perm_spec.lua
+++ b/test/functional/legacy/file_perm_spec.lua
@@ -21,7 +21,7 @@ describe('Test getting and setting file permissions', function()
eq(9, call('len', call('getfperm', tempfile)))
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))
else
eq('rwx------', call('getfperm', tempfile))
diff --git a/test/helpers.lua b/test/helpers.lua
index 779d33e3b1..c2a708197f 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -190,6 +190,15 @@ module.uname = (function()
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()
return os.getenv('TMPDIR') and os.getenv('TMPDIR') or os.getenv('TEMP')
end