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:
dundargoc 2022-11-22 01:13:30 +01:00 committed by GitHub
parent 7c10774860
commit 5eb5f49488
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
74 changed files with 346 additions and 347 deletions

View File

@ -3,12 +3,12 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear local clear = helpers.clear
local eq = helpers.eq local eq = helpers.eq
local funcs = helpers.funcs local funcs = helpers.funcs
local iswin = helpers.iswin
local neq = helpers.neq local neq = helpers.neq
local nvim_argv = helpers.nvim_argv local nvim_argv = helpers.nvim_argv
local request = helpers.request local request = helpers.request
local retry = helpers.retry local retry = helpers.retry
local NIL = helpers.NIL local NIL = helpers.NIL
local is_os = helpers.is_os
describe('API', function() describe('API', function()
before_each(clear) before_each(clear)
@ -62,7 +62,7 @@ describe('API', function()
it('returns process info', function() it('returns process info', function()
local pid = funcs.getpid() local pid = funcs.getpid()
local pinfo = request('nvim_get_proc', pid) 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(pid, pinfo.pid)
eq('number', type(pinfo.ppid)) eq('number', type(pinfo.ppid))
neq(pid, pinfo.ppid) neq(pid, pinfo.ppid)

View File

@ -5,7 +5,7 @@ local eq, clear, eval, command, nvim, next_msg =
local meths = helpers.meths local meths = helpers.meths
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local retry = helpers.retry local retry = helpers.retry
local isCI = helpers.isCI local is_ci = helpers.is_ci
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local skip = helpers.skip local skip = helpers.skip
@ -79,7 +79,7 @@ describe('notify', function()
end) end)
it('cancels stale events on channel close', function() 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 catchan = eval("jobstart(['cat'], {'rpc': v:true})")
local catpath = eval('exepath("cat")') local catpath = eval('exepath("cat")')
eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[ eq({id=catchan, argv={catpath}, stream='job', mode='rpc', client = {}}, exec_lua ([[

View File

@ -250,7 +250,7 @@ describe('server -> client', function()
pcall(funcs.jobstop, jobid) pcall(funcs.jobstop, jobid)
end) 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() it('rpc and text stderr can be combined', function()
local status, rv = pcall(funcs.rpcrequest, jobid, 'poll') local status, rv = pcall(funcs.rpcrequest, jobid, 'poll')

View File

@ -12,7 +12,6 @@ local exec = helpers.exec
local eval = helpers.eval local eval = helpers.eval
local expect = helpers.expect local expect = helpers.expect
local funcs = helpers.funcs local funcs = helpers.funcs
local iswin = helpers.iswin
local meths = helpers.meths local meths = helpers.meths
local matches = helpers.matches local matches = helpers.matches
local pesc = helpers.pesc local pesc = helpers.pesc
@ -400,7 +399,7 @@ describe('API', function()
end) end)
it('returns shell |:!| output', function() 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]])) eq(':!echo foo\r\n\nfoo'..win_lf..'\n', nvim('command_output', [[!echo foo]]))
end) end)
@ -2125,7 +2124,7 @@ describe('API', function()
pty='?', pty='?',
} }
local event = meths.get_var("opened_event") local event = meths.get_var("opened_event")
if not iswin() then if not is_os('win') then
info.pty = event.info.pty info.pty = event.info.pty
neq(nil, string.match(info.pty, "^/dev/")) neq(nil, string.match(info.pty, "^/dev/"))
end end
@ -2141,7 +2140,7 @@ describe('API', function()
stream = 'job', stream = 'job',
id = 4, id = 4,
argv = ( argv = (
iswin() and { is_os('win') and {
eval('&shell'), eval('&shell'),
'/s', '/s',
'/c', '/c',
@ -2163,7 +2162,7 @@ describe('API', function()
-- :terminal with args + stopped process. -- :terminal with args + stopped process.
eq(1, eval('jobstop(&channel)')) eq(1, eval('jobstop(&channel)'))
eval('jobwait([&channel], 1000)') -- Wait. 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)')) eq(expected2, eval('nvim_get_chan_info(&channel)'))
end) end)
end) end)
@ -2724,7 +2723,7 @@ describe('API', function()
eq({}, meths.get_runtime_file("foobarlang/", true)) eq({}, meths.get_runtime_file("foobarlang/", true))
end) end)
it('can handle bad patterns', function() it('can handle bad patterns', function()
skip(iswin()) skip(is_os('win'))
eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false)) eq("Vim:E220: Missing }.", pcall_err(meths.get_runtime_file, "{", false))

View File

@ -1,12 +1,12 @@
local lfs = require('lfs') local lfs = require('lfs')
local h = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local clear = h.clear local clear = helpers.clear
local command = h.command local command = helpers.command
local eq = h.eq local eq = helpers.eq
local eval = h.eval local eval = helpers.eval
local request = h.request local request = helpers.request
local iswin = h.iswin local is_os = helpers.is_os
describe('autocmd DirChanged and DirChangedPre', function() describe('autocmd DirChanged and DirChangedPre', function()
local curdir = string.gsub(lfs.currentdir(), '\\', '/') local curdir = string.gsub(lfs.currentdir(), '\\', '/')
@ -21,8 +21,8 @@ describe('autocmd DirChanged and DirChangedPre', function()
curdir .. '\\XTEST-FUNCTIONAL-AUTOCMD-DIRCHANGED.DIR3', curdir .. '\\XTEST-FUNCTIONAL-AUTOCMD-DIRCHANGED.DIR3',
} }
setup(function() for _, dir in pairs(dirs) do h.mkdir(dir) end end) setup(function() for _, dir in pairs(dirs) do helpers.mkdir(dir) end end)
teardown(function() for _, dir in pairs(dirs) do h.rmdir(dir) end end) teardown(function() for _, dir in pairs(dirs) do helpers.rmdir(dir) end end)
before_each(function() before_each(function()
clear() clear()
@ -159,7 +159,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(1, eval('g:cdprecount')) eq(1, eval('g:cdprecount'))
eq(1, eval('g:cdcount')) eq(1, eval('g:cdcount'))
if iswin() then if is_os('win') then
command('lcd '..win_dirs[1]) command('lcd '..win_dirs[1])
eq({}, eval('g:evpre')) eq({}, eval('g:evpre'))
eq({}, eval('g:ev')) eq({}, eval('g:ev'))
@ -182,7 +182,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(2, eval('g:cdprecount')) eq(2, eval('g:cdprecount'))
eq(2, eval('g:cdcount')) eq(2, eval('g:cdcount'))
if iswin() then if is_os('win') then
command('tcd '..win_dirs[2]) command('tcd '..win_dirs[2])
eq({}, eval('g:evpre')) eq({}, eval('g:evpre'))
eq({}, eval('g:ev')) eq({}, eval('g:ev'))
@ -204,7 +204,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(3, eval('g:cdprecount')) eq(3, eval('g:cdprecount'))
eq(3, eval('g:cdcount')) eq(3, eval('g:cdcount'))
if iswin() then if is_os('win') then
command('cd '..win_dirs[3]) command('cd '..win_dirs[3])
eq({}, eval('g:evpre')) eq({}, eval('g:evpre'))
eq({}, eval('g:ev')) eq({}, eval('g:ev'))
@ -229,7 +229,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(4, eval('g:cdprecount')) eq(4, eval('g:cdprecount'))
eq(4, eval('g:cdcount')) eq(4, eval('g:cdcount'))
if iswin() then if is_os('win') then
command('split '..win_dirs[1]..'/baz') command('split '..win_dirs[1]..'/baz')
eq({}, eval('g:evpre')) eq({}, eval('g:evpre'))
eq({}, eval('g:ev')) eq({}, eval('g:ev'))
@ -278,7 +278,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
eq(9, eval('g:cdprecount')) -- same CWD, no DirChangedPre event eq(9, eval('g:cdprecount')) -- same CWD, no DirChangedPre event
eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event
if iswin() then if is_os('win') then
command('tabnew') -- tab 3 command('tabnew') -- tab 3
eq(9, eval('g:cdprecount')) -- same CWD, no DirChangedPre event eq(9, eval('g:cdprecount')) -- same CWD, no DirChangedPre event
eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event eq(9, eval('g:cdcount')) -- same CWD, no DirChanged event

View File

@ -6,7 +6,7 @@ local nvim_prog = helpers.nvim_prog
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local feed_data = thelpers.feed_data local feed_data = thelpers.feed_data
if helpers.skip(helpers.iswin()) then return end if helpers.skip(helpers.is_os('win')) then return end
describe('autoread TUI FocusGained/FocusLost', function() describe('autoread TUI FocusGained/FocusLost', function()
local f1 = 'xtest-foo' local f1 = 'xtest-foo'

View File

@ -5,10 +5,10 @@ local command = helpers.command
local eq = helpers.eq local eq = helpers.eq
local funcs = helpers.funcs local funcs = helpers.funcs
local next_msg = helpers.next_msg local next_msg = helpers.next_msg
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
if skip(iswin(), 'Only applies to POSIX systems') then return end if skip(is_os('win'), 'Only applies to POSIX systems') then return end
local function posix_kill(signame, pid) local function posix_kill(signame, pid)
os.execute('kill -s '..signame..' -- '..pid..' >/dev/null') os.execute('kill -s '..signame..' -- '..pid..' >/dev/null')

View File

@ -10,8 +10,8 @@ local ok = helpers.ok
local feed = helpers.feed local feed = helpers.feed
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local iswin = helpers.iswin
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe('autocmd TermClose', function() describe('autocmd TermClose', function()
before_each(function() before_each(function()
@ -48,7 +48,7 @@ describe('autocmd TermClose', function()
end) end)
it('triggers when long-running terminal job gets stopped', function() it('triggers when long-running terminal job gets stopped', function()
nvim('set_option', 'shell', iswin() and 'cmd.exe' or 'sh') nvim('set_option', 'shell', is_os('win') and 'cmd.exe' or 'sh')
command('autocmd TermClose * let g:test_termclose = 23') command('autocmd TermClose * let g:test_termclose = 23')
command('terminal') command('terminal')
command('call jobstop(b:terminal_job_id)') command('call jobstop(b:terminal_job_id)')
@ -56,7 +56,7 @@ describe('autocmd TermClose', function()
end) end)
it('kills job trapping SIGTERM', function() it('kills job trapping SIGTERM', function()
skip(iswin()) skip(is_os('win'))
nvim('set_option', 'shell', 'sh') nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c') nvim('set_option', 'shellcmdflag', '-c')
command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]] command([[ let g:test_job = jobstart('trap "" TERM && echo 1 && sleep 60', { ]]
@ -76,7 +76,7 @@ describe('autocmd TermClose', function()
end) end)
it('kills PTY job trapping SIGHUP and SIGTERM', function() it('kills PTY job trapping SIGHUP and SIGTERM', function()
skip(iswin()) skip(is_os('win'))
nvim('set_option', 'shell', 'sh') nvim('set_option', 'shell', 'sh')
nvim('set_option', 'shellcmdflag', '-c') nvim('set_option', 'shellcmdflag', '-c')
command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]] command([[ let g:test_job = jobstart('trap "" HUP TERM && echo 1 && sleep 60', { ]]

View File

@ -1,5 +1,4 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local uname = helpers.uname
local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq, local clear, eq, eval, next_msg, ok, source = helpers.clear, helpers.eq,
helpers.eval, helpers.next_msg, helpers.ok, helpers.source helpers.eval, helpers.next_msg, helpers.ok, helpers.source
local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths local command, funcs, meths = helpers.command, helpers.funcs, helpers.meths
@ -12,7 +11,6 @@ local retry = helpers.retry
local expect_twostreams = helpers.expect_twostreams local expect_twostreams = helpers.expect_twostreams
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local iswin = helpers.iswin
local skip = helpers.skip local skip = helpers.skip
describe('channels', function() describe('channels', function()
@ -147,7 +145,7 @@ describe('channels', function()
end end
it('can use stdio channel with pty', function() it('can use stdio channel with pty', function()
skip(iswin()) skip(is_os('win'))
source([[ source([[
let g:job_opts = { let g:job_opts = {
\ 'on_stdout': function('OnEvent'), \ 'on_stdout': function('OnEvent'),
@ -180,8 +178,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 bsdlike = is_os('bsd') or is_os('mac')
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)
@ -201,7 +198,7 @@ describe('channels', function()
it('stdio channel can use rpc and stderr simultaneously', function() it('stdio channel can use rpc and stderr simultaneously', function()
skip(iswin()) skip(is_os('win'))
source([[ source([[
let g:job_opts = { let g:job_opts = {
\ 'on_stderr': function('OnEvent'), \ 'on_stderr': function('OnEvent'),

View File

@ -21,14 +21,14 @@ local read_file = helpers.read_file
local tmpname = helpers.tmpname local tmpname = helpers.tmpname
local trim = helpers.trim local trim = helpers.trim
local currentdir = helpers.funcs.getcwd local currentdir = helpers.funcs.getcwd
local iswin = helpers.iswin
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local expect_exit = helpers.expect_exit local expect_exit = helpers.expect_exit
local write_file = helpers.write_file local write_file = helpers.write_file
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local isCI = helpers.isCI
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
local is_ci = helpers.is_ci
describe('fileio', function() describe('fileio', function()
before_each(function() before_each(function()
@ -90,7 +90,7 @@ describe('fileio', function()
end) end)
it('backup #9709', function() it('backup #9709', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
clear({ args={ '-i', 'Xtest_startup_shada', clear({ args={ '-i', 'Xtest_startup_shada',
'--cmd', 'set directory=Xtest_startup_swapdir' } }) '--cmd', 'set directory=Xtest_startup_swapdir' } })
@ -110,7 +110,7 @@ describe('fileio', function()
end) end)
it('backup with full path #11214', function() it('backup with full path #11214', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
clear() clear()
mkdir('Xtest_backupdir') mkdir('Xtest_backupdir')
command('set backup') command('set backup')
@ -123,7 +123,7 @@ describe('fileio', function()
-- Backup filename = fullpath, separators replaced with "%". -- Backup filename = fullpath, separators replaced with "%".
local backup_file_name = string.gsub(currentdir()..'/Xtest_startup_file1', local backup_file_name = string.gsub(currentdir()..'/Xtest_startup_file1',
iswin() and '[:/\\]' or '/', '%%') .. '~' is_os('win') and '[:/\\]' or '/', '%%') .. '~'
local foo_contents = trim(read_file('Xtest_backupdir/'..backup_file_name)) local foo_contents = trim(read_file('Xtest_backupdir/'..backup_file_name))
local foobar_contents = trim(read_file('Xtest_startup_file1')) local foobar_contents = trim(read_file('Xtest_startup_file1'))
@ -132,7 +132,7 @@ describe('fileio', function()
end) end)
it('backup symlinked files #11349', function() it('backup symlinked files #11349', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
clear() clear()
local initial_content = 'foo' local initial_content = 'foo'
@ -154,7 +154,7 @@ describe('fileio', function()
it('backup symlinked files in first avialable backupdir #11349', function() it('backup symlinked files in first avialable backupdir #11349', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
clear() clear()
local initial_content = 'foo' local initial_content = 'foo'
@ -299,7 +299,7 @@ describe('tmpdir', function()
end) end)
-- "…/nvim.<user>/" has wrong permissions: -- "…/nvim.<user>/" has wrong permissions:
skip(iswin(), 'TODO(justinmk): need setfperm/getfperm on Windows. #8244') skip(is_os('win'), 'TODO(justinmk): need setfperm/getfperm on Windows. #8244')
os.remove(testlog) os.remove(testlog)
os.remove(tmproot) os.remove(tmproot)
mkdir(tmproot) mkdir(tmproot)

View File

@ -13,7 +13,6 @@ local retry = helpers.retry
local meths = helpers.meths local meths = helpers.meths
local NIL = helpers.NIL local NIL = helpers.NIL
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = helpers.poke_eventloop
local iswin = helpers.iswin
local get_pathsep = helpers.get_pathsep local get_pathsep = helpers.get_pathsep
local pathroot = helpers.pathroot local pathroot = helpers.pathroot
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
@ -24,6 +23,7 @@ local pcall_err = helpers.pcall_err
local matches = helpers.matches local matches = helpers.matches
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe('jobs', function() describe('jobs', function()
local channel local channel
@ -56,7 +56,7 @@ describe('jobs', function()
it('must specify env option as a dict', function() it('must specify env option as a dict', function()
command("let g:job_opts.env = v:true") command("let g:job_opts.env = v:true")
local _, err = pcall(function() local _, err = pcall(function()
if iswin() then if is_os('win') then
nvim('command', "let j = jobstart('set', g:job_opts)") nvim('command', "let j = jobstart('set', g:job_opts)")
else else
nvim('command', "let j = jobstart('env', g:job_opts)") nvim('command', "let j = jobstart('env', g:job_opts)")
@ -69,7 +69,7 @@ describe('jobs', function()
nvim('command', "let $VAR = 'abc'") nvim('command', "let $VAR = 'abc'")
nvim('command', "let $TOTO = 'goodbye world'") nvim('command', "let $TOTO = 'goodbye world'")
nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}") nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}")
if iswin() then if is_os('win') then
nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]]) nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]])
else else
nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]]) nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
@ -88,12 +88,12 @@ describe('jobs', function()
end) end)
it('append environment with pty #env', function() it('append environment with pty #env', function()
skip(iswin()) skip(is_os('win'))
nvim('command', "let $VAR = 'abc'") nvim('command', "let $VAR = 'abc'")
nvim('command', "let $TOTO = 'goodbye world'") nvim('command', "let $TOTO = 'goodbye world'")
nvim('command', "let g:job_opts.pty = v:true") nvim('command', "let g:job_opts.pty = v:true")
nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}") nvim('command', "let g:job_opts.env = {'TOTO': 'hello world'}")
if iswin() then if is_os('win') then
nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]]) nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]])
else else
nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]]) nvim('command', [[call jobstart('echo $TOTO $VAR', g:job_opts)]])
@ -123,7 +123,7 @@ describe('jobs', function()
-- --
-- Rather than expecting a completely empty environment, ensure that $VAR -- Rather than expecting a completely empty environment, ensure that $VAR
-- is *not* in the environment but $TOTO is. -- is *not* in the environment but $TOTO is.
if iswin() then if is_os('win') then
nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]]) nvim('command', [[call jobstart('echo %TOTO% %VAR%', g:job_opts)]])
expect_msg_seq({ expect_msg_seq({
{'notification', 'stdout', {0, {'hello world %VAR%', ''}}} {'notification', 'stdout', {0, {'hello world %VAR%', ''}}}
@ -142,7 +142,7 @@ describe('jobs', function()
-- Since $Toto is being set in the job, it should take precedence over the -- Since $Toto is being set in the job, it should take precedence over the
-- global $TOTO on Windows -- global $TOTO on Windows
nvim('command', "let g:job_opts = {'env': {'Toto': 'def'}, 'stdout_buffered': v:true}") nvim('command', "let g:job_opts = {'env': {'Toto': 'def'}, 'stdout_buffered': v:true}")
if iswin() then if is_os('win') then
nvim('command', [[let j = jobstart('set | find /I "toto="', g:job_opts)]]) nvim('command', [[let j = jobstart('set | find /I "toto="', g:job_opts)]])
else else
nvim('command', [[let j = jobstart('env | grep -i toto=', g:job_opts)]]) nvim('command', [[let j = jobstart('env | grep -i toto=', g:job_opts)]])
@ -151,7 +151,7 @@ describe('jobs', function()
nvim('command', "let g:output = Normalize(g:job_opts.stdout)") nvim('command', "let g:output = Normalize(g:job_opts.stdout)")
local actual = eval('g:output') local actual = eval('g:output')
local expected local expected
if iswin() then if is_os('win') then
-- Toto is normalized to TOTO so we can detect duplicates, and because -- Toto is normalized to TOTO so we can detect duplicates, and because
-- Windows doesn't care about case -- Windows doesn't care about case
expected = {'TOTO=def', ''} expected = {'TOTO=def', ''}
@ -165,7 +165,7 @@ describe('jobs', function()
it('uses &shell and &shellcmdflag if passed a string', function() it('uses &shell and &shellcmdflag if passed a string', function()
nvim('command', "let $VAR = 'abc'") nvim('command', "let $VAR = 'abc'")
if iswin() then if is_os('win') then
nvim('command', "let j = jobstart('echo %VAR%', g:job_opts)") nvim('command', "let j = jobstart('echo %VAR%', g:job_opts)")
else else
nvim('command', "let j = jobstart('echo $VAR', g:job_opts)") nvim('command', "let j = jobstart('echo $VAR', g:job_opts)")
@ -177,7 +177,7 @@ describe('jobs', function()
it('changes to given / directory', function() it('changes to given / directory', function()
nvim('command', "let g:job_opts.cwd = '/'") nvim('command', "let g:job_opts.cwd = '/'")
if iswin() then if is_os('win') then
nvim('command', "let j = jobstart('cd', g:job_opts)") nvim('command', "let j = jobstart('cd', g:job_opts)")
else else
nvim('command', "let j = jobstart('pwd', g:job_opts)") nvim('command', "let j = jobstart('pwd', g:job_opts)")
@ -192,7 +192,7 @@ describe('jobs', function()
local dir = eval("resolve(tempname())"):gsub("/", get_pathsep()) local dir = eval("resolve(tempname())"):gsub("/", get_pathsep())
mkdir(dir) mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'") nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then if is_os('win') then
nvim('command', "let j = jobstart('cd', g:job_opts)") nvim('command', "let j = jobstart('cd', g:job_opts)")
else else
nvim('command', "let j = jobstart('pwd', g:job_opts)") nvim('command', "let j = jobstart('pwd', g:job_opts)")
@ -216,7 +216,7 @@ describe('jobs', function()
local dir = eval('resolve(tempname())."-bogus"') local dir = eval('resolve(tempname())."-bogus"')
local _, err = pcall(function() local _, err = pcall(function()
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'") nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then if is_os('win') then
nvim('command', "let j = jobstart('cd', g:job_opts)") nvim('command', "let j = jobstart('cd', g:job_opts)")
else else
nvim('command', "let j = jobstart('pwd', g:job_opts)") nvim('command', "let j = jobstart('pwd', g:job_opts)")
@ -226,7 +226,7 @@ describe('jobs', function()
end) end)
it('error on non-executable `cwd`', function() it('error on non-executable `cwd`', function()
skip(iswin(), 'Not applicable for Windows') skip(is_os('win'), 'Not applicable for Windows')
local dir = 'Xtest_not_executable_dir' local dir = 'Xtest_not_executable_dir'
mkdir(dir) mkdir(dir)
@ -249,7 +249,7 @@ describe('jobs', function()
end end
local executable_jobid = new_job() local executable_jobid = new_job()
local exe = iswin() and './test/functional/fixtures' or './test/functional/fixtures/non_executable.txt' local exe = is_os('win') and './test/functional/fixtures' or './test/functional/fixtures/non_executable.txt'
eq("Vim:E475: Invalid value for argument cmd: '"..exe.."' is not executable", eq("Vim:E475: Invalid value for argument cmd: '"..exe.."' is not executable",
pcall_err(eval, "jobstart(['"..exe.."'])")) pcall_err(eval, "jobstart(['"..exe.."'])"))
eq("", eval("v:errmsg")) eq("", eval("v:errmsg"))
@ -703,7 +703,7 @@ describe('jobs', function()
describe('jobwait', function() describe('jobwait', function()
before_each(function() before_each(function()
if iswin() then if is_os('win') then
helpers.set_shell_powershell() helpers.set_shell_powershell()
end end
end) end)
@ -787,7 +787,7 @@ describe('jobs', function()
feed_command('call rpcnotify(g:channel, "ready") | '.. feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '.. 'call rpcnotify(g:channel, "wait", '..
'jobwait([jobstart("'.. 'jobwait([jobstart("'..
(iswin() and 'Start-Sleep 10' or 'sleep 10').. (is_os('win') and 'Start-Sleep 10' or 'sleep 10')..
'; exit 55")]))') '; exit 55")]))')
eq({'notification', 'ready', {}}, next_msg()) eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>') feed('<c-c>')
@ -798,7 +798,7 @@ describe('jobs', function()
feed_command('call rpcnotify(g:channel, "ready") | '.. feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '.. 'call rpcnotify(g:channel, "wait", '..
'jobwait([jobstart("'.. 'jobwait([jobstart("'..
(iswin() and 'Start-Sleep 10' or 'sleep 10').. (is_os('win') and 'Start-Sleep 10' or 'sleep 10')..
'; exit 55")], 10000))') '; exit 55")], 10000))')
eq({'notification', 'ready', {}}, next_msg()) eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>') feed('<c-c>')
@ -806,7 +806,7 @@ describe('jobs', function()
end) end)
it('can be called recursively', function() it('can be called recursively', function()
skip(iswin(), "TODO: Need `cat`") skip(is_os('win'), "TODO: Need `cat`")
source([[ source([[
let g:opts = {} let g:opts = {}
let g:counter = 0 let g:counter = 0
@ -931,7 +931,7 @@ describe('jobs', function()
-- ..c.."', '-c', '"..c.."'])") -- ..c.."', '-c', '"..c.."'])")
-- Create child with several descendants. -- Create child with several descendants.
if iswin() then if is_os('win') then
source([[ source([[
function! s:formatprocs(pid, prefix) function! s:formatprocs(pid, prefix)
let result = '' let result = ''
@ -980,13 +980,13 @@ describe('jobs', function()
endfunction endfunction
]]) ]])
end end
local sleep_cmd = (iswin() local sleep_cmd = (is_os('win')
and 'ping -n 31 127.0.0.1' and 'ping -n 31 127.0.0.1'
or 'sleep 30') or 'sleep 30')
local j = eval("jobstart('"..sleep_cmd..' | '..sleep_cmd..' | '..sleep_cmd.."')") local j = eval("jobstart('"..sleep_cmd..' | '..sleep_cmd..' | '..sleep_cmd.."')")
local ppid = funcs.jobpid(j) local ppid = funcs.jobpid(j)
local children local children
if iswin() then if is_os('win') then
local status, result = pcall(retry, nil, nil, function() local status, result = pcall(retry, nil, nil, function()
children = meths.get_proc_children(ppid) children = meths.get_proc_children(ppid)
-- On Windows conhost.exe may exist, and -- On Windows conhost.exe may exist, and
@ -1007,7 +1007,7 @@ describe('jobs', function()
-- Assert that nvim_get_proc() sees the children. -- Assert that nvim_get_proc() sees the children.
for _, child_pid in ipairs(children) do for _, child_pid in ipairs(children) do
local info = meths.get_proc(child_pid) local info = meths.get_proc(child_pid)
-- eq((iswin() and 'nvim.exe' or 'nvim'), info.name) -- eq((is_os('win') and 'nvim.exe' or 'nvim'), info.name)
eq(ppid, info.ppid) eq(ppid, info.ppid)
end end
-- Kill the root of the tree. -- Kill the root of the tree.
@ -1028,7 +1028,7 @@ describe('jobs', function()
end) end)
describe('running tty-test program', function() describe('running tty-test program', function()
if skip(iswin()) then return end if skip(is_os('win')) then return end
local function next_chunk() local function next_chunk()
local rv local rv
while true do while true do
@ -1125,7 +1125,7 @@ describe("pty process teardown", function()
end) end)
it("does not prevent/delay exit. #4798 #4900", function() it("does not prevent/delay exit. #4798 #4900", function()
skip(iswin()) skip(is_os('win'))
-- Use a nested nvim (in :term) to test without --headless. -- Use a nested nvim (in :term) to test without --headless.
feed_command(":terminal '"..helpers.nvim_prog feed_command(":terminal '"..helpers.nvim_prog
.."' -u NONE -i NONE --cmd '"..nvim_set.."' " .."' -u NONE -i NONE --cmd '"..nvim_set.."' "

View File

@ -9,7 +9,7 @@ local clear = helpers.clear
local funcs = helpers.funcs local funcs = helpers.funcs
local nvim_prog_abs = helpers.nvim_prog_abs local nvim_prog_abs = helpers.nvim_prog_abs
local write_file = helpers.write_file local write_file = helpers.write_file
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
describe('Command-line option', function() describe('Command-line option', function()
@ -51,7 +51,7 @@ describe('Command-line option', function()
eq(#('100500\n'), attrs.size) eq(#('100500\n'), attrs.size)
end) end)
it('does not crash after reading from stdin in non-headless mode', function() it('does not crash after reading from stdin in non-headless mode', function()
skip(iswin()) skip(is_os('win'))
local screen = Screen.new(40, 8) local screen = Screen.new(40, 8)
screen:attach() screen:attach()
local args = { local args = {

View File

@ -3,16 +3,16 @@ local clear = helpers.clear
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local command = helpers.command local command = helpers.command
local iswin = helpers.iswin
local insert = helpers.insert local insert = helpers.insert
local feed = helpers.feed local feed = helpers.feed
local is_os = helpers.is_os
describe('path collapse', function() describe('path collapse', function()
local targetdir local targetdir
local expected_path local expected_path
local function join_path(...) local function join_path(...)
local pathsep = (iswin() and '\\' or '/') local pathsep = (is_os('win') and '\\' or '/')
return table.concat({...}, pathsep) return table.concat({...}, pathsep)
end end

View File

@ -20,11 +20,11 @@ local read_file = helpers.read_file
local retry = helpers.retry local retry = helpers.retry
local rmdir = helpers.rmdir local rmdir = helpers.rmdir
local sleep = helpers.sleep local sleep = helpers.sleep
local iswin = helpers.iswin
local startswith = helpers.startswith local startswith = helpers.startswith
local write_file = helpers.write_file local write_file = helpers.write_file
local meths = helpers.meths local meths = helpers.meths
local alter_slashes = helpers.alter_slashes local alter_slashes = helpers.alter_slashes
local is_os = helpers.is_os
local testfile = 'Xtest_startuptime' local testfile = 'Xtest_startuptime'
after_each(function() after_each(function()
@ -79,7 +79,7 @@ describe('startup', function()
it('in a TTY: has("ttyin")==1 has("ttyout")==1', function() it('in a TTY: has("ttyin")==1 has("ttyout")==1', function()
local screen = Screen.new(25, 4) local screen = Screen.new(25, 4)
screen:attach() screen:attach()
if iswin() then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
-- Running in :terminal -- Running in :terminal
@ -95,7 +95,7 @@ describe('startup', function()
]]) ]])
end) end)
it('output to pipe: has("ttyin")==1 has("ttyout")==0', function() it('output to pipe: has("ttyin")==1 has("ttyout")==0', function()
if iswin() then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
-- Running in :terminal -- Running in :terminal
@ -111,7 +111,7 @@ describe('startup', function()
end) end)
end) end)
it('input from pipe: has("ttyin")==0 has("ttyout")==1', function() it('input from pipe: has("ttyin")==0 has("ttyout")==1', function()
if iswin() then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
-- Running in :terminal -- Running in :terminal
@ -130,7 +130,7 @@ describe('startup', function()
it('input from pipe (implicit) #7679', function() it('input from pipe (implicit) #7679', function()
local screen = Screen.new(25, 4) local screen = Screen.new(25, 4)
screen:attach() screen:attach()
if iswin() then if is_os('win') then
command([[set shellcmdflag=/s\ /c shellxquote=\"]]) command([[set shellcmdflag=/s\ /c shellxquote=\"]])
end end
-- Running in :terminal -- Running in :terminal
@ -665,7 +665,7 @@ describe('runtime:', function()
end) end)
it('loads plugin/*.lua from site packages', function() it('loads plugin/*.lua from site packages', function()
local nvimdata = iswin() and "nvim-data" or "nvim" local nvimdata = is_os('win') and "nvim-data" or "nvim"
local plugin_path = table.concat({xdata, nvimdata, 'site', 'pack', 'xa', 'start', 'yb'}, pathsep) local plugin_path = table.concat({xdata, nvimdata, 'site', 'pack', 'xa', 'start', 'yb'}, pathsep)
local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep) local plugin_folder_path = table.concat({plugin_path, 'plugin'}, pathsep)
local plugin_after_path = table.concat({plugin_path, 'after', 'plugin'}, pathsep) local plugin_after_path = table.concat({plugin_path, 'after', 'plugin'}, pathsep)

View File

@ -9,8 +9,8 @@ local clear = helpers.clear
local command = helpers.command local command = helpers.command
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local pathsep = helpers.get_pathsep() local pathsep = helpers.get_pathsep()
local iswin = helpers.iswin
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
-- These directories will be created for testing -- These directories will be created for testing
local directories = { local directories = {
@ -281,7 +281,7 @@ describe("getcwd()", function ()
end) end)
it("returns empty string if working directory does not exist", function() it("returns empty string if working directory does not exist", function()
skip(iswin()) skip(is_os('win'))
command("cd "..directories.global) command("cd "..directories.global)
command("call delete('../"..directories.global.."', 'd')") command("call delete('../"..directories.global.."', 'd')")
eq("", helpers.eval("getcwd()")) eq("", helpers.eval("getcwd()"))

View File

@ -5,7 +5,6 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = helpers.clear
local command = helpers.command local command = helpers.command
local get_pathsep = helpers.get_pathsep local get_pathsep = helpers.get_pathsep
local iswin = helpers.iswin
local eq = helpers.eq local eq = helpers.eq
local neq = helpers.neq local neq = helpers.neq
local funcs = helpers.funcs local funcs = helpers.funcs
@ -15,6 +14,7 @@ local rmdir = helpers.rmdir
local sleep = helpers.sleep local sleep = helpers.sleep
local meths = helpers.meths local meths = helpers.meths
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
@ -178,7 +178,7 @@ describe(':mksession', function()
command('cd ' .. cwd_dir) command('cd ' .. cwd_dir)
command('mksession ' .. session_path) command('mksession ' .. session_path)
command('%bwipeout!') command('%bwipeout!')
if iswin() then if is_os('win') then
sleep(100) -- Make sure all child processes have exited. sleep(100) -- Make sure all child processes have exited.
end end
@ -189,13 +189,13 @@ describe(':mksession', function()
local expected_cwd = cwd_dir .. '/' .. tab_dir local expected_cwd = cwd_dir .. '/' .. tab_dir
matches('^term://' .. pesc(expected_cwd) .. '//%d+:', funcs.expand('%')) matches('^term://' .. pesc(expected_cwd) .. '//%d+:', funcs.expand('%'))
command('%bwipeout!') command('%bwipeout!')
if iswin() then if is_os('win') then
sleep(100) -- Make sure all child processes have exited. sleep(100) -- Make sure all child processes have exited.
end end
end) end)
it('restores CWD for :terminal buffer at root directory #16988', function() it('restores CWD for :terminal buffer at root directory #16988', function()
skip(iswin(), 'N/A for Windows') skip(is_os('win'), 'N/A for Windows')
local screen local screen
local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') local cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '')

View File

@ -14,9 +14,9 @@ local eval = helpers.eval
local exec_capture = helpers.exec_capture local exec_capture = helpers.exec_capture
local neq = helpers.neq local neq = helpers.neq
local matches = helpers.matches local matches = helpers.matches
local iswin = helpers.iswin
local mkdir = helpers.mkdir local mkdir = helpers.mkdir
local rmdir = helpers.rmdir local rmdir = helpers.rmdir
local is_os = helpers.is_os
describe(':source', function() describe(':source', function()
before_each(function() before_each(function()
@ -44,7 +44,7 @@ describe(':source', function()
end) end)
it("changing 'shellslash' changes the result of expand()", function() it("changing 'shellslash' changes the result of expand()", function()
if not iswin() then if not is_os('win') then
pending("'shellslash' only works on Windows") pending("'shellslash' only works on Windows")
return return
end end

View File

@ -8,9 +8,9 @@ local command = helpers.command
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local funcs = helpers.funcs local funcs = helpers.funcs
local meths = helpers.meths local meths = helpers.meths
local iswin = helpers.iswin
local isCI = helpers.isCI
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
local is_ci = helpers.is_ci
local fname = 'Xtest-functional-ex_cmds-write' local fname = 'Xtest-functional-ex_cmds-write'
local fname_bak = fname .. '~' local fname_bak = fname .. '~'
@ -39,7 +39,7 @@ describe(':write', function()
it('&backupcopy=auto preserves symlinks', function() it('&backupcopy=auto preserves symlinks', function()
command('set backupcopy=auto') command('set backupcopy=auto')
write_file('test_bkc_file.txt', 'content0') write_file('test_bkc_file.txt', 'content0')
if iswin() then if is_os('win') then
command("silent !mklink test_bkc_link.txt test_bkc_file.txt") command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
else else
command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
@ -57,10 +57,10 @@ describe(':write', function()
end) end)
it('&backupcopy=no replaces symlink with new file', function() it('&backupcopy=no replaces symlink with new file', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
command('set backupcopy=no') command('set backupcopy=no')
write_file('test_bkc_file.txt', 'content0') write_file('test_bkc_file.txt', 'content0')
if iswin() then if is_os('win') then
command("silent !mklink test_bkc_link.txt test_bkc_file.txt") command("silent !mklink test_bkc_link.txt test_bkc_file.txt")
else else
command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") command("silent !ln -s test_bkc_file.txt test_bkc_link.txt")
@ -79,7 +79,7 @@ describe(':write', function()
it("appends FIFO file", function() it("appends FIFO file", function()
-- mkfifo creates read-only .lnk files on Windows -- mkfifo creates read-only .lnk files on Windows
if iswin() or eval("executable('mkfifo')") == 0 then if is_os('win') or eval("executable('mkfifo')") == 0 then
pending('missing "mkfifo" command') pending('missing "mkfifo" command')
end end
@ -112,7 +112,7 @@ describe(':write', function()
eq(1, eval("filereadable('test/write/p_opt.txt')")) eq(1, eval("filereadable('test/write/p_opt.txt')"))
eq(('Vim(write):E32: No file name'), pcall_err(command, 'write ++p test_write/')) eq(('Vim(write):E32: No file name'), pcall_err(command, 'write ++p test_write/'))
if not iswin() then if not is_os('win') then
eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
pcall_err(command, 'write ++p .')) pcall_err(command, 'write ++p .'))
eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
@ -121,11 +121,11 @@ describe(':write', function()
end) end)
it('errors out correctly', function() it('errors out correctly', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
command('let $HOME=""') command('let $HOME=""')
eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~')) eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~'))
-- Message from check_overwrite -- Message from check_overwrite
if not iswin() then if not is_os('win') then
eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'),
pcall_err(command, 'write .')) pcall_err(command, 'write .'))
end end
@ -144,7 +144,7 @@ describe(':write', function()
funcs.setfperm(fname, 'r--------') funcs.setfperm(fname, 'r--------')
eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)', eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)',
pcall_err(command, 'write')) pcall_err(command, 'write'))
if iswin() then if is_os('win') then
eq(0, os.execute('del /q/f ' .. fname)) eq(0, os.execute('del /q/f ' .. fname))
eq(0, os.execute('rd /q/s ' .. fname_bak)) eq(0, os.execute('rd /q/s ' .. fname_bak))
else else
@ -152,7 +152,7 @@ describe(':write', function()
eq(true, os.remove(fname_bak)) eq(true, os.remove(fname_bak))
end end
write_file(fname_bak, 'TTYX') write_file(fname_bak, 'TTYX')
skip(iswin(), [[FIXME: exc_exec('write!') outputs 0 in Windows]]) skip(is_os('win'), [[FIXME: exc_exec('write!') outputs 0 in Windows]])
lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true) lfs.link(fname_bak .. ('/xxxxx'):rep(20), fname, true)
eq('Vim(write):E166: Can\'t open linked file for writing', eq('Vim(write):E166: Can\'t open linked file for writing',
pcall_err(command, 'write!')) pcall_err(command, 'write!'))

View File

@ -3,14 +3,14 @@ local lfs = require('lfs')
local clear = helpers.clear local clear = helpers.clear
local command, eq, neq, write_file = local command, eq, neq, write_file =
helpers.command, helpers.eq, helpers.neq, helpers.write_file helpers.command, helpers.eq, helpers.neq, helpers.write_file
local iswin = helpers.iswin
local read_file = helpers.read_file local read_file = helpers.read_file
local is_os = helpers.is_os
describe(':wshada', function() describe(':wshada', function()
local shada_file = 'wshada_test' local shada_file = 'wshada_test'
before_each(function() before_each(function()
clear{args={'-i', iswin() and 'nul' or '/dev/null', clear{args={'-i', is_os('win') and 'nul' or '/dev/null',
-- Need 'swapfile' for these tests. -- Need 'swapfile' for these tests.
'--cmd', 'set swapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}, '--cmd', 'set swapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'},
args_rm={'-n', '-i', '--cmd'}} args_rm={'-n', '-i', '--cmd'}}

View File

@ -54,7 +54,6 @@ if module.nvim_dir == module.nvim_prog then
module.nvim_dir = "." module.nvim_dir = "."
end end
local iswin = global_helpers.iswin
local prepend_argv local prepend_argv
if os.getenv('VALGRIND') then if os.getenv('VALGRIND') then
@ -557,7 +556,7 @@ function module.source(code)
end end
function module.has_powershell() function module.has_powershell()
return module.eval('executable("'..(iswin() and 'powershell' or 'pwsh')..'")') == 1 return module.eval('executable("'..(is_os('win') and 'powershell' or 'pwsh')..'")') == 1
end end
--- Sets Nvim shell to powershell. --- Sets Nvim shell to powershell.
@ -570,9 +569,9 @@ function module.set_shell_powershell(fake)
if not fake then if not fake then
assert(found) assert(found)
end end
local shell = found and (iswin() and 'powershell' or 'pwsh') or module.testprg('pwsh-test') local shell = found and (is_os('win') and 'powershell' or 'pwsh') or module.testprg('pwsh-test')
local set_encoding = '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();' local set_encoding = '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();'
local cmd = set_encoding..'Remove-Item -Force '..table.concat(iswin() local cmd = set_encoding..'Remove-Item -Force '..table.concat(is_os('win')
and {'alias:cat', 'alias:echo', 'alias:sleep', 'alias:sort'} and {'alias:cat', 'alias:echo', 'alias:sleep', 'alias:sort'}
or {'alias:echo'}, ',')..';' or {'alias:echo'}, ',')..';'
module.exec([[ module.exec([[
@ -854,13 +853,13 @@ function module.exec_lua(code, ...)
end end
function module.get_pathsep() function module.get_pathsep()
return iswin() and '\\' or '/' return is_os('win') and '\\' or '/'
end end
--- Gets the filesystem root dir, namely "/" or "C:/". --- Gets the filesystem root dir, namely "/" or "C:/".
function module.pathroot() function module.pathroot()
local pathsep = package.config:sub(1,1) local pathsep = package.config:sub(1,1)
return iswin() and (module.nvim_dir:sub(1,2)..pathsep) or '/' return is_os('win') and (module.nvim_dir:sub(1,2)..pathsep) or '/'
end end
--- Gets the full `…/build/bin/{name}` path of a test program produced by --- Gets the full `…/build/bin/{name}` path of a test program produced by
@ -868,7 +867,7 @@ end
--- ---
--- @param name (string) Name of the test program. --- @param name (string) Name of the test program.
function module.testprg(name) function module.testprg(name)
local ext = module.iswin() and '.exe' or '' local ext = module.is_os('win') and '.exe' or ''
return ('%s/%s%s'):format(module.nvim_dir, name, ext) return ('%s/%s%s'):format(module.nvim_dir, name, ext)
end end
@ -895,7 +894,7 @@ function module.missing_provider(provider)
end end
function module.alter_slashes(obj) function module.alter_slashes(obj)
if not iswin() then if not is_os('win') then
return obj return obj
end end
if type(obj) == 'string' then if type(obj) == 'string' then
@ -913,7 +912,7 @@ function module.alter_slashes(obj)
end end
local load_factor = 1 local load_factor = 1
if global_helpers.isCI() then if global_helpers.is_ci() then
-- Compute load factor only once (but outside of any tests). -- Compute load factor only once (but outside of any tests).
module.clear() module.clear()
module.request('nvim_command', 'source src/nvim/testdir/load.vim') module.request('nvim_command', 'source src/nvim/testdir/load.vim')
@ -946,14 +945,14 @@ end
-- Kill process with given pid -- Kill process with given pid
function module.os_kill(pid) function module.os_kill(pid)
return os.execute((iswin() return os.execute((is_os('win')
and 'taskkill /f /t /pid '..pid..' > nul' and 'taskkill /f /t /pid '..pid..' > nul'
or 'kill -9 '..pid..' > /dev/null')) or 'kill -9 '..pid..' > /dev/null'))
end end
-- Create folder with non existing parents -- Create folder with non existing parents
function module.mkdir_p(path) function module.mkdir_p(path)
return os.execute((iswin() return os.execute((is_os('win')
and 'mkdir '..path and 'mkdir '..path
or 'mkdir -p '..path)) or 'mkdir -p '..path))
end end

View File

@ -18,11 +18,11 @@ local clear, feed_command, expect, eq, neq, dedent, write_file, feed =
helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq,
helpers.dedent, helpers.write_file, helpers.feed helpers.dedent, helpers.write_file, helpers.feed
local command = helpers.command local command = helpers.command
local iswin = helpers.iswin
local read_file = helpers.read_file local read_file = helpers.read_file
local is_os = helpers.is_os
local function has_gzip() local function has_gzip()
local null = iswin() and 'nul' or '/dev/null' local null = is_os('win') and 'nul' or '/dev/null'
return os.execute('gzip --help >' .. null .. ' 2>&1') == 0 return os.execute('gzip --help >' .. null .. ' 2>&1') == 0
end end

View File

@ -23,7 +23,7 @@ describe('jump to a tag with hidden set', function()
feed_command('set hidden') feed_command('set hidden')
-- Create a link from test25.dir to the current directory. -- Create a link from test25.dir to the current directory.
if helpers.iswin() then if helpers.is_os('win') then
feed_command('!rd /q/s test25.dir') feed_command('!rd /q/s test25.dir')
feed_command('!mklink /j test25.dir .') feed_command('!mklink /j test25.dir .')
else else
@ -33,7 +33,7 @@ describe('jump to a tag with hidden set', function()
-- Create tags.text, with the current directory name inserted. -- Create tags.text, with the current directory name inserted.
feed_command('/tags line') feed_command('/tags line')
feed_command('r !' .. (helpers.iswin() and 'cd' or 'pwd')) feed_command('r !' .. (helpers.is_os('win') and 'cd' or 'pwd'))
feed('d$/test<cr>') feed('d$/test<cr>')
feed('hP:.w! tags.test<cr>') feed('hP:.w! tags.test<cr>')
@ -44,7 +44,7 @@ describe('jump to a tag with hidden set', function()
feed('G<C-]> x:yank a<cr>') feed('G<C-]> x:yank a<cr>')
feed_command("call delete('tags.test')") feed_command("call delete('tags.test')")
feed_command("call delete('Xxx')") feed_command("call delete('Xxx')")
if helpers.iswin() then if helpers.is_os('win') then
feed_command('!rd /q test25.dir') feed_command('!rd /q test25.dir')
else else
feed_command('!rm -f test25.dir') feed_command('!rm -f test25.dir')

View File

@ -10,7 +10,7 @@ describe('glob() and globpath()', function()
setup(clear) setup(clear)
setup(function() setup(function()
if helpers.iswin() then if helpers.is_os('win') then
os.execute("md sautest\\autoload") os.execute("md sautest\\autoload")
os.execute(".>sautest\\autoload\\Test104.vim 2>nul") os.execute(".>sautest\\autoload\\Test104.vim 2>nul")
os.execute(".>sautest\\autoload\\footest.vim 2>nul") os.execute(".>sautest\\autoload\\footest.vim 2>nul")
@ -28,7 +28,7 @@ describe('glob() and globpath()', function()
-- Consistent sorting of file names -- Consistent sorting of file names
command('set nofileignorecase') command('set nofileignorecase')
if helpers.iswin() then if helpers.is_os('win') then
command([[$put =glob('Xxx{')]]) command([[$put =glob('Xxx{')]])
command([[$put =glob('Xxx$')]]) command([[$put =glob('Xxx$')]])
@ -72,7 +72,7 @@ describe('glob() and globpath()', function()
end) end)
teardown(function() teardown(function()
if helpers.iswin() then if helpers.is_os('win') then
os.execute('del /q/f Xxx{ Xxx$') os.execute('del /q/f Xxx{ Xxx$')
os.execute('rd /q /s sautest') os.execute('rd /q /s sautest')
else else

View File

@ -48,7 +48,7 @@ describe('Test for delete()', function()
it('symlink directory delete', function() it('symlink directory delete', function()
command("call mkdir('Xdir1')") command("call mkdir('Xdir1')")
if helpers.iswin() then if helpers.is_os('win') then
command("silent !mklink /j Xlink Xdir1") command("silent !mklink /j Xlink Xdir1")
else else
command("silent !ln -s Xdir1 Xlink") command("silent !ln -s Xdir1 Xlink")

View File

@ -7,12 +7,12 @@ local exec_lua = helpers.exec_lua
local expect_exit = helpers.expect_exit local expect_exit = helpers.expect_exit
local feed = helpers.feed local feed = helpers.feed
local funcs = helpers.funcs local funcs = helpers.funcs
local iswin = helpers.iswin
local meths = helpers.meths local meths = helpers.meths
local read_file = helpers.read_file local read_file = helpers.read_file
local source = helpers.source local source = helpers.source
local eq = helpers.eq local eq = helpers.eq
local write_file = helpers.write_file local write_file = helpers.write_file
local is_os = helpers.is_os
local function sizeoflong() local function sizeoflong()
if not exec_lua('return pcall(require, "ffi")') then if not exec_lua('return pcall(require, "ffi")') then
@ -376,7 +376,7 @@ describe(':confirm command dialog', function()
{3:(Y)es, [N]o: }^ | {3:(Y)es, [N]o: }^ |
]]) ]])
feed('Y') feed('Y')
if iswin() then if is_os('win') then
screen:expect([[ screen:expect([[
foobar | foobar |
{0:~ }| {0:~ }|
@ -416,7 +416,7 @@ describe(':confirm command dialog', function()
{3:(Y)es, [N]o: }^ | {3:(Y)es, [N]o: }^ |
]]) ]])
feed('Y') feed('Y')
if iswin() then if is_os('win') then
screen:expect([[ screen:expect([[
foobar | foobar |
{1: }| {1: }|
@ -493,7 +493,7 @@ describe(':confirm command dialog', function()
{3:(Y)es, [N]o: }^ | {3:(Y)es, [N]o: }^ |
]]) ]])
feed('Y') feed('Y')
if iswin() then if is_os('win') then
screen:expect([[ screen:expect([[
a | a |
b | b |

View File

@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source local clear, source = helpers.clear, helpers.source
local call, eq, meths = helpers.call, helpers.eq, helpers.meths local call, eq, meths = helpers.call, helpers.eq, helpers.meths
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
local function expected_empty() local function expected_empty()
@ -17,7 +17,7 @@ describe('file changed dialog', function()
end) end)
it('works', function() it('works', function()
skip(iswin()) skip(is_os('win'))
source([[ source([[
func Test_file_changed_dialog() func Test_file_changed_dialog()
au! FileChangedShell au! FileChangedShell

View File

@ -3,15 +3,14 @@ local clear = helpers.clear
local eval = helpers.eval local eval = helpers.eval
local eq = helpers.eq local eq = helpers.eq
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local iswin = helpers.iswin
local retry = helpers.retry local retry = helpers.retry
local ok = helpers.ok local ok = helpers.ok
local source = helpers.source local source = helpers.source
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = helpers.poke_eventloop
local uname = helpers.uname
local load_adjust = helpers.load_adjust local load_adjust = helpers.load_adjust
local write_file = helpers.write_file local write_file = helpers.write_file
local isCI = helpers.isCI local is_os = helpers.is_os
local is_ci = helpers.is_ci
local function isasan() local function isasan()
local version = eval('execute("version")') local version = eval('execute("version")')
@ -22,8 +21,8 @@ clear()
if isasan() then if isasan() then
pending('ASAN build is difficult to estimate memory usage', function() end) pending('ASAN build is difficult to estimate memory usage', function() end)
return return
elseif iswin() then elseif is_os('win') then
if isCI('github') then if is_ci('github') then
pending('Windows runners in Github Actions do not have a stable environment to estimate memory usage', function() end) pending('Windows runners in Github Actions do not have a stable environment to estimate memory usage', function() end)
return return
elseif eval("executable('wmic')") == 0 then elseif eval("executable('wmic')") == 0 then
@ -38,7 +37,7 @@ end
local monitor_memory_usage = { local monitor_memory_usage = {
memory_usage = function(self) memory_usage = function(self)
local handle local handle
if iswin() then if is_os('win') then
handle = io.popen('wmic process where processid=' ..self.pid..' get WorkingSetSize') handle = io.popen('wmic process where processid=' ..self.pid..' get WorkingSetSize')
else else
handle = io.popen('ps -o rss= -p '..self.pid) handle = io.popen('ps -o rss= -p '..self.pid)
@ -169,7 +168,7 @@ describe('memory usage', function()
-- Allow for 20% tolerance at the upper limit. That's very permissive, but -- Allow for 20% tolerance at the upper limit. That's very permissive, but
-- otherwise the test fails sometimes. On Sourcehut CI with FreeBSD we need to -- otherwise the test fails sometimes. On Sourcehut CI with FreeBSD we need to
-- be even much more permissive. -- be even much more permissive.
local upper_multiplier = uname() == 'freebsd' and 19 or 12 local upper_multiplier = is_os('freebsd') and 19 or 12
local lower = before.last * 8 / 10 local lower = before.last * 8 / 10
local upper = load_adjust((after.max + (after.last - before.last)) * upper_multiplier / 10) local upper = load_adjust((after.max + (after.last - before.last)) * upper_multiplier / 10)
check_result({before=before, after=after, last=last}, check_result({before=before, after=after, last=last},
@ -179,7 +178,7 @@ describe('memory usage', function()
end) end)
it('releases memory when closing windows when folds exist', function() it('releases memory when closing windows when folds exist', function()
if helpers.is_os('mac') then if is_os('mac') then
pending('macOS memory compression causes flakiness') pending('macOS memory compression causes flakiness')
end end
local pid = eval('getpid()') local pid = eval('getpid()')

View File

@ -7,10 +7,10 @@ local mkdir_p = helpers.mkdir_p
local rmdir = helpers.rmdir local rmdir = helpers.rmdir
local nvim_dir = helpers.nvim_dir local nvim_dir = helpers.nvim_dir
local test_build_dir = helpers.test_build_dir local test_build_dir = helpers.test_build_dir
local iswin = helpers.iswin
local nvim_prog = helpers.nvim_prog local nvim_prog = helpers.nvim_prog
local is_os = helpers.is_os
local nvim_prog_basename = iswin() and 'nvim.exe' or 'nvim' local nvim_prog_basename = is_os('win') and 'nvim.exe' or 'nvim'
before_each(clear) before_each(clear)
@ -102,7 +102,7 @@ describe('vim.fs', function()
eq('C:/Users/jdoe', exec_lua [[ return vim.fs.normalize('C:\\Users\\jdoe') ]]) eq('C:/Users/jdoe', exec_lua [[ return vim.fs.normalize('C:\\Users\\jdoe') ]])
end) end)
it('works with ~', function() it('works with ~', function()
if iswin() then if is_os('win') then
pending([[$HOME does not exist on Windows ¯\_(ツ)_/¯]]) pending([[$HOME does not exist on Windows ¯\_(ツ)_/¯]])
end end
eq(os.getenv('HOME') .. '/src/foo', exec_lua [[ return vim.fs.normalize('~/src/foo') ]]) eq(os.getenv('HOME') .. '/src/foo', exec_lua [[ return vim.fs.normalize('~/src/foo') ]])

View File

@ -8,12 +8,12 @@ local feed = helpers.feed
local clear = helpers.clear local clear = helpers.clear
local funcs = helpers.funcs local funcs = helpers.funcs
local meths = helpers.meths local meths = helpers.meths
local iswin = helpers.iswin
local command = helpers.command local command = helpers.command
local write_file = helpers.write_file local write_file = helpers.write_file
local exec_capture = helpers.exec_capture local exec_capture = helpers.exec_capture
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local is_os = helpers.is_os
local screen local screen
@ -135,7 +135,7 @@ describe('print', function()
print("very slow") print("very slow")
vim.api.nvim_command("sleep 1m") -- force deferred event processing vim.api.nvim_command("sleep 1m") -- force deferred event processing
end end
]], (iswin() and "timeout 1") or "sleep 0.1") ]], (is_os('win') and "timeout 1") or "sleep 0.1")
eq('very slow\nvery fast', exec_capture('lua test()')) eq('very slow\nvery fast', exec_capture('lua test()'))
end) end)
end) end)

View File

@ -5,7 +5,7 @@ local eq = helpers.eq
local clear = helpers.clear local clear = helpers.clear
local command = helpers.command local command = helpers.command
local pathsep = helpers.get_pathsep() local pathsep = helpers.get_pathsep()
local iswin = helpers.iswin() local is_os = helpers.is_os
local curbufmeths = helpers.curbufmeths local curbufmeths = helpers.curbufmeths
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
@ -18,7 +18,7 @@ describe('vim.secure', function()
local xstate = 'Xstate' local xstate = 'Xstate'
setup(function() setup(function()
helpers.mkdir_p(xstate .. pathsep .. (iswin and 'nvim-data' or 'nvim')) helpers.mkdir_p(xstate .. pathsep .. (is_os('win') and 'nvim-data' or 'nvim'))
end) end)
teardown(function() teardown(function()

View File

@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear local clear = helpers.clear
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local eq = helpers.eq local eq = helpers.eq
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
local write_file = require('test.helpers').write_file local write_file = require('test.helpers').write_file
@ -169,7 +169,7 @@ describe('URI methods', function()
describe('uri from bufnr', function() describe('uri from bufnr', function()
it('Windows paths should not be treated as uris', function() it('Windows paths should not be treated as uris', function()
skip(not iswin(), "Not applicable on non-Windows") skip(not is_os('win'), "Not applicable on non-Windows")
local file = helpers.tmpname() local file = helpers.tmpname()
write_file(file, 'Test content') write_file(file, 'Test content')

View File

@ -16,7 +16,7 @@ describe("'autochdir'", function()
-- With 'autochdir' on, we should get the directory of tty-test.c. -- With 'autochdir' on, we should get the directory of tty-test.c.
clear('--cmd', 'set autochdir', targetdir..'/tty-test.c') clear('--cmd', 'set autochdir', targetdir..'/tty-test.c')
eq(helpers.iswin() and expected:gsub('/', '\\') or expected, funcs.getcwd()) eq(helpers.is_os('win') and expected:gsub('/', '\\') or expected, funcs.getcwd())
end) end)
it('is not overwritten by getwinvar() call #17609',function() it('is not overwritten by getwinvar() call #17609',function()

View File

@ -12,13 +12,13 @@ local eq = helpers.eq
local ok = helpers.ok local ok = helpers.ok
local funcs = helpers.funcs local funcs = helpers.funcs
local insert = helpers.insert local insert = helpers.insert
local iswin = helpers.iswin
local neq = helpers.neq local neq = helpers.neq
local mkdir = helpers.mkdir local mkdir = helpers.mkdir
local rmdir = helpers.rmdir local rmdir = helpers.rmdir
local alter_slashes = helpers.alter_slashes local alter_slashes = helpers.alter_slashes
local tbl_contains = helpers.tbl_contains local tbl_contains = helpers.tbl_contains
local expect_exit = helpers.expect_exit local expect_exit = helpers.expect_exit
local is_os = helpers.is_os
describe('startup defaults', function() describe('startup defaults', function()
describe(':filetype', function() describe(':filetype', function()
@ -240,7 +240,7 @@ describe('startup defaults', function()
describe('$NVIM_LOG_FILE', function() describe('$NVIM_LOG_FILE', function()
local xdgdir = 'Xtest-startup-xdg-logpath' local xdgdir = 'Xtest-startup-xdg-logpath'
local xdgstatedir = iswin() and xdgdir..'/nvim-data' or xdgdir..'/nvim' local xdgstatedir = is_os('win') and xdgdir..'/nvim-data' or xdgdir..'/nvim'
after_each(function() after_each(function()
os.remove('Xtest-logpath') os.remove('Xtest-logpath')
rmdir(xdgdir) rmdir(xdgdir)
@ -279,7 +279,7 @@ describe('XDG defaults', function()
clear() clear()
local rtp = eval('split(&runtimepath, ",")') local rtp = eval('split(&runtimepath, ",")')
local rv = {} local rv = {}
local expected = (iswin() local expected = (is_os('win')
and { [[\nvim-data\site]], [[\nvim-data\site\after]], } and { [[\nvim-data\site]], [[\nvim-data\site\after]], }
or { '/nvim/site', '/nvim/site/after', }) or { '/nvim/site', '/nvim/site/after', })
@ -327,10 +327,10 @@ describe('XDG defaults', function()
return vimruntime, libdir return vimruntime, libdir
end end
local env_sep = iswin() and ';' or ':' local env_sep = is_os('win') and ';' or ':'
local data_dir = iswin() and 'nvim-data' or 'nvim' local data_dir = is_os('win') and 'nvim-data' or 'nvim'
local state_dir = iswin() and 'nvim-data' or 'nvim' local state_dir = is_os('win') and 'nvim-data' or 'nvim'
local root_path = iswin() and 'C:' or '' local root_path = is_os('win') and 'C:' or ''
describe('with too long XDG variables', function() describe('with too long XDG variables', function()
before_each(function() before_each(function()
@ -497,7 +497,7 @@ describe('XDG defaults', function()
it('are escaped properly', function() it('are escaped properly', function()
local vimruntime, libdir = vimruntime_and_libdir() local vimruntime, libdir = vimruntime_and_libdir()
local path_sep = iswin() and '\\' or '/' local path_sep = is_os('win') and '\\' or '/'
eq(('\\, \\, \\,' .. path_sep .. 'nvim' eq(('\\, \\, \\,' .. path_sep .. 'nvim'
.. ',\\,-\\,-\\,' .. path_sep .. 'nvim' .. ',\\,-\\,-\\,' .. path_sep .. 'nvim'
.. ',-\\,-\\,-' .. path_sep .. 'nvim' .. ',-\\,-\\,-' .. path_sep .. 'nvim'
@ -549,9 +549,9 @@ end)
describe('stdpath()', function() describe('stdpath()', function()
-- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions -- Windows appends 'nvim-data' instead of just 'nvim' to prevent collisions
-- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same. -- due to XDG_CONFIG_HOME, XDG_DATA_HOME and XDG_STATE_HOME being the same.
local datadir = iswin() and 'nvim-data' or 'nvim' local datadir = is_os('win') and 'nvim-data' or 'nvim'
local statedir = iswin() and 'nvim-data' or 'nvim' local statedir = is_os('win') and 'nvim-data' or 'nvim'
local env_sep = iswin() and ';' or ':' local env_sep = is_os('win') and ';' or ':'
it('acceptance', function() it('acceptance', function()
clear() -- Do not explicitly set any env vars. clear() -- Do not explicitly set any env vars.
@ -704,7 +704,7 @@ describe('stdpath()', function()
context('returns a List', function() context('returns a List', function()
-- Some OS specific variables the system would have set. -- Some OS specific variables the system would have set.
local function base_env() local function base_env()
if iswin() then if is_os('win') then
return { return {
HOME='C:\\Users\\docwhat', -- technically, is not a usual PATH HOME='C:\\Users\\docwhat', -- technically, is not a usual PATH
HOMEDRIVE='C:', HOMEDRIVE='C:',

View File

@ -17,9 +17,9 @@ local retry = helpers.retry
local NIL = helpers.NIL local NIL = helpers.NIL
local read_file = require('test.helpers').read_file local read_file = require('test.helpers').read_file
local write_file = require('test.helpers').write_file local write_file = require('test.helpers').write_file
local isCI = helpers.isCI local is_ci = helpers.is_ci
local meths = helpers.meths local meths = helpers.meths
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
-- Use these to get access to a coroutine so that I can run async tests and use -- Use these to get access to a coroutine so that I can run async tests and use
@ -27,7 +27,7 @@ local skip = helpers.skip
local run, stop = helpers.run, helpers.stop local run, stop = helpers.run, helpers.stop
-- TODO(justinmk): hangs on Windows https://github.com/neovim/neovim/pull/11837 -- TODO(justinmk): hangs on Windows https://github.com/neovim/neovim/pull/11837
if skip(iswin()) then return end if skip(is_os('win')) then return end
-- Fake LSP server. -- Fake LSP server.
local fake_lsp_code = 'test/functional/fixtures/fake-lsp-server.lua' local fake_lsp_code = 'test/functional/fixtures/fake-lsp-server.lua'
@ -318,7 +318,7 @@ describe('LSP', function()
end) end)
it('should succeed with manual shutdown', function() it('should succeed with manual shutdown', function()
if isCI() then if is_ci() then
pending('hangs the build on CI #14028, re-enable with freeze timeout #14204') pending('hangs the build on CI #14028, re-enable with freeze timeout #14204')
return return
elseif helpers.skip_fragile(pending) then elseif helpers.skip_fragile(pending) then

View File

@ -8,8 +8,8 @@ local nvim_prog = helpers.nvim_prog
local matches = helpers.matches local matches = helpers.matches
local write_file = helpers.write_file local write_file = helpers.write_file
local tmpname = helpers.tmpname local tmpname = helpers.tmpname
local isCI = helpers.isCI
local skip = helpers.skip local skip = helpers.skip
local is_ci = helpers.is_ci
clear() clear()
if funcs.executable('man') == 0 then if funcs.executable('man') == 0 then
@ -162,7 +162,7 @@ describe(':Man', function()
end) end)
it('reports non-existent man pages for absolute paths', function() it('reports non-existent man pages for absolute paths', function()
skip(isCI('cirrus')) skip(is_ci('cirrus'))
local actual_file = tmpname() local actual_file = tmpname()
-- actual_file must be an absolute path to an existent file for us to test against it -- actual_file must be an absolute path to an existent file for us to test against it
matches('^/.+', actual_file) matches('^/.+', actual_file)

View File

@ -2140,7 +2140,7 @@ end)
describe('plugin/shada.vim', function() describe('plugin/shada.vim', function()
local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0) local epoch = os.date('%Y-%m-%dT%H:%M:%S', 0)
local eol = helpers.iswin() and '\r\n' or '\n' local eol = helpers.is_os('win') and '\r\n' or '\n'
before_each(function() before_each(function()
-- Note: reset() is called explicitly in each test. -- Note: reset() is called explicitly in each test.
os.remove(fname) os.remove(fname)

View File

@ -2,10 +2,10 @@
-- Busted started doing this to help provide more isolation. See issue #62 -- Busted started doing this to help provide more isolation. See issue #62
-- for more information about this. -- for more information about this.
local helpers = require('test.functional.helpers')(nil) local helpers = require('test.functional.helpers')(nil)
local iswin = helpers.iswin
local busted = require("busted") local busted = require("busted")
local is_os = helpers.is_os
if iswin() then if is_os('win') then
local ffi = require('ffi') local ffi = require('ffi')
ffi.cdef[[ ffi.cdef[[
typedef int errno_t; typedef int errno_t;

View File

@ -9,7 +9,7 @@ local curbufmeths = helpers.curbufmeths
local insert = helpers.insert local insert = helpers.insert
local expect = helpers.expect local expect = helpers.expect
local feed = helpers.feed local feed = helpers.feed
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
do do
@ -26,7 +26,7 @@ before_each(function()
end) end)
describe('legacy perl provider', function() describe('legacy perl provider', function()
skip(iswin()) skip(is_os('win'))
it('feature test', function() it('feature test', function()
eq(1, eval('has("perl")')) eq(1, eval('has("perl")'))
@ -70,7 +70,7 @@ describe('legacy perl provider', function()
end) end)
describe('perl provider', function() describe('perl provider', function()
skip(iswin()) skip(is_os('win'))
teardown(function () teardown(function ()
os.remove('Xtest-perl-hello.pl') os.remove('Xtest-perl-hello.pl')
os.remove('Xtest-perl-hello-plugin.pl') os.remove('Xtest-perl-hello-plugin.pl')

View File

@ -12,7 +12,7 @@ local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compati
local mock_file_path = '/a/b/' local mock_file_path = '/a/b/'
local mock_file_path2 = '/d/e/' local mock_file_path2 = '/d/e/'
if helpers.iswin() then if helpers.is_os('win') then
mock_file_path = 'C:/a/' mock_file_path = 'C:/a/'
mock_file_path2 = 'C:/d/' mock_file_path2 = 'C:/d/'
end end

View File

@ -14,7 +14,7 @@ local wshada, sdrcmd, shada_fname =
get_shada_rw('Xtest-functional-shada-merging.shada') get_shada_rw('Xtest-functional-shada-merging.shada')
local mock_file_path = '/a/b/' local mock_file_path = '/a/b/'
if helpers.iswin() then if helpers.is_os('win') then
mock_file_path = 'C:/a/' mock_file_path = 'C:/a/'
end end

View File

@ -5,7 +5,7 @@ local meths, nvim_command, funcs, eq =
local write_file, spawn, set_session, nvim_prog, exc_exec = local write_file, spawn, set_session, nvim_prog, exc_exec =
helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog, helpers.write_file, helpers.spawn, helpers.set_session, helpers.nvim_prog,
helpers.exc_exec helpers.exc_exec
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
local lfs = require('lfs') local lfs = require('lfs')
@ -250,7 +250,7 @@ describe('ShaDa support code', function()
end) end)
it('does not crash when ShaDa file directory is not writable', function() it('does not crash when ShaDa file directory is not writable', function()
skip(iswin()) skip(is_os('win'))
funcs.mkdir(dirname, '', 0) funcs.mkdir(dirname, '', 0)
eq(0, funcs.filewritable(dirname)) eq(0, funcs.filewritable(dirname))

View File

@ -6,7 +6,7 @@ local feed_data = thelpers.feed_data
local enter_altscreen = thelpers.enter_altscreen local enter_altscreen = thelpers.enter_altscreen
local exit_altscreen = thelpers.exit_altscreen local exit_altscreen = thelpers.exit_altscreen
if helpers.skip(helpers.iswin()) then return end if helpers.skip(helpers.is_os('win')) then return end
describe(':terminal altscreen', function() describe(':terminal altscreen', function()
local screen local screen

View File

@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local child_session = require('test.functional.terminal.helpers') local child_session = require('test.functional.terminal.helpers')
local ok = helpers.ok local ok = helpers.ok
if helpers.skip(helpers.iswin()) then return end if helpers.skip(helpers.is_os('win')) then return end
describe('api', function() describe('api', function()
local screen local screen

View File

@ -15,7 +15,7 @@ local matches = helpers.matches
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local sleep = helpers.sleep local sleep = helpers.sleep
local funcs = helpers.funcs local funcs = helpers.funcs
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
describe(':terminal buffer', function() describe(':terminal buffer', function()
@ -202,7 +202,7 @@ describe(':terminal buffer', function()
-- Save the buffer number of the terminal for later testing. -- Save the buffer number of the terminal for later testing.
local tbuf = eval('bufnr("%")') local tbuf = eval('bufnr("%")')
local exitcmd = helpers.iswin() local exitcmd = helpers.is_os('win')
and "['cmd', '/c', 'exit']" and "['cmd', '/c', 'exit']"
or "['sh', '-c', 'exit']" or "['sh', '-c', 'exit']"
source([[ source([[
@ -264,7 +264,7 @@ describe(':terminal buffer', function()
end) end)
it('it works with set rightleft #11438', function() it('it works with set rightleft #11438', function()
skip(iswin()) skip(is_os('win'))
local columns = eval('&columns') local columns = eval('&columns')
feed(string.rep('a', columns)) feed(string.rep('a', columns))
command('set rightleft') command('set rightleft')

View File

@ -9,7 +9,7 @@ local matches = helpers.matches
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local hide_cursor = thelpers.hide_cursor local hide_cursor = thelpers.hide_cursor
local show_cursor = thelpers.show_cursor local show_cursor = thelpers.show_cursor
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
describe(':terminal cursor', function() describe(':terminal cursor', function()
@ -90,7 +90,7 @@ describe(':terminal cursor', function()
describe('when invisible', function() describe('when invisible', function()
it('is not highlighted and is detached from screen cursor', function() it('is not highlighted and is detached from screen cursor', function()
skip(iswin()) skip(is_os('win'))
hide_cursor() hide_cursor()
screen:expect([[ screen:expect([[
tty ready | tty ready |
@ -363,7 +363,7 @@ describe('buffer cursor position is correct in terminal without number column',
end) end)
describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function() describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function()
if skip(iswin(), "Encoding problem?") then return end if skip(is_os('win'), "Encoding problem?") then return end
before_each(function() before_each(function()
setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳') setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
@ -446,7 +446,7 @@ describe('buffer cursor position is correct in terminal without number column',
end) end)
describe('in a line with double-cell multibyte characters and no trailing spaces,', function() describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
skip(iswin(), "Encoding problem?") skip(is_os('win'), "Encoding problem?")
before_each(function() before_each(function()
setup_ex_register('哦哦哦哦哦哦哦哦') setup_ex_register('哦哦哦哦哦哦哦哦')
@ -743,7 +743,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
end) end)
describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function() describe('in a line with single-cell composed multibyte characters and no trailing spaces,', function()
if skip(iswin(), "Encoding problem?") then return end if skip(is_os('win'), "Encoding problem?") then return end
before_each(function() before_each(function()
setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳') setup_ex_register('µ̳µ̳µ̳µ̳µ̳µ̳µ̳µ̳')
@ -826,7 +826,7 @@ describe('buffer cursor position is correct in terminal with number column', fun
end) end)
describe('in a line with double-cell multibyte characters and no trailing spaces,', function() describe('in a line with double-cell multibyte characters and no trailing spaces,', function()
skip(iswin(), "Encoding problem?") skip(is_os('win'), "Encoding problem?")
before_each(function() before_each(function()
setup_ex_register('哦哦哦哦哦哦哦哦') setup_ex_register('哦哦哦哦哦哦哦哦')

View File

@ -36,7 +36,7 @@ describe(':edit term://*', function()
end) end)
it("runs TermOpen early enough to set buffer-local 'scrollback'", function() it("runs TermOpen early enough to set buffer-local 'scrollback'", function()
if helpers.skip(helpers.iswin()) then return end if helpers.skip(helpers.is_os('win')) then return end
local columns, lines = 20, 4 local columns, lines = 20, 4
local scr = get_screen(columns, lines) local scr = get_screen(columns, lines)
local rep = 97 local rep = 97

View File

@ -8,10 +8,10 @@ local feed_command, eval = helpers.feed_command, helpers.eval
local funcs = helpers.funcs local funcs = helpers.funcs
local retry = helpers.retry local retry = helpers.retry
local ok = helpers.ok local ok = helpers.ok
local iswin = helpers.iswin
local command = helpers.command local command = helpers.command
local isCI = helpers.isCI
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
local is_ci = helpers.is_ci
describe(':terminal', function() describe(':terminal', function()
local screen local screen
@ -47,8 +47,8 @@ describe(':terminal', function()
end) end)
it("reads output buffer on terminal reporting #4151", function() it("reads output buffer on terminal reporting #4151", function()
skip(isCI('cirrus') or iswin()) skip(is_ci('cirrus') or is_os('win'))
if iswin() then if is_os('win') then
feed_command([[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]]) feed_command([[terminal powershell -NoProfile -NoLogo -Command Write-Host -NoNewline "\"$([char]27)[6n\""; Start-Sleep -Milliseconds 500 ]])
else else
feed_command([[terminal printf '\e[6n'; sleep 0.5 ]]) feed_command([[terminal printf '\e[6n'; sleep 0.5 ]])
@ -57,7 +57,7 @@ describe(':terminal', function()
end) end)
it("in normal-mode :split does not move cursor", function() it("in normal-mode :split does not move cursor", function()
if iswin() then if is_os('win') then
feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]]) feed_command([[terminal for /L \\%I in (1,0,2) do ( echo foo & ping -w 100 -n 1 127.0.0.1 > nul )]])
else else
feed_command([[terminal while true; do echo foo; sleep .1; done]]) feed_command([[terminal while true; do echo foo; sleep .1; done]])
@ -144,7 +144,7 @@ describe(':terminal (with fake shell)', function()
end end
it('with no argument, acts like termopen()', function() it('with no argument, acts like termopen()', function()
skip(iswin()) skip(is_os('win'))
terminal_with_fake_shell() terminal_with_fake_shell()
retry(nil, 4 * screen.timeout, function() retry(nil, 4 * screen.timeout, function()
screen:expect([[ screen:expect([[
@ -168,7 +168,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it("with no argument, but 'shell' has arguments, acts like termopen()", function() it("with no argument, but 'shell' has arguments, acts like termopen()", function()
skip(iswin()) skip(is_os('win'))
nvim('set_option', 'shell', testprg('shell-test')..' -t jeff') nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
terminal_with_fake_shell() terminal_with_fake_shell()
screen:expect([[ screen:expect([[
@ -180,7 +180,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it('executes a given command through the shell', function() it('executes a given command through the shell', function()
skip(iswin()) skip(is_os('win'))
command('set shellxquote=') -- win: avoid extra quotes command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell('echo hi') terminal_with_fake_shell('echo hi')
screen:expect([[ screen:expect([[
@ -192,7 +192,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it("executes a given command through the shell, when 'shell' has arguments", function() it("executes a given command through the shell, when 'shell' has arguments", function()
skip(iswin()) skip(is_os('win'))
nvim('set_option', 'shell', testprg('shell-test')..' -t jeff') nvim('set_option', 'shell', testprg('shell-test')..' -t jeff')
command('set shellxquote=') -- win: avoid extra quotes command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell('echo hi') terminal_with_fake_shell('echo hi')
@ -205,7 +205,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it('allows quotes and slashes', function() it('allows quotes and slashes', function()
skip(iswin()) skip(is_os('win'))
command('set shellxquote=') -- win: avoid extra quotes command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell([[echo 'hello' \ "world"]]) terminal_with_fake_shell([[echo 'hello' \ "world"]])
screen:expect([[ screen:expect([[
@ -242,7 +242,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it('works with :find', function() it('works with :find', function()
skip(iswin()) skip(is_os('win'))
terminal_with_fake_shell() terminal_with_fake_shell()
screen:expect([[ screen:expect([[
^ready $ | ^ready $ |
@ -253,7 +253,7 @@ describe(':terminal (with fake shell)', function()
eq('term://', string.match(eval('bufname("%")'), "^term://")) eq('term://', string.match(eval('bufname("%")'), "^term://"))
feed([[<C-\><C-N>]]) feed([[<C-\><C-N>]])
feed_command([[find */shadacat.py]]) feed_command([[find */shadacat.py]])
if iswin() then if is_os('win') then
eq('scripts\\shadacat.py', eval('bufname("%")')) eq('scripts\\shadacat.py', eval('bufname("%")'))
else else
eq('scripts/shadacat.py', eval('bufname("%")')) eq('scripts/shadacat.py', eval('bufname("%")'))
@ -261,7 +261,7 @@ describe(':terminal (with fake shell)', function()
end) end)
it('works with gf', function() it('works with gf', function()
skip(iswin()) skip(is_os('win'))
command('set shellxquote=') -- win: avoid extra quotes command('set shellxquote=') -- win: avoid extra quotes
terminal_with_fake_shell([[echo "scripts/shadacat.py"]]) terminal_with_fake_shell([[echo "scripts/shadacat.py"]])
retry(nil, 4 * screen.timeout, function() retry(nil, 4 * screen.timeout, function()

View File

@ -7,7 +7,7 @@ local nvim_prog_abs = helpers.nvim_prog_abs
local eq, eval = helpers.eq, helpers.eval local eq, eval = helpers.eq, helpers.eval
local funcs = helpers.funcs local funcs = helpers.funcs
local nvim_set = helpers.nvim_set local nvim_set = helpers.nvim_set
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
describe(':terminal highlight', function() describe(':terminal highlight', function()
@ -60,7 +60,7 @@ describe(':terminal highlight', function()
end) end)
local function pass_attrs() local function pass_attrs()
skip(iswin()) skip(is_os('win'))
screen:expect(sub([[ screen:expect(sub([[
tty ready | tty ready |
{NUM:text}text{10: } | {NUM:text}text{10: } |
@ -75,7 +75,7 @@ describe(':terminal highlight', function()
it('will pass the corresponding attributes', pass_attrs) it('will pass the corresponding attributes', pass_attrs)
it('will pass the corresponding attributes on scrollback', function() it('will pass the corresponding attributes on scrollback', function()
skip(iswin()) skip(is_os('win'))
pass_attrs() pass_attrs()
local lines = {} local lines = {}
for i = 1, 8 do for i = 1, 8 do
@ -199,7 +199,7 @@ describe(':terminal highlight forwarding', function()
end) end)
it('will handle cterm and rgb attributes', function() it('will handle cterm and rgb attributes', function()
skip(iswin()) skip(is_os('win'))
thelpers.set_fg(3) thelpers.set_fg(3)
thelpers.feed_data('text') thelpers.feed_data('text')
thelpers.feed_termcode('[38:2:255:128:0m') thelpers.feed_termcode('[38:2:255:128:0m')
@ -251,7 +251,7 @@ describe(':terminal highlight with custom palette', function()
end) end)
it('will use the custom color', function() it('will use the custom color', function()
skip(iswin()) skip(is_os('win'))
thelpers.set_fg(3) thelpers.set_fg(3)
thelpers.feed_data('text') thelpers.feed_data('text')
thelpers.clear_attrs() thelpers.clear_attrs()

View File

@ -3,7 +3,7 @@ local thelpers = require('test.functional.terminal.helpers')
local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command
local feed_data = thelpers.feed_data local feed_data = thelpers.feed_data
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
describe(':terminal mouse', function() describe(':terminal mouse', function()
@ -68,7 +68,7 @@ describe(':terminal mouse', function()
end) end)
it('does not leave terminal mode on left-release', function() it('does not leave terminal mode on left-release', function()
skip(iswin()) skip(is_os('win'))
feed('<LeftRelease>') feed('<LeftRelease>')
eq('t', eval('mode(1)')) eq('t', eval('mode(1)'))
end) end)
@ -89,7 +89,7 @@ describe(':terminal mouse', function()
end) end)
it('will forward mouse press, drag and release to the program', function() it('will forward mouse press, drag and release to the program', function()
skip(iswin()) skip(is_os('win'))
feed('<LeftMouse><1,2>') feed('<LeftMouse><1,2>')
screen:expect([[ screen:expect([[
line27 | line27 |
@ -133,7 +133,7 @@ describe(':terminal mouse', function()
end) end)
it('will forward mouse scroll to the program', function() it('will forward mouse scroll to the program', function()
skip(iswin()) skip(is_os('win'))
feed('<ScrollWheelUp><0,0>') feed('<ScrollWheelUp><0,0>')
screen:expect([[ screen:expect([[
line27 | line27 |
@ -147,7 +147,7 @@ describe(':terminal mouse', function()
end) end)
it('dragging and scrolling do not interfere with each other', function() it('dragging and scrolling do not interfere with each other', function()
skip(iswin()) skip(is_os('win'))
feed('<LeftMouse><1,2>') feed('<LeftMouse><1,2>')
screen:expect([[ screen:expect([[
line27 | line27 |
@ -201,7 +201,7 @@ describe(':terminal mouse', function()
end) end)
it('will forward mouse clicks to the program with the correct even if set nu', function() it('will forward mouse clicks to the program with the correct even if set nu', function()
skip(iswin()) skip(is_os('win'))
command('set number') command('set number')
-- When the display area such as a number is clicked, it returns to the -- When the display area such as a number is clicked, it returns to the
-- normal mode. -- normal mode.
@ -232,7 +232,7 @@ describe(':terminal mouse', function()
end) end)
describe('with a split window and other buffer', function() describe('with a split window and other buffer', function()
skip(iswin()) skip(is_os('win'))
before_each(function() before_each(function()
feed('<c-\\><c-n>:vsp<cr>') feed('<c-\\><c-n>:vsp<cr>')
screen:expect([[ screen:expect([[

View File

@ -3,7 +3,6 @@ local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers') local thelpers = require('test.functional.terminal.helpers')
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
local feed, testprg, feed_command = helpers.feed, helpers.testprg, helpers.feed_command local feed, testprg, feed_command = helpers.feed, helpers.testprg, helpers.feed_command
local iswin = helpers.iswin
local eval = helpers.eval local eval = helpers.eval
local command = helpers.command local command = helpers.command
local matches = helpers.matches local matches = helpers.matches
@ -16,6 +15,7 @@ local pcall_err = helpers.pcall_err
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe(':terminal scrollback', function() describe(':terminal scrollback', function()
local screen local screen
@ -140,7 +140,7 @@ describe(':terminal scrollback', function()
describe('and height decreased by 1', function() describe('and height decreased by 1', function()
if skip(iswin()) then return end if skip(is_os('win')) then return end
local function will_hide_top_line() local function will_hide_top_line()
feed([[<C-\><C-N>]]) feed([[<C-\><C-N>]])
screen:try_resize(screen._width - 2, screen._height - 1) screen:try_resize(screen._width - 2, screen._height - 1)
@ -186,7 +186,7 @@ describe(':terminal scrollback', function()
-- XXX: Can't test this reliably on Windows unless the cursor is _moved_ -- XXX: Can't test this reliably on Windows unless the cursor is _moved_
-- by the resize. http://docs.libuv.org/en/v1.x/signal.html -- by the resize. http://docs.libuv.org/en/v1.x/signal.html
-- See also: https://github.com/rprichard/winpty/issues/110 -- See also: https://github.com/rprichard/winpty/issues/110
if skip(iswin()) then return end if skip(is_os('win')) then return end
describe('and the height is decreased by 2', function() describe('and the height is decreased by 2', function()
before_each(function() before_each(function()
@ -265,7 +265,7 @@ describe(':terminal scrollback', function()
-- XXX: Can't test this reliably on Windows unless the cursor is _moved_ -- XXX: Can't test this reliably on Windows unless the cursor is _moved_
-- by the resize. http://docs.libuv.org/en/v1.x/signal.html -- by the resize. http://docs.libuv.org/en/v1.x/signal.html
-- See also: https://github.com/rprichard/winpty/issues/110 -- See also: https://github.com/rprichard/winpty/issues/110
if skip(iswin()) then return end if skip(is_os('win')) then return end
local function pop_then_push() local function pop_then_push()
screen:try_resize(screen._width, screen._height + 1) screen:try_resize(screen._width, screen._height + 1)
screen:expect([[ screen:expect([[
@ -347,7 +347,7 @@ end)
describe(':terminal prints more lines than the screen height and exits', function() describe(':terminal prints more lines than the screen height and exits', function()
it('will push extra lines to scrollback', function() it('will push extra lines to scrollback', function()
skip(iswin()) skip(is_os('win'))
clear() clear()
local screen = Screen.new(30, 7) local screen = Screen.new(30, 7)
screen:attach({rgb=false}) screen:attach({rgb=false})
@ -397,21 +397,21 @@ describe("'scrollback' option", function()
it('set to 0 behaves as 1', function() it('set to 0 behaves as 1', function()
local screen local screen
if iswin() then if is_os('win') then
screen = thelpers.screen_setup(nil, "['cmd.exe']", 30) screen = thelpers.screen_setup(nil, "['cmd.exe']", 30)
else else
screen = thelpers.screen_setup(nil, "['sh']", 30) screen = thelpers.screen_setup(nil, "['sh']", 30)
end end
curbufmeths.set_option('scrollback', 0) curbufmeths.set_option('scrollback', 0)
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), iswin() and '\r' or '\n')) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
screen:expect{any='30: line '} screen:expect{any='30: line '}
retry(nil, nil, function() expect_lines(7) end) retry(nil, nil, function() expect_lines(7) end)
end) end)
it('deletes lines (only) if necessary', function() it('deletes lines (only) if necessary', function()
local screen local screen
if iswin() then if is_os('win') then
command([[let $PROMPT='$$']]) command([[let $PROMPT='$$']])
screen = thelpers.screen_setup(nil, "['cmd.exe']", 30) screen = thelpers.screen_setup(nil, "['cmd.exe']", 30)
else else
@ -424,7 +424,7 @@ describe("'scrollback' option", function()
-- Wait for prompt. -- Wait for prompt.
screen:expect{any='%$'} screen:expect{any='%$'}
feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), iswin() and '\r' or '\n')) feed_data(('%s REP 31 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
screen:expect{any='30: line '} screen:expect{any='30: line '}
retry(nil, nil, function() expect_lines(33, 2) end) retry(nil, nil, function() expect_lines(33, 2) end)
@ -437,8 +437,8 @@ describe("'scrollback' option", function()
-- 'scrollback' option is synchronized with the internal sb_buffer. -- 'scrollback' option is synchronized with the internal sb_buffer.
command('sleep 100m') command('sleep 100m')
feed_data(('%s REP 41 line%s'):format(testprg('shell-test'), iswin() and '\r' or '\n')) feed_data(('%s REP 41 line%s'):format(testprg('shell-test'), is_os('win') and '\r' or '\n'))
if iswin() then if is_os('win') then
screen:expect{grid=[[ screen:expect{grid=[[
37: line | 37: line |
38: line | 38: line |
@ -462,8 +462,8 @@ describe("'scrollback' option", function()
expect_lines(58) expect_lines(58)
-- Verify off-screen state -- Verify off-screen state
matches((iswin() and '^36: line[ ]*$' or '^35: line[ ]*$'), eval("getline(line('w0') - 1)")) matches((is_os('win') and '^36: line[ ]*$' or '^35: line[ ]*$'), eval("getline(line('w0') - 1)"))
matches((iswin() and '^27: line[ ]*$' or '^26: line[ ]*$'), eval("getline(line('w0') - 10)")) matches((is_os('win') and '^27: line[ ]*$' or '^26: line[ ]*$'), eval("getline(line('w0') - 10)"))
end) end)
it('deletes extra lines immediately', function() it('deletes extra lines immediately', function()
@ -607,7 +607,7 @@ describe("pending scrollback line handling", function()
end) end)
it("does not crash after nvim_buf_call #14891", function() it("does not crash after nvim_buf_call #14891", function()
skip(iswin()) skip(is_os('win'))
exec_lua [[ exec_lua [[
local a = vim.api local a = vim.api
local bufnr = a.nvim_create_buf(false, true) local bufnr = a.nvim_create_buf(false, true)

View File

@ -5,7 +5,6 @@
-- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode -- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Bracketed-Paste-Mode
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local uname = helpers.uname
local thelpers = require('test.functional.terminal.helpers') local thelpers = require('test.functional.terminal.helpers')
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
@ -22,9 +21,10 @@ local ok = helpers.ok
local read_file = helpers.read_file local read_file = helpers.read_file
local funcs = helpers.funcs local funcs = helpers.funcs
local meths = helpers.meths local meths = helpers.meths
local isCI = helpers.isCI local is_ci = helpers.is_ci
local is_os = helpers.is_os
if helpers.skip(helpers.iswin()) then return end if helpers.skip(helpers.is_os('win')) then return end
describe('TUI', function() describe('TUI', function()
local screen local screen
@ -822,7 +822,7 @@ describe('TUI', function()
end) end)
it('paste: terminal mode', function() it('paste: terminal mode', function()
if isCI('github') then if is_ci('github') then
pending("tty-test complains about not owning the terminal -- actions/runner#241") pending("tty-test complains about not owning the terminal -- actions/runner#241")
end end
child_exec_lua('vim.o.statusline="^^^^^^^"') child_exec_lua('vim.o.statusline="^^^^^^^"')
@ -1089,7 +1089,7 @@ describe('TUI', function()
-- "bracketed paste" -- "bracketed paste"
feed_data('\027[200~'..expected..'\027[201~') feed_data('\027[200~'..expected..'\027[201~')
-- FIXME: Data race between the two feeds -- FIXME: Data race between the two feeds
if uname() == 'freebsd' then screen:sleep(1) end if is_os('freebsd') then screen:sleep(1) end
feed_data(' end') feed_data(' end')
expected = expected..' end' expected = expected..' end'
screen:expect([[ screen:expect([[
@ -1329,7 +1329,7 @@ describe('TUI', function()
end) end)
it('forwards :term palette colors with termguicolors', function() it('forwards :term palette colors with termguicolors', function()
if isCI('github') then if is_ci('github') then
pending("tty-test complains about not owning the terminal -- actions/runner#241") pending("tty-test complains about not owning the terminal -- actions/runner#241")
end end
screen:set_rgb_cterm(true) screen:set_rgb_cterm(true)
@ -1668,7 +1668,6 @@ 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 = (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={}})
@ -1771,7 +1770,7 @@ describe("TUI 't_Co' (terminal colors)", function()
-- which is raised to 16 by COLORTERM. -- which is raised to 16 by COLORTERM.
it("TERM=screen no COLORTERM uses 8/256 colors", function() it("TERM=screen no COLORTERM uses 8/256 colors", function()
if is_freebsd then if is_os('freebsd') then
assert_term_colors("screen", nil, 256) assert_term_colors("screen", nil, 256)
else else
assert_term_colors("screen", nil, 8) assert_term_colors("screen", nil, 8)
@ -1779,7 +1778,7 @@ describe("TUI 't_Co' (terminal colors)", function()
end) end)
it("TERM=screen COLORTERM=screen uses 16/256 colors", function() it("TERM=screen COLORTERM=screen uses 16/256 colors", function()
if is_freebsd then if is_os('freebsd') then
assert_term_colors("screen", "screen", 256) assert_term_colors("screen", "screen", 256)
else else
assert_term_colors("screen", "screen", 16) assert_term_colors("screen", "screen", 16)
@ -1942,8 +1941,6 @@ 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(uname(), 'bsd')
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()
@ -1969,11 +1966,11 @@ 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 uname() == "openbsd" then if is_os('openbsd') then
assert_term("xterm", "xterm") assert_term("xterm", "xterm")
elseif is_bsd then -- BSD lacks terminfo, builtin is always used. elseif is_os('bsd') then -- BSD lacks terminfo, builtin is always used.
assert_term("xterm", "builtin_xterm") assert_term("xterm", "builtin_xterm")
elseif is_macos then elseif is_os('mac') then
local status, _ = pcall(assert_term, "xterm", "xterm") local status, _ = pcall(assert_term, "xterm", "xterm")
if not status then if not status then
pending("macOS: unibilium could not find terminfo") pending("macOS: unibilium could not find terminfo")

View File

@ -3,12 +3,12 @@ local thelpers = require('test.functional.terminal.helpers')
local feed_data = thelpers.feed_data local feed_data = thelpers.feed_data
local feed, clear = helpers.feed, helpers.clear local feed, clear = helpers.feed, helpers.clear
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = helpers.poke_eventloop
local iswin = helpers.iswin
local command = helpers.command local command = helpers.command
local retry = helpers.retry local retry = helpers.retry
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe(':terminal window', function() describe(':terminal window', function()
local screen local screen
@ -19,7 +19,7 @@ describe(':terminal window', function()
end) end)
it('sets topline correctly #8556', function() it('sets topline correctly #8556', function()
skip(iswin()) skip(is_os('win'))
-- Test has hardcoded assumptions of dimensions. -- Test has hardcoded assumptions of dimensions.
eq(7, eval('&lines')) eq(7, eval('&lines'))
feed_data('\n\n\n') -- Add blank lines. feed_data('\n\n\n') -- Add blank lines.
@ -55,7 +55,7 @@ describe(':terminal window', function()
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]]) ]])
skip(iswin(), 'win: :terminal resize is unreliable #7007') skip(is_os('win'), 'win: :terminal resize is unreliable #7007')
-- numberwidth=9 -- numberwidth=9
feed([[<C-\><C-N>]]) feed([[<C-\><C-N>]])
@ -171,7 +171,7 @@ describe(':terminal with multigrid', function()
]]) ]])
screen:try_resize_grid(2, 20, 10) screen:try_resize_grid(2, 20, 10)
if iswin() then if is_os('win') then
screen:expect{any="rows: 10, cols: 20"} screen:expect{any="rows: 10, cols: 20"}
else else
screen:expect([[ screen:expect([[
@ -200,7 +200,7 @@ describe(':terminal with multigrid', function()
end end
screen:try_resize_grid(2, 70, 3) screen:try_resize_grid(2, 70, 3)
if iswin() then if is_os('win') then
screen:expect{any="rows: 3, cols: 70"} screen:expect{any="rows: 3, cols: 70"}
else else
screen:expect([[ screen:expect([[
@ -222,7 +222,7 @@ describe(':terminal with multigrid', function()
end end
screen:try_resize_grid(2, 0, 0) screen:try_resize_grid(2, 0, 0)
if iswin() then if is_os('win') then
screen:expect{any="rows: 6, cols: 50"} screen:expect{any="rows: 6, cols: 50"}
else else
screen:expect([[ screen:expect([[

View File

@ -8,9 +8,9 @@ local command = helpers.command
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local meths = helpers.meths local meths = helpers.meths
local iswin = helpers.iswin
local sleep = helpers.sleep local sleep = helpers.sleep
local retry = helpers.retry local retry = helpers.retry
local is_os = helpers.is_os
describe(':terminal', function() describe(':terminal', function()
local screen local screen
@ -96,7 +96,7 @@ describe(':terminal', function()
local w1, h1 = screen._width - 3, screen._height - 2 local w1, h1 = screen._width - 3, screen._height - 2
local w2, h2 = w1 - 6, h1 - 3 local w2, h2 = w1 - 6, h1 - 3
if iswin() then if is_os('win') then
-- win: SIGWINCH is unreliable, use a weaker test. #7506 -- win: SIGWINCH is unreliable, use a weaker test. #7506
retry(3, 30000, function() retry(3, 30000, function()
screen:try_resize(w1, h1) screen:try_resize(w1, h1)

View File

@ -5,7 +5,7 @@ local eq = helpers.eq
local insert = helpers.insert local insert = helpers.insert
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local feed = helpers.feed local feed = helpers.feed
local iswin = helpers.iswin local is_os = helpers.is_os
local skip = helpers.skip local skip = helpers.skip
before_each(clear) before_each(clear)
@ -684,7 +684,7 @@ int x = INT_MAX;
end) end)
it("should not inject bad languages", function() it("should not inject bad languages", function()
skip(iswin()) skip(is_os('win'))
exec_lua([=[ exec_lua([=[
vim.treesitter.add_directive("inject-bad!", function(match, _, _, pred, metadata) vim.treesitter.add_directive("inject-bad!", function(match, _, _, pred, metadata)
metadata.language = "{" metadata.language = "{"

View File

@ -4,10 +4,10 @@ local clear, feed = helpers.clear, helpers.feed
local source = helpers.source local source = helpers.source
local command = helpers.command local command = helpers.command
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local uname = helpers.uname
local exec = helpers.exec local exec = helpers.exec
local eval = helpers.eval local eval = helpers.eval
local eq = helpers.eq local eq = helpers.eq
local is_os = helpers.is_os
local function new_screen(opt) local function new_screen(opt)
local screen = Screen.new(25, 5) local screen = Screen.new(25, 5)
@ -717,7 +717,7 @@ describe('cmdline redraw', function()
end) end)
it('with <Cmd>', function() it('with <Cmd>', function()
if string.find(uname(), 'bsd') then if is_os('bsd') then
pending('FIXME #10804') pending('FIXME #10804')
end end
command('cmap a <Cmd>call sin(0)<CR>') -- no-op command('cmap a <Cmd>call sin(0)<CR>') -- no-op

View File

@ -51,7 +51,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' == helpers.uname() then if helpers.is_os('openbsd') then
pending('FIXME #10804') pending('FIXME #10804')
end end
startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"') startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"')

View File

@ -4,10 +4,10 @@ local Screen = require('test.functional.ui.screen')
local clear, insert = helpers.clear, helpers.insert local clear, insert = helpers.clear, helpers.insert
local command = helpers.command local command = helpers.command
local meths = helpers.meths local meths = helpers.meths
local iswin = helpers.iswin
local testprg = helpers.testprg local testprg = helpers.testprg
local thelpers = require('test.functional.terminal.helpers') local thelpers = require('test.functional.terminal.helpers')
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe('ext_hlstate detailed highlights', function() describe('ext_hlstate detailed highlights', function()
local screen local screen
@ -183,7 +183,7 @@ describe('ext_hlstate detailed highlights', function()
end) end)
it("work with :terminal", function() it("work with :terminal", function()
skip(iswin()) skip(is_os('win'))
screen:set_default_attr_ids({ screen:set_default_attr_ids({
[1] = {{}, {{hi_name = "TermCursorNC", ui_name = "TermCursorNC", kind = "ui"}}}, [1] = {{}, {{hi_name = "TermCursorNC", ui_name = "TermCursorNC", kind = "ui"}}},
@ -212,7 +212,7 @@ describe('ext_hlstate detailed highlights', function()
thelpers.set_bold() thelpers.set_bold()
thelpers.feed_data('z\n') thelpers.feed_data('z\n')
-- TODO(bfredl): check if this distinction makes sense -- TODO(bfredl): check if this distinction makes sense
if iswin() then if is_os('win') then
screen:expect([[ screen:expect([[
^tty ready | ^tty ready |
x {5:y z} | x {5:y z} |
@ -238,7 +238,7 @@ describe('ext_hlstate detailed highlights', function()
thelpers.feed_termcode("[A") thelpers.feed_termcode("[A")
thelpers.feed_termcode("[2C") thelpers.feed_termcode("[2C")
if iswin() then if is_os('win') then
screen:expect([[ screen:expect([[
^tty ready | ^tty ready |
x {6:y}{5: z} | x {6:y}{5: z} |

View File

@ -9,12 +9,13 @@ local meths = helpers.meths
local async_meths = helpers.async_meths local async_meths = helpers.async_meths
local test_build_dir = helpers.test_build_dir local test_build_dir = helpers.test_build_dir
local nvim_prog = helpers.nvim_prog local nvim_prog = helpers.nvim_prog
local iswin = helpers.iswin
local exec = helpers.exec local exec = helpers.exec
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua local exec_lua = helpers.exec_lua
local poke_eventloop = helpers.poke_eventloop local poke_eventloop = helpers.poke_eventloop
local assert_alive = helpers.assert_alive local assert_alive = helpers.assert_alive
local is_os = helpers.is_os
local is_ci = helpers.is_ci
describe('ui/ext_messages', function() describe('ui/ext_messages', function()
local screen local screen
@ -1496,7 +1497,7 @@ describe('ui/msg_puts_printf', function()
screen = Screen.new(25, 5) screen = Screen.new(25, 5)
screen:attach() screen:attach()
if iswin() then if is_os('win') then
if os.execute('chcp 932 > NUL 2>&1') ~= 0 then if os.execute('chcp 932 > NUL 2>&1') ~= 0 then
pending('missing japanese language features', function() end) pending('missing japanese language features', function() end)
return return
@ -1507,7 +1508,7 @@ describe('ui/msg_puts_printf', function()
if (exc_exec('lang ja_JP.UTF-8') ~= 0) then if (exc_exec('lang ja_JP.UTF-8') ~= 0) then
pending('Locale ja_JP.UTF-8 not supported', function() end) pending('Locale ja_JP.UTF-8 not supported', function() end)
return return
elseif helpers.isCI() then elseif is_ci() then
-- Fails non--Windows CI. Message catalog directory issue? -- Fails non--Windows CI. Message catalog directory issue?
pending('fails on unix CI', function() end) pending('fails on unix CI', function() end)
return return

View File

@ -6,7 +6,6 @@ local mkdir, write_file, rmdir = helpers.mkdir, helpers.write_file, helpers.rmdi
local eq = helpers.eq local eq = helpers.eq
local feed = helpers.feed local feed = helpers.feed
local feed_command = helpers.feed_command local feed_command = helpers.feed_command
local iswin = helpers.iswin
local clear = helpers.clear local clear = helpers.clear
local command = helpers.command local command = helpers.command
local testprg = helpers.testprg local testprg = helpers.testprg
@ -14,6 +13,7 @@ local nvim_dir = helpers.nvim_dir
local has_powershell = helpers.has_powershell local has_powershell = helpers.has_powershell
local set_shell_powershell = helpers.set_shell_powershell local set_shell_powershell = helpers.set_shell_powershell
local skip = helpers.skip local skip = helpers.skip
local is_os = helpers.is_os
describe("shell command :!", function() describe("shell command :!", function()
local screen local screen
@ -37,7 +37,7 @@ describe("shell command :!", function()
end) end)
it("displays output without LF/EOF. #4646 #4569 #3772", function() it("displays output without LF/EOF. #4646 #4569 #3772", function()
skip(iswin()) skip(is_os('win'))
-- NOTE: We use a child nvim (within a :term buffer) -- NOTE: We use a child nvim (within a :term buffer)
-- to avoid triggering a UI flush. -- to avoid triggering a UI flush.
child_session.feed_data(":!printf foo; sleep 200\n") child_session.feed_data(":!printf foo; sleep 200\n")
@ -53,7 +53,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()
skip('openbsd' == helpers.uname(), 'FIXME #10804') skip(is_os('openbsd'), 'FIXME #10804')
child_session.feed_data((":!%s REP 30001 foo\n"):format(testprg('shell-test'))) child_session.feed_data((":!%s REP 30001 foo\n"):format(testprg('shell-test')))
-- If we observe any line starting with a dot, then throttling occurred. -- If we observe any line starting with a dot, then throttling occurred.
@ -95,7 +95,7 @@ describe("shell command :!", function()
end) end)
it('handles control codes', function() it('handles control codes', function()
skip(iswin(), 'missing printf') skip(is_os('win'), 'missing printf')
local screen = Screen.new(50, 4) local screen = Screen.new(50, 4)
screen:set_default_attr_ids { screen:set_default_attr_ids {
[1] = {bold = true, reverse = true}; [1] = {bold = true, reverse = true};
@ -170,10 +170,10 @@ describe("shell command :!", function()
end) end)
it("doesn't truncate Last line of shell output #3269", function() it("doesn't truncate Last line of shell output #3269", function()
command(helpers.iswin() command(is_os('win')
and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]] and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]]
or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]]) or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]])
local result = (helpers.iswin() local result = (is_os('win')
and [[:!dir /b bang_filter_spec]] and [[:!dir /b bang_filter_spec]]
or [[:!ls bang_filter_spec ]]) or [[:!ls bang_filter_spec ]])
feed([[\l]]) feed([[\l]])
@ -212,7 +212,7 @@ describe("shell command :!", function()
it('handles multibyte sequences split over buffer boundaries', function() it('handles multibyte sequences split over buffer boundaries', function()
command('cd '..nvim_dir) command('cd '..nvim_dir)
local cmd = iswin() and '!shell-test UTF-8 ' or '!./shell-test UTF-8' local cmd = is_os('win') and '!shell-test UTF-8 ' or '!./shell-test UTF-8'
feed_command(cmd) feed_command(cmd)
-- Note: only the first example of split composed char works -- Note: only the first example of split composed char works
screen:expect([[ screen:expect([[
@ -262,7 +262,7 @@ describe("shell command :!", function()
| |
Press ENTER or type command to continue^ | Press ENTER or type command to continue^ |
]]) ]])
if iswin() then if is_os('win') then
feed_command([[!& 'cmd.exe' /c 'echo $a']]) feed_command([[!& 'cmd.exe' /c 'echo $a']])
screen:expect([[ screen:expect([[
:!& 'cmd.exe' /c 'echo $a' | :!& 'cmd.exe' /c 'echo $a' |

View File

@ -5,8 +5,8 @@ local feed, command = helpers.feed, helpers.command
local insert = helpers.insert local insert = helpers.insert
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local iswin = helpers.iswin
local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua local funcs, meths, exec_lua = helpers.funcs, helpers.meths, helpers.exec_lua
local is_os = helpers.is_os
describe('screen', function() describe('screen', function()
local screen local screen
@ -128,18 +128,18 @@ local function screen_tests(linegrid)
end) end)
it('has correct default title with named file', function() it('has correct default title with named file', function()
local expected = (iswin() and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM') local expected = (is_os('win') and 'myfile (C:\\mydir) - NVIM' or 'myfile (/mydir) - NVIM')
command('set title') command('set title')
command(iswin() and 'file C:\\mydir\\myfile' or 'file /mydir/myfile') command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
screen:expect(function() screen:expect(function()
eq(expected, screen.title) eq(expected, screen.title)
end) end)
end) end)
describe('is not changed by', function() describe('is not changed by', function()
local file1 = iswin() and 'C:\\mydir\\myfile1' or '/mydir/myfile1' local file1 = is_os('win') and 'C:\\mydir\\myfile1' or '/mydir/myfile1'
local file2 = iswin() and 'C:\\mydir\\myfile2' or '/mydir/myfile2' local file2 = is_os('win') and 'C:\\mydir\\myfile2' or '/mydir/myfile2'
local expected = (iswin() and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM') local expected = (is_os('win') and 'myfile1 (C:\\mydir) - NVIM' or 'myfile1 (/mydir) - NVIM')
local buf2 local buf2
before_each(function() before_each(function()

View File

@ -5,8 +5,8 @@ local Screen = require('test.functional.ui.screen')
local clear = helpers.clear local clear = helpers.clear
local feed = helpers.feed local feed = helpers.feed
local insert = helpers.insert local insert = helpers.insert
local uname = helpers.uname
local command = helpers.command local command = helpers.command
local is_os = helpers.is_os
describe("'spell'", function() describe("'spell'", function()
local screen local screen
@ -27,7 +27,7 @@ describe("'spell'", function()
end) end)
it('joins long lines #7937', function() it('joins long lines #7937', function()
if uname() == 'openbsd' then pending('FIXME #12104', function() end) return end if is_os('openbsd') then pending('FIXME #12104', function() end) return end
command('set spell') command('set spell')
insert([[ insert([[
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod

View File

@ -1,13 +1,13 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command local clear, feed, command = helpers.clear, helpers.feed, helpers.command
local iswin = helpers.iswin
local funcs = helpers.funcs local funcs = helpers.funcs
local meths = helpers.meths local meths = helpers.meths
local eq = helpers.eq local eq = helpers.eq
local eval = helpers.eval local eval = helpers.eval
local retry = helpers.retry local retry = helpers.retry
local testprg = helpers.testprg local testprg = helpers.testprg
local is_os = helpers.is_os
describe("'wildmenu'", function() describe("'wildmenu'", function()
local screen local screen
@ -159,7 +159,7 @@ describe("'wildmenu'", function()
-- must wait the full timeout. So make it reasonable. -- must wait the full timeout. So make it reasonable.
screen.timeout = 1000 screen.timeout = 1000
if not iswin() then if not is_os('win') then
command('set shell=sh') -- Need a predictable "$" prompt. command('set shell=sh') -- Need a predictable "$" prompt.
command('let $PS1 = "$"') command('let $PS1 = "$"')
end end
@ -169,7 +169,7 @@ describe("'wildmenu'", function()
-- Check for a shell prompt to verify that the terminal loaded. -- Check for a shell prompt to verify that the terminal loaded.
retry(nil, nil, function() retry(nil, nil, function()
if iswin() then if is_os('win') then
eq('Microsoft', eval("matchstr(join(getline(1, '$')), 'Microsoft')")) eq('Microsoft', eval("matchstr(join(getline(1, '$')), 'Microsoft')"))
else else
eq('$', eval([[matchstr(getline(1), '\$')]])) eq('$', eval([[matchstr(getline(1), '\$')]]))

View File

@ -71,13 +71,13 @@ describe("backtick expansion", function()
end) end)
it("with default 'shell'", function() it("with default 'shell'", function()
if helpers.iswin() then if helpers.is_os('win') then
command(":silent args `dir /b *2`") command(":silent args `dir /b *2`")
else else
command(":silent args `echo ***2`") command(":silent args `echo ***2`")
end end
eq({ "file2", }, eval("argv()")) eq({ "file2", }, eval("argv()"))
if helpers.iswin() then if helpers.is_os('win') then
command(":silent args `dir /s/b *4`") command(":silent args `dir /s/b *4`")
eq({ "subdir\\file4", }, eval("map(argv(), 'fnamemodify(v:val, \":.\")')")) eq({ "subdir\\file4", }, eval("map(argv(), 'fnamemodify(v:val, \":.\")')"))
else else

View File

@ -1,15 +1,16 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local eq, clear, call, iswin, write_file, command = local eq, clear, call, write_file, command =
helpers.eq, helpers.clear, helpers.call, helpers.iswin, helpers.write_file, helpers.eq, helpers.clear, helpers.call, helpers.write_file,
helpers.command helpers.command
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local eval = helpers.eval local eval = helpers.eval
local is_os = helpers.is_os
describe('executable()', function() describe('executable()', function()
before_each(clear) before_each(clear)
it('returns 1 for commands in $PATH', function() it('returns 1 for commands in $PATH', function()
local exe = iswin() and 'ping' or 'ls' local exe = is_os('win') and 'ping' or 'ls'
eq(1, call('executable', exe)) eq(1, call('executable', exe))
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
eq(1, call('executable', 'null')) eq(1, call('executable', 'null'))
@ -17,7 +18,7 @@ describe('executable()', function()
eq(1, call('executable', 'false')) eq(1, call('executable', 'false'))
end) end)
if iswin() then if is_os('win') then
it('exepath respects shellslash', function() it('exepath respects shellslash', function()
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
eq([[test\functional\fixtures\bin\null.CMD]], call('fnamemodify', call('exepath', 'null'), ':.')) eq([[test\functional\fixtures\bin\null.CMD]], call('fnamemodify', call('exepath', 'null'), ':.'))
@ -56,8 +57,8 @@ describe('executable()', function()
-- Some executable in build/bin/, *not* in $PATH nor CWD. -- Some executable in build/bin/, *not* in $PATH nor CWD.
local sibling_exe = 'printargs-test' local sibling_exe = 'printargs-test'
-- Windows: siblings are in Nvim's "pseudo-$PATH". -- Windows: siblings are in Nvim's "pseudo-$PATH".
local expected = iswin() and 1 or 0 local expected = is_os('win') and 1 or 0
if iswin() then if is_os('win') then
eq('arg1=lemon;arg2=sky;arg3=tree;', eq('arg1=lemon;arg2=sky;arg3=tree;',
call('system', sibling_exe..' lemon sky tree')) call('system', sibling_exe..' lemon sky tree'))
end end
@ -69,7 +70,7 @@ describe('executable()', function()
clear() clear()
write_file('Xtest_not_executable', 'non-executable file') write_file('Xtest_not_executable', 'non-executable file')
write_file('Xtest_executable', 'executable file (exec-bit set)') write_file('Xtest_executable', 'executable file (exec-bit set)')
if not iswin() then -- N/A for Windows. if not is_os('win') then -- N/A for Windows.
call('system', {'chmod', '-x', 'Xtest_not_executable'}) call('system', {'chmod', '-x', 'Xtest_not_executable'})
call('system', {'chmod', '+x', 'Xtest_executable'}) call('system', {'chmod', '+x', 'Xtest_executable'})
end end
@ -90,14 +91,17 @@ describe('executable()', function()
end) end)
it('set, qualified as a path', function() it('set, qualified as a path', function()
local expected = iswin() and 0 or 1 local expected = is_os('win') and 0 or 1
eq(expected, call('executable', './Xtest_executable')) eq(expected, call('executable', './Xtest_executable'))
end) end)
end) end)
end) end)
describe('executable() (Windows)', function() describe('executable() (Windows)', function()
if not iswin() then return end -- N/A for Unix. if not is_os('win') then
pending('N/A for non-windows')
return
end
local exts = {'bat', 'exe', 'com', 'cmd'} local exts = {'bat', 'exe', 'com', 'cmd'}
setup(function() setup(function()

View File

@ -8,7 +8,7 @@ local funcs = helpers.funcs
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
local command = helpers.command local command = helpers.command
local feed = helpers.feed local feed = helpers.feed
local iswin = helpers.iswin local is_os = helpers.is_os
describe('execute()', function() describe('execute()', function()
before_each(clear) before_each(clear)
@ -265,7 +265,7 @@ describe('execute()', function()
-- This deviates from vim behavior, but is consistent -- This deviates from vim behavior, but is consistent
-- with how nvim currently displays the output. -- with how nvim currently displays the output.
it('captures shell-command output', function() it('captures shell-command output', function()
local win_lf = iswin() and '\13' or '' local win_lf = is_os('win') and '\13' or ''
eq('\n:!echo foo\r\n\nfoo'..win_lf..'\n', funcs.execute('!echo foo')) eq('\n:!echo foo\r\n\nfoo'..win_lf..'\n', funcs.execute('!echo foo'))
end) end)

View File

@ -1,19 +1,20 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local eq, clear, call, iswin = local eq, clear, call =
helpers.eq, helpers.clear, helpers.call, helpers.iswin helpers.eq, helpers.clear, helpers.call
local command = helpers.command local command = helpers.command
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local matches = helpers.matches local matches = helpers.matches
local is_os = helpers.is_os
describe('exepath()', function() describe('exepath()', function()
before_each(clear) before_each(clear)
it('returns 1 for commands in $PATH', function() it('returns 1 for commands in $PATH', function()
local exe = iswin() and 'ping' or 'ls' local exe = is_os('win') and 'ping' or 'ls'
local ext_pat = iswin() and '%.EXE$' or '$' local ext_pat = is_os('win') and '%.EXE$' or '$'
matches(exe .. ext_pat, call('exepath', exe)) matches(exe .. ext_pat, call('exepath', exe))
command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")') command('let $PATH = fnamemodify("./test/functional/fixtures/bin", ":p")')
ext_pat = iswin() and '%.CMD$' or '$' ext_pat = is_os('win') and '%.CMD$' or '$'
matches('null' .. ext_pat, call('exepath', 'null')) matches('null' .. ext_pat, call('exepath', 'null'))
matches('true' .. ext_pat, call('exepath', 'true')) matches('true' .. ext_pat, call('exepath', 'true'))
matches('false' .. ext_pat, call('exepath', 'false')) matches('false' .. ext_pat, call('exepath', 'false'))
@ -30,7 +31,7 @@ describe('exepath()', function()
end end
end) end)
if iswin() then if is_os('win') then
it('append extension if omitted', function() it('append extension if omitted', function()
local filename = 'cmd' local filename = 'cmd'
local pathext = '.exe' local pathext = '.exe'

View File

@ -1,12 +1,12 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear local clear = helpers.clear
local eq = helpers.eq local eq = helpers.eq
local iswin = helpers.iswin
local fnamemodify = helpers.funcs.fnamemodify local fnamemodify = helpers.funcs.fnamemodify
local getcwd = helpers.funcs.getcwd local getcwd = helpers.funcs.getcwd
local command = helpers.command local command = helpers.command
local write_file = helpers.write_file local write_file = helpers.write_file
local alter_slashes = helpers.alter_slashes local alter_slashes = helpers.alter_slashes
local is_os = helpers.is_os
local function eq_slashconvert(expected, got) local function eq_slashconvert(expected, got)
eq(alter_slashes(expected), alter_slashes(got)) eq(alter_slashes(expected), alter_slashes(got))
@ -27,7 +27,7 @@ describe('fnamemodify()', function()
local root = helpers.pathroot() local root = helpers.pathroot()
eq(root, fnamemodify([[/]], ':p:h')) eq(root, fnamemodify([[/]], ':p:h'))
eq(root, fnamemodify([[/]], ':p')) eq(root, fnamemodify([[/]], ':p'))
if iswin() then if is_os('win') then
eq(root, fnamemodify([[\]], ':p:h')) eq(root, fnamemodify([[\]], ':p:h'))
eq(root, fnamemodify([[\]], ':p')) eq(root, fnamemodify([[\]], ':p'))
command('set shellslash') command('set shellslash')
@ -114,7 +114,7 @@ describe('fnamemodify()', function()
it('handles shell escape', function() it('handles shell escape', function()
local expected local expected
if iswin() then if is_os('win') then
-- we expand with double-quotes on Windows -- we expand with double-quotes on Windows
expected = [["hello there! quote ' newline]] .. '\n' .. [["]] expected = [["hello there! quote ' newline]] .. '\n' .. [["]]
else else

View File

@ -9,12 +9,12 @@ local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear local clear = helpers.clear
local eval = helpers.eval local eval = helpers.eval
local iswin = helpers.iswin
local matches = helpers.matches local matches = helpers.matches
local is_os = helpers.is_os
before_each(clear) before_each(clear)
it('windowsversion()', function() it('windowsversion()', function()
clear() clear()
matches(iswin() and '^%d+%.%d+$' or '^$', eval('windowsversion()')) matches(is_os('win') and '^%d+%.%d+$' or '^$', eval('windowsversion()'))
end) end)

View File

@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq local eq = helpers.eq
local clear = helpers.clear local clear = helpers.clear
local funcs = helpers.funcs local funcs = helpers.funcs
local iswin = helpers.iswin local is_os = helpers.is_os
describe('has()', function() describe('has()', function()
before_each(clear) before_each(clear)
@ -51,7 +51,7 @@ describe('has()', function()
end) end)
it('"unnamedplus"', function() it('"unnamedplus"', function()
if (not iswin()) and funcs.has("clipboard") == 1 then if (not is_os('win')) and funcs.has("clipboard") == 1 then
eq(1, funcs.has("unnamedplus")) eq(1, funcs.has("unnamedplus"))
else else
eq(0, funcs.has("unnamedplus")) eq(0, funcs.has("unnamedplus"))

View File

@ -3,7 +3,7 @@ local eq = helpers.eq
local ok = helpers.ok local ok = helpers.ok
local call = helpers.call local call = helpers.call
local clear = helpers.clear local clear = helpers.clear
local iswin = helpers.iswin local is_os = helpers.is_os
describe('hostname()', function() describe('hostname()', function()
before_each(clear) before_each(clear)
@ -13,8 +13,8 @@ describe('hostname()', function()
ok(string.len(actual) > 0) ok(string.len(actual) > 0)
if call('executable', 'hostname') == 1 then if call('executable', 'hostname') == 1 then
local expected = string.gsub(call('system', 'hostname'), '[\n\r]', '') local expected = string.gsub(call('system', 'hostname'), '[\n\r]', '')
eq((iswin() and expected:upper() or expected), eq((is_os('win') and expected:upper() or expected),
(iswin() and actual:upper() or actual)) (is_os('win') and actual:upper() or actual))
end end
end) end)
end) end)

View File

@ -5,7 +5,7 @@ local eval, eq = helpers.eval, helpers.eq
local command = helpers.command local command = helpers.command
local nvim = helpers.nvim local nvim = helpers.nvim
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local iswin = helpers.iswin local is_os = helpers.is_os
describe('msgpack*() functions', function() describe('msgpack*() functions', function()
before_each(clear) before_each(clear)
@ -467,7 +467,7 @@ describe('msgpackparse() function', function()
eval(cmd) eval(cmd)
eval(cmd) -- do it again (try to force segfault) eval(cmd) -- do it again (try to force segfault)
local api_info = eval(cmd) -- do it again local api_info = eval(cmd) -- do it again
if iswin() then if is_os('win') then
helpers.assert_alive() helpers.assert_alive()
pending('msgpackparse() has a bug on windows') pending('msgpackparse() has a bug on windows')
return return

View File

@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')(after_each) local helpers = require('test.functional.helpers')(after_each)
local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval local eq, neq, eval = helpers.eq, helpers.neq, helpers.eval
local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths
local iswin = helpers.iswin
local ok = helpers.ok local ok = helpers.ok
local matches = helpers.matches local matches = helpers.matches
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local mkdir = helpers.mkdir local mkdir = helpers.mkdir
local is_os = helpers.is_os
local function clear_serverlist() local function clear_serverlist()
for _, server in pairs(funcs.serverlist()) do for _, server in pairs(funcs.serverlist()) do
@ -19,7 +19,7 @@ describe('server', function()
mkdir(dir) mkdir(dir)
clear({ env={ XDG_RUNTIME_DIR=dir } }) clear({ env={ XDG_RUNTIME_DIR=dir } })
matches(dir, funcs.stdpath('run')) matches(dir, funcs.stdpath('run'))
if not iswin() then if not is_os('win') then
matches(dir, funcs.serverstart()) matches(dir, funcs.serverstart())
end end
end) end)
@ -65,7 +65,7 @@ describe('server', function()
eq('', meths.get_vvar('servername')) eq('', meths.get_vvar('servername'))
-- v:servername and $NVIM take the next available server. -- v:servername and $NVIM take the next available server.
local servername = (iswin() and [[\\.\pipe\Xtest-functional-server-pipe]] local servername = (is_os('win') and [[\\.\pipe\Xtest-functional-server-pipe]]
or './Xtest-functional-server-socket') or './Xtest-functional-server-socket')
funcs.serverstart(servername) funcs.serverstart(servername)
eq(servername, meths.get_vvar('servername')) eq(servername, meths.get_vvar('servername'))
@ -130,7 +130,7 @@ describe('server', function()
local n = eval('len(serverlist())') local n = eval('len(serverlist())')
-- Add some servers. -- Add some servers.
local servs = (iswin() local servs = (is_os('win')
and { [[\\.\pipe\Xtest-pipe0934]], [[\\.\pipe\Xtest-pipe4324]] } and { [[\\.\pipe\Xtest-pipe0934]], [[\\.\pipe\Xtest-pipe4324]] }
or { [[./Xtest-pipe0934]], [[./Xtest-pipe4324]] }) or { [[./Xtest-pipe0934]], [[./Xtest-pipe4324]] })
for _, s in ipairs(servs) do for _, s in ipairs(servs) do
@ -164,7 +164,7 @@ describe('startup --listen', function()
end) end)
it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function() it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function()
local addr = (iswin() and [[\\.\pipe\Xtest-listen-pipe]] local addr = (is_os('win') and [[\\.\pipe\Xtest-listen-pipe]]
or './Xtest-listen-pipe') or './Xtest-listen-pipe')
clear({ env={ NVIM_LISTEN_ADDRESS='./Xtest-env-pipe' }, clear({ env={ NVIM_LISTEN_ADDRESS='./Xtest-env-pipe' },
args={ '--listen', addr } }) args={ '--listen', addr } })

View File

@ -9,9 +9,9 @@ local command = helpers.command
local insert = helpers.insert local insert = helpers.insert
local expect = helpers.expect local expect = helpers.expect
local exc_exec = helpers.exc_exec local exc_exec = helpers.exc_exec
local iswin = helpers.iswin
local os_kill = helpers.os_kill local os_kill = helpers.os_kill
local pcall_err = helpers.pcall_err local pcall_err = helpers.pcall_err
local is_os = helpers.is_os
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
@ -85,7 +85,7 @@ describe('system()', function()
end) end)
it('does NOT run in shell', function() it('does NOT run in shell', function()
if iswin() then if is_os('win') then
eq("%PATH%\n", eval("system(['powershell', '-NoProfile', '-NoLogo', '-ExecutionPolicy', 'RemoteSigned', '-Command', 'Write-Output', '%PATH%'])")) eq("%PATH%\n", eval("system(['powershell', '-NoProfile', '-NoLogo', '-ExecutionPolicy', 'RemoteSigned', '-Command', 'Write-Output', '%PATH%'])"))
else else
eq("* $PATH %PATH%\n", eval("system(['echo', '*', '$PATH', '%PATH%'])")) eq("* $PATH %PATH%\n", eval("system(['echo', '*', '$PATH', '%PATH%'])"))
@ -94,7 +94,7 @@ describe('system()', function()
end) end)
it('sets v:shell_error', function() it('sets v:shell_error', function()
if iswin() then if is_os('win') then
eval([[system("cmd.exe /c exit")]]) eval([[system("cmd.exe /c exit")]])
eq(0, eval('v:shell_error')) eq(0, eval('v:shell_error'))
eval([[system("cmd.exe /c exit 1")]]) eval([[system("cmd.exe /c exit 1")]])
@ -123,7 +123,7 @@ describe('system()', function()
screen:attach() screen:attach()
end) end)
if iswin() then if is_os('win') then
local function test_more() local function test_more()
eq('root = true', eval([[get(split(system('"more" ".editorconfig"'), "\n"), 0, '')]])) eq('root = true', eval([[get(split(system('"more" ".editorconfig"'), "\n"), 0, '')]]))
end end
@ -184,7 +184,7 @@ describe('system()', function()
-- * on Windows, expected to default to Western European enc -- * on Windows, expected to default to Western European enc
-- * on Linux, expected to default to UTF8 -- * on Linux, expected to default to UTF8
command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']]) command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']])
eq(iswin() and '??\n' or 'ああ\n', eval([[system('Write-Output "ああ"')]])) eq(is_os('win') and '??\n' or 'ああ\n', eval([[system('Write-Output "ああ"')]]))
end) end)
it('`echo` and waits for its return', function() it('`echo` and waits for its return', function()
@ -213,7 +213,7 @@ describe('system()', function()
screen:try_resize(72, 14) screen:try_resize(72, 14)
feed(':4verbose echo system("echo hi")<cr>') feed(':4verbose echo system("echo hi")<cr>')
if iswin() then if is_os('win') then
screen:expect{any=[[Executing command: "'fake_shell' 'cmdflag' '"echo hi"'"]]} screen:expect{any=[[Executing command: "'fake_shell' 'cmdflag' '"echo hi"'"]]}
else else
screen:expect{any=[[Executing command: "'fake_shell' 'cmdflag' 'echo hi'"]]} screen:expect{any=[[Executing command: "'fake_shell' 'cmdflag' 'echo hi'"]]}
@ -243,7 +243,7 @@ describe('system()', function()
end) end)
it('`yes` interrupted with CTRL-C', function() it('`yes` interrupted with CTRL-C', function()
feed(':call system("' .. (iswin() feed(':call system("' .. (is_os('win')
and 'for /L %I in (1,0,2) do @echo y' and 'for /L %I in (1,0,2) do @echo y'
or 'yes') .. '")<cr>') or 'yes') .. '")<cr>')
screen:expect([[ screen:expect([[
@ -260,7 +260,7 @@ describe('system()', function()
~ | ~ |
~ | ~ |
~ | ~ |
]] .. (iswin() ]] .. (is_os('win')
and [[ and [[
:call system("for /L %I in (1,0,2) do @echo y") |]] :call system("for /L %I in (1,0,2) do @echo y") |]]
or [[ or [[
@ -286,7 +286,7 @@ describe('system()', function()
it('`yes` interrupted with mapped CTRL-C', function() it('`yes` interrupted with mapped CTRL-C', function()
command('nnoremap <C-C> i') command('nnoremap <C-C> i')
feed(':call system("' .. (iswin() feed(':call system("' .. (is_os('win')
and 'for /L %I in (1,0,2) do @echo y' and 'for /L %I in (1,0,2) do @echo y'
or 'yes') .. '")<cr>') or 'yes') .. '")<cr>')
screen:expect([[ screen:expect([[
@ -303,7 +303,7 @@ describe('system()', function()
~ | ~ |
~ | ~ |
~ | ~ |
]] .. (iswin() ]] .. (is_os('win')
and [[ and [[
:call system("for /L %I in (1,0,2) do @echo y") |]] :call system("for /L %I in (1,0,2) do @echo y") |]]
or [[ or [[
@ -330,7 +330,7 @@ describe('system()', function()
describe('passing no input', function() describe('passing no input', function()
it('returns the program output', function() it('returns the program output', function()
if iswin() then if is_os('win') then
eq("echoed\n", eval('system("echo echoed")')) eq("echoed\n", eval('system("echo echoed")'))
else else
eq("echoed", eval('system("echo -n echoed")')) eq("echoed", eval('system("echo -n echoed")'))
@ -438,7 +438,7 @@ describe('systemlist()', function()
before_each(clear) before_each(clear)
it('sets v:shell_error', function() it('sets v:shell_error', function()
if iswin() then if is_os('win') then
eval([[systemlist("cmd.exe /c exit")]]) eval([[systemlist("cmd.exe /c exit")]])
eq(0, eval('v:shell_error')) eq(0, eval('v:shell_error'))
eval([[systemlist("cmd.exe /c exit 1")]]) eval([[systemlist("cmd.exe /c exit 1")]])
@ -617,12 +617,12 @@ describe('systemlist()', function()
return return
end end
helpers.set_shell_powershell() helpers.set_shell_powershell()
eq({iswin() and '\r' or ''}, eval([[systemlist('Write-Output あ')]])) eq({is_os('win') and '\r' or ''}, eval([[systemlist('Write-Output あ')]]))
-- Sanity test w/ default encoding -- Sanity test w/ default encoding
-- * on Windows, expected to default to Western European enc -- * on Windows, expected to default to Western European enc
-- * on Linux, expected to default to UTF8 -- * on Linux, expected to default to UTF8
command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']]) command([[let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ']])
eq({iswin() and '?\r' or ''}, eval([[systemlist('Write-Output あ')]])) eq({is_os('win') and '?\r' or ''}, eval([[systemlist('Write-Output あ')]]))
end) end)
end) end)
@ -639,7 +639,7 @@ describe('shell :!', function()
1 1
4 4
2]]) 2]])
if iswin() then if is_os('win') then
feed(':4verbose %!sort /R<cr>') feed(':4verbose %!sort /R<cr>')
screen:expect{ screen:expect{
any=[[Executing command: .?& { Get%-Content .* | & sort /R } 2>&1 | Out%-File %-Encoding UTF8 .*; exit $LastExitCode"]] any=[[Executing command: .?& { Get%-Content .* | & sort /R } 2>&1 | Out%-File %-Encoding UTF8 .*; exit $LastExitCode"]]

View File

@ -269,14 +269,10 @@ function module.check_logs()
table.concat(runtime_errors, ', '))) table.concat(runtime_errors, ', ')))
end end
function module.iswin() -- Gets (lowercase) OS name from CMake, uname, or manually check if on Windows
return package.config:sub(1,1) == '\\' do
end
-- Gets (lowercase) OS name from CMake, uname, or "win" if iswin().
module.uname = (function()
local platform = nil local platform = nil
return (function() function module.uname()
if platform then if platform then
return platform return platform
end end
@ -290,22 +286,28 @@ module.uname = (function()
if status then if status then
platform = string.lower(f:read("*l")) platform = string.lower(f:read("*l"))
f:close() f:close()
elseif module.iswin() then elseif package.config:sub(1,1) == '\\' then
platform = 'windows' platform = 'windows'
else else
error('unknown platform') error('unknown platform')
end end
return platform return platform
end) end
end)() end
function module.is_os(s) function module.is_os(s)
if not (s == 'win' or s == 'mac' or s == 'unix') then if not (s == 'win'
or s == 'mac'
or s == 'freebsd'
or s == 'openbsd'
or s == 'bsd') then
error('unknown platform: '..tostring(s)) error('unknown platform: '..tostring(s))
end end
return ((s == 'win' and module.iswin()) return ((s == 'win' and module.uname() == 'windows')
or (s == 'mac' and module.uname() == 'darwin') or (s == 'mac' and module.uname() == 'darwin')
or (s == 'unix')) or (s == 'freebsd' and module.uname() == 'freebsd')
or (s == 'openbsd' and module.uname() == 'openbsd')
or (s == 'bsd' and string.find(module.uname(), 'bsd')))
end end
local function tmpdir_get() local function tmpdir_get()
@ -331,11 +333,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.is_os('win') 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.is_os('mac') 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
@ -378,14 +380,14 @@ function module.check_cores(app, force)
exc_re = { os.getenv('NVIM_TEST_CORE_EXC_RE'), local_tmpdir } exc_re = { os.getenv('NVIM_TEST_CORE_EXC_RE'), local_tmpdir }
db_cmd = os.getenv('NVIM_TEST_CORE_DB_CMD') or gdb_db_cmd db_cmd = os.getenv('NVIM_TEST_CORE_DB_CMD') or gdb_db_cmd
random_skip = os.getenv('NVIM_TEST_CORE_RANDOM_SKIP') random_skip = os.getenv('NVIM_TEST_CORE_RANDOM_SKIP')
elseif 'darwin' == module.uname() then elseif module.is_os('mac') then
initial_path = '/cores' initial_path = '/cores'
re = nil re = nil
exc_re = { local_tmpdir } exc_re = { local_tmpdir }
db_cmd = lldb_db_cmd db_cmd = lldb_db_cmd
else else
initial_path = '.' initial_path = '.'
if 'freebsd' == module.uname() then if module.is_os('freebsd') then
re = '/nvim.core$' re = '/nvim.core$'
else else
re = '/core[^/]*$' re = '/core[^/]*$'
@ -800,7 +802,7 @@ function module.write_file(name, text, no_dedent, append)
file:close() file:close()
end end
function module.isCI(name) function module.is_ci(name)
local any = (name == nil) local any = (name == nil)
assert(any or name == 'github' or name == 'cirrus') assert(any or name == 'github' or name == 'cirrus')
local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS')) local gh = ((any or name == 'github') and nil ~= os.getenv('GITHUB_ACTIONS'))
@ -812,7 +814,7 @@ end
-- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments. -- Also moves the file to "${NVIM_LOG_FILE}.displayed" on CI environments.
function module.read_nvim_log(logfile, ci_rename) function module.read_nvim_log(logfile, ci_rename)
logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog' logfile = logfile or os.getenv('NVIM_LOG_FILE') or '.nvimlog'
local is_ci = module.isCI() local is_ci = module.is_ci()
local keep = is_ci and 100 or 10 local keep = is_ci and 100 or 10
local lines = module.read_file_list(logfile, -keep) or {} local lines = module.read_file_list(logfile, -keep) or {}
local log = (('-'):rep(78)..'\n' local log = (('-'):rep(78)..'\n'