test/uname(): always lowercase

This commit is contained in:
Justin M. Keyes
2019-09-01 21:21:26 -07:00
parent 7d20907724
commit ead39d6ce6
7 changed files with 26 additions and 24 deletions

View File

@@ -139,7 +139,7 @@ describe('channels', function()
command("call chansend(id, 'incomplet\004')") command("call chansend(id, 'incomplet\004')")
local is_bsd = not not string.find(string.lower(uname()), 'bsd') local is_bsd = not not string.find(uname(), 'bsd')
local bsdlike = is_bsd or (os_name() == "osx") local bsdlike = is_bsd or (os_name() == "osx")
local extra = bsdlike and "^D\008\008" or "" local extra = bsdlike and "^D\008\008" or ""
expect_twoline(id, "stdout", expect_twoline(id, "stdout",

View File

@@ -48,7 +48,7 @@ if module.nvim_dir == module.nvim_prog then
end end
local tmpname = global_helpers.tmpname local tmpname = global_helpers.tmpname
local uname = global_helpers.uname local iswin = global_helpers.iswin
local prepend_argv local prepend_argv
if os.getenv('VALGRIND') then if os.getenv('VALGRIND') then
@@ -287,10 +287,6 @@ module.os_name = (function()
end) end)
end)() end)()
function module.iswin()
return package.config:sub(1,1) == '\\'
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, ...)
@@ -672,7 +668,7 @@ end
-- Helper to skip tests. Returns true in Windows systems. -- Helper to skip tests. Returns true in Windows systems.
-- pending_fn is pending() from busted -- pending_fn is pending() from busted
function module.pending_win32(pending_fn) function module.pending_win32(pending_fn)
if uname() == 'Windows' then if iswin() then
if pending_fn ~= nil then if pending_fn ~= nil then
pending_fn('FIXME: Windows', function() end) pending_fn('FIXME: Windows', function() end)
end end
@@ -734,12 +730,12 @@ function module.redir_exec(cmd)
end end
function module.get_pathsep() function module.get_pathsep()
return module.iswin() and '\\' or '/' return iswin() and '\\' or '/'
end end
function module.pathroot() function module.pathroot()
local pathsep = package.config:sub(1,1) local pathsep = package.config:sub(1,1)
return module.iswin() and (module.nvim_dir:sub(1,2)..pathsep) or '/' return iswin() and (module.nvim_dir:sub(1,2)..pathsep) or '/'
end end
-- Returns a valid, platform-independent $NVIM_LISTEN_ADDRESS. -- Returns a valid, platform-independent $NVIM_LISTEN_ADDRESS.
@@ -765,7 +761,7 @@ function module.missing_provider(provider)
end end
function module.alter_slashes(obj) function module.alter_slashes(obj)
if not module.iswin() then if not iswin() then
return obj return obj
end end
if type(obj) == 'string' then if type(obj) == 'string' then

View File

@@ -902,7 +902,7 @@ end)
-- does not initialize the TUI. -- does not initialize the TUI.
describe("TUI 't_Co' (terminal colors)", function() describe("TUI 't_Co' (terminal colors)", function()
local screen local screen
local is_freebsd = (string.lower(uname()) == 'freebsd') local is_freebsd = (uname() == 'freebsd')
local function assert_term_colors(term, colorterm, maxcolors) local function assert_term_colors(term, colorterm, maxcolors)
helpers.clear({env={TERM=term}, args={}}) helpers.clear({env={TERM=term}, args={}})
@@ -1176,8 +1176,8 @@ end)
-- does not initialize the TUI. -- does not initialize the TUI.
describe("TUI 'term' option", function() describe("TUI 'term' option", function()
local screen local screen
local is_bsd = not not string.find(string.lower(uname()), 'bsd') local is_bsd = not not string.find(uname(), 'bsd')
local is_macos = not not string.find(string.lower(uname()), 'darwin') local is_macos = not not string.find(uname(), 'darwin')
local function assert_term(term_envvar, term_expected) local function assert_term(term_envvar, term_expected)
clear() clear()
@@ -1203,7 +1203,7 @@ describe("TUI 'term' option", function()
end) end)
it('gets system-provided term if $TERM is valid', function() it('gets system-provided term if $TERM is valid', function()
if string.lower(uname()) == "openbsd" then if uname() == "openbsd" then
assert_term("xterm", "xterm") assert_term("xterm", "xterm")
elseif is_bsd then -- BSD lacks terminfo, builtin is always used. elseif is_bsd then -- BSD lacks terminfo, builtin is always used.
assert_term("xterm", "builtin_xterm") assert_term("xterm", "builtin_xterm")

View File

@@ -828,7 +828,7 @@ describe('cmdline redraw', function()
end) end)
it('with <Cmd>', function() it('with <Cmd>', function()
if 'openbsd' == string.lower(helpers.uname()) then if 'openbsd' == helpers.uname() then
pending('FIXME #10804', function() end) pending('FIXME #10804', function() end)
return return
end end

View File

@@ -49,7 +49,7 @@ local function test_embed(ext_linegrid)
end) end)
it("doesn't erase output when setting color scheme", function() it("doesn't erase output when setting color scheme", function()
if 'openbsd' == string.lower(helpers.uname()) then if 'openbsd' == helpers.uname() then
pending('FIXME #10804', function() end) pending('FIXME #10804', function() end)
return return
end end

View File

@@ -50,7 +50,7 @@ describe("shell command :!", function()
end) end)
it("throttles shell-command output greater than ~10KB", function() it("throttles shell-command output greater than ~10KB", function()
if 'openbsd' == string.lower(helpers.uname()) then if 'openbsd' == helpers.uname() then
pending('FIXME #10804', function() end) pending('FIXME #10804', function() end)
return return
end end

View File

@@ -158,7 +158,11 @@ function module.check_logs()
table.concat(runtime_errors, ', '))) table.concat(runtime_errors, ', ')))
end end
-- Tries to get platform name from $SYSTEM_NAME, uname; fallback is "Windows". function module.iswin()
return package.config:sub(1,1) == '\\'
end
-- Gets (lowercase) OS name from CMake, uname, or "win" if iswin().
module.uname = (function() module.uname = (function()
local platform = nil local platform = nil
return (function() return (function()
@@ -166,17 +170,19 @@ module.uname = (function()
return platform return platform
end end
platform = os.getenv("SYSTEM_NAME") if os.getenv("SYSTEM_NAME") then -- From CMAKE_SYSTEM_NAME.
if platform then platform = string.lower(os.getenv("SYSTEM_NAME"))
return platform return platform
end end
local status, f = pcall(module.popen_r, 'uname', '-s') local status, f = pcall(module.popen_r, 'uname', '-s')
if status then if status then
platform = f:read("*l") platform = string.lower(f:read("*l"))
f:close() f:close()
elseif module.iswin() then
platform = 'windows'
else else
platform = 'Windows' error('unknown platform')
end end
return platform return platform
end) end)
@@ -203,11 +209,11 @@ module.tmpname = (function()
return fname return fname
else else
local fname = os.tmpname() local fname = os.tmpname()
if module.uname() == 'Windows' and fname:sub(1, 2) == '\\s' then if module.uname() == 'windows' and fname:sub(1, 2) == '\\s' then
-- In Windows tmpname() returns a filename starting with -- In Windows tmpname() returns a filename starting with
-- special sequence \s, prepend $TEMP path -- special sequence \s, prepend $TEMP path
return tmpdir..fname return tmpdir..fname
elseif fname:match('^/tmp') and module.uname() == 'Darwin' then elseif fname:match('^/tmp') and module.uname() == 'darwin' then
-- In OS X /tmp links to /private/tmp -- In OS X /tmp links to /private/tmp
return '/private'..fname return '/private'..fname
else else