diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2022-11-22 01:13:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 08:13:30 +0800 |
commit | 5eb5f4948826e9d47685ea9e257409cc3e693614 (patch) | |
tree | 9c5bbb393bbf992c06c78fd8f25375d9637d8bba /test/functional/ex_cmds | |
parent | 7c10774860b4238090f0d36a26203080542ef1ac (diff) | |
download | rneovim-5eb5f4948826e9d47685ea9e257409cc3e693614.tar.gz rneovim-5eb5f4948826e9d47685ea9e257409cc3e693614.tar.bz2 rneovim-5eb5f4948826e9d47685ea9e257409cc3e693614.zip |
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")`.
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r-- | test/functional/ex_cmds/cd_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ex_cmds/mksession_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ex_cmds/source_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ex_cmds/write_spec.lua | 22 | ||||
-rw-r--r-- | test/functional/ex_cmds/wviminfo_spec.lua | 4 |
5 files changed, 21 insertions, 21 deletions
diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index d2135d0613..5ed71651c7 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -9,8 +9,8 @@ local clear = helpers.clear local command = helpers.command local exc_exec = helpers.exc_exec local pathsep = helpers.get_pathsep() -local iswin = helpers.iswin local skip = helpers.skip +local is_os = helpers.is_os -- These directories will be created for testing local directories = { @@ -281,7 +281,7 @@ describe("getcwd()", function () end) it("returns empty string if working directory does not exist", function() - skip(iswin()) + skip(is_os('win')) command("cd "..directories.global) command("call delete('../"..directories.global.."', 'd')") eq("", helpers.eval("getcwd()")) diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua index b7ff6a7bf7..0a0c7ca410 100644 --- a/test/functional/ex_cmds/mksession_spec.lua +++ b/test/functional/ex_cmds/mksession_spec.lua @@ -5,7 +5,6 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local get_pathsep = helpers.get_pathsep -local iswin = helpers.iswin local eq = helpers.eq local neq = helpers.neq local funcs = helpers.funcs @@ -15,6 +14,7 @@ local rmdir = helpers.rmdir local sleep = helpers.sleep local meths = helpers.meths local skip = helpers.skip +local is_os = helpers.is_os local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec' @@ -178,7 +178,7 @@ describe(':mksession', function() command('cd ' .. cwd_dir) command('mksession ' .. session_path) command('%bwipeout!') - if iswin() then + if is_os('win') then sleep(100) -- Make sure all child processes have exited. end @@ -189,13 +189,13 @@ describe(':mksession', function() local expected_cwd = cwd_dir .. '/' .. tab_dir matches('^term://' .. pesc(expected_cwd) .. '//%d+:', funcs.expand('%')) command('%bwipeout!') - if iswin() then + if is_os('win') then sleep(100) -- Make sure all child processes have exited. end end) 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 cwd_dir = funcs.fnamemodify('.', ':p:~'):gsub([[[\/]*$]], '') diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua index 10ebefd8cd..64c3464be7 100644 --- a/test/functional/ex_cmds/source_spec.lua +++ b/test/functional/ex_cmds/source_spec.lua @@ -14,9 +14,9 @@ local eval = helpers.eval local exec_capture = helpers.exec_capture local neq = helpers.neq local matches = helpers.matches -local iswin = helpers.iswin local mkdir = helpers.mkdir local rmdir = helpers.rmdir +local is_os = helpers.is_os describe(':source', function() before_each(function() @@ -44,7 +44,7 @@ describe(':source', function() end) 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") return end diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua index e2a6b6460d..1ccd27875e 100644 --- a/test/functional/ex_cmds/write_spec.lua +++ b/test/functional/ex_cmds/write_spec.lua @@ -8,9 +8,9 @@ local command = helpers.command local feed_command = helpers.feed_command local funcs = helpers.funcs local meths = helpers.meths -local iswin = helpers.iswin -local isCI = helpers.isCI 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_bak = fname .. '~' @@ -39,7 +39,7 @@ describe(':write', function() it('&backupcopy=auto preserves symlinks', function() command('set backupcopy=auto') 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") else command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") @@ -57,10 +57,10 @@ describe(':write', function() end) it('&backupcopy=no replaces symlink with new file', function() - skip(isCI('cirrus')) + skip(is_ci('cirrus')) command('set backupcopy=no') 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") else command("silent !ln -s test_bkc_file.txt test_bkc_link.txt") @@ -79,7 +79,7 @@ describe(':write', function() it("appends FIFO file", function() -- 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') end @@ -112,7 +112,7 @@ describe(':write', function() eq(1, eval("filereadable('test/write/p_opt.txt')")) 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'), pcall_err(command, 'write ++p .')) eq(('Vim(write):E17: "'..funcs.fnamemodify('.', ':p:h')..'" is a directory'), @@ -121,11 +121,11 @@ describe(':write', function() end) it('errors out correctly', function() - skip(isCI('cirrus')) + skip(is_ci('cirrus')) command('let $HOME=""') eq(funcs.fnamemodify('.', ':p:h'), funcs.fnamemodify('.', ':p:h:~')) -- 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'), pcall_err(command, 'write .')) end @@ -144,7 +144,7 @@ describe(':write', function() funcs.setfperm(fname, 'r--------') eq('Vim(write):E505: "Xtest-functional-ex_cmds-write" is read-only (add ! to override)', pcall_err(command, 'write')) - if iswin() then + if is_os('win') then eq(0, os.execute('del /q/f ' .. fname)) eq(0, os.execute('rd /q/s ' .. fname_bak)) else @@ -152,7 +152,7 @@ describe(':write', function() eq(true, os.remove(fname_bak)) end 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) eq('Vim(write):E166: Can\'t open linked file for writing', pcall_err(command, 'write!')) diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua index 7c00daf1d7..861a977ea6 100644 --- a/test/functional/ex_cmds/wviminfo_spec.lua +++ b/test/functional/ex_cmds/wviminfo_spec.lua @@ -3,14 +3,14 @@ local lfs = require('lfs') local clear = helpers.clear local command, eq, neq, write_file = helpers.command, helpers.eq, helpers.neq, helpers.write_file -local iswin = helpers.iswin local read_file = helpers.read_file +local is_os = helpers.is_os describe(':wshada', function() local shada_file = 'wshada_test' 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. '--cmd', 'set swapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler'}, args_rm={'-n', '-i', '--cmd'}} |