diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-08 08:00:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-08 08:00:27 +0800 |
commit | 3bb5d2f2192b63e368a4f573f66406eba3ee66b3 (patch) | |
tree | 05ce75681734aae42887dcf1b02c802dab08c731 | |
parent | 5e3c1b976ab4664bde2f546ac15510f4d888a39e (diff) | |
download | rneovim-3bb5d2f2192b63e368a4f573f66406eba3ee66b3.tar.gz rneovim-3bb5d2f2192b63e368a4f573f66406eba3ee66b3.tar.bz2 rneovim-3bb5d2f2192b63e368a4f573f66406eba3ee66b3.zip |
test: use termopen() instead of :terminal more (#26462)
-rw-r--r-- | test/functional/api/buffer_updates_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/autocmd/autocmd_oldtest_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/core/job_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/core/main_spec.lua | 4 | ||||
-rw-r--r-- | test/functional/ex_cmds/swapfile_preserve_recover_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/lua/ui_event_spec.lua | 2 |
7 files changed, 34 insertions, 15 deletions
diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index bf76db432f..6c250ad6ce 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local clear = helpers.clear local eq, ok = helpers.eq, helpers.ok +local funcs = helpers.funcs local buffer, command, eval, nvim, next_msg = helpers.buffer, helpers.command, helpers.eval, helpers.nvim, helpers.next_msg local nvim_prog = helpers.nvim_prog @@ -832,7 +833,10 @@ describe('API: buffer events:', function() it('when :terminal lines change', function() local buffer_lines = {} local expected_lines = {} - command('terminal "'..nvim_prog..'" -u NONE -i NONE -n -c "set shortmess+=A"') + funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '-n', '-c', 'set shortmess+=A' }, { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) + local b = nvim('get_current_buf') ok(buffer('attach', b, true, {})) diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index abae346701..7a3116cba5 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -2396,7 +2396,11 @@ describe('API', function() eq(info, meths.get_chan_info(3)) -- :terminal with args + running process. - command(':exe "terminal" shellescape(v:progpath) "-u NONE -i NONE"') + command('enew') + local progpath_esc = eval('shellescape(v:progpath)') + funcs.termopen(('%s -u NONE -i NONE'):format(progpath_esc), { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) eq(-1, eval('jobwait([&channel], 0)[0]')) -- Running? local expected2 = { stream = 'job', @@ -2406,11 +2410,11 @@ describe('API', function() eval('&shell'), '/s', '/c', - fmt('"%s -u NONE -i NONE"', eval('shellescape(v:progpath)')), + fmt('"%s -u NONE -i NONE"', progpath_esc), } or { eval('&shell'), eval('&shellcmdflag'), - fmt('%s -u NONE -i NONE', eval('shellescape(v:progpath)')), + fmt('%s -u NONE -i NONE', progpath_esc), } ), mode = 'terminal', diff --git a/test/functional/autocmd/autocmd_oldtest_spec.lua b/test/functional/autocmd/autocmd_oldtest_spec.lua index dfd746a06e..3ff4d9b873 100644 --- a/test/functional/autocmd/autocmd_oldtest_spec.lua +++ b/test/functional/autocmd/autocmd_oldtest_spec.lua @@ -75,7 +75,7 @@ describe('oldtests', function() funcs.writefile(funcs.split(content, "\n"), fname) funcs.delete('Xout') - funcs.system(string.format('%s -u NORC -i NONE -N -S %s', meths.get_vvar('progpath'), fname)) + funcs.system(string.format('%s --clean -N -S %s', meths.get_vvar('progpath'), fname)) eq(1, funcs.filereadable('Xout')) funcs.delete('Xxx1') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 038368c387..d2ea0b7441 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -676,7 +676,7 @@ describe('jobs', function() on_stderr = function(chan, data, name) stderr = data end, on_stdout = function(chan, data, name) stdout = data end, } - local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1',( '+echo "%s="..getenv("%s")'):format(envname, envname), '+qa!' }, opt) + local j1 = vim.fn.jobstart({ vim.v.progpath, '-es', '-V1',('+echo "%s="..getenv("%s")'):format(envname, envname), '+qa!' }, opt) vim.fn.jobwait({ j1 }, 10000) return join({ join(stdout), join(stderr) }) ]], @@ -1162,11 +1162,12 @@ describe("pty process teardown", function() it("does not prevent/delay exit. #4798 #4900", function() skip(is_os('win')) -- Use a nested nvim (in :term) to test without --headless. - feed_command(":terminal '"..helpers.nvim_prog - .."' -u NONE -i NONE --cmd '"..nvim_set.."' " + funcs.termopen({ + helpers.nvim_prog, '-u', 'NONE', '-i', "NONE", '--cmd', nvim_set, -- Use :term again in the _nested_ nvim to get a PTY process. -- Use `sleep` to simulate a long-running child of the PTY. - .."+terminal +'!(sleep 300 &)' +qa") + '+terminal', '+!(sleep 300 &)', '+qa', + }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }) -- Exiting should terminate all descendants (PTY, its children, ...). screen:expect([[ diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index c8d800f89a..37d659739c 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -68,7 +68,9 @@ describe('command-line option', function() -- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read -- data from the terminal #18181 - funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " "))) + funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")), { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) screen:expect([[ {1:^ }| {2:~ }| diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua index 436873b464..c0e592deb8 100644 --- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua +++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua @@ -115,7 +115,9 @@ describe("preserve and (R)ecover with custom 'directory'", function() local screen0 = Screen.new() screen0:attach() local child_server = new_pipename() - funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server}) + funcs.termopen({ nvim_prog, '-u', 'NONE', '-i', 'NONE', '--listen', child_server }, { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) screen0:expect({any = pesc('[No Name]')}) -- Wait for the child process to start. local child_session = helpers.connect(child_server) set_session(child_session) @@ -452,7 +454,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() it('(Q)uit at first file argument', function() local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', init_dir, '--cmd', init_set, - testfile}) + testfile}, { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) retry(nil, nil, function() eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:', eval("getline('$')->trim(' ', 2)")) @@ -467,7 +471,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() it('(A)bort at second file argument with -p', function() local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', init_dir, '--cmd', init_set, - '-p', otherfile, testfile}) + '-p', otherfile, testfile}, { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) retry(nil, nil, function() eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:', eval("getline('$')->trim(' ', 2)")) @@ -487,7 +493,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function() third %s /^ \zsthird$/]]):format(testfile, testfile, testfile)) local chan = funcs.termopen({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--cmd', init_dir, '--cmd', init_set, - '--cmd', 'set tags='..otherfile, '-tsecond'}) + '--cmd', 'set tags='..otherfile, '-tsecond'}, { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + }) retry(nil, nil, function() eq('[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:', eval("getline('$')->trim(' ', 2)")) diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 373d45da61..2d1ee54506 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -101,7 +101,7 @@ describe('vim.ui_attach', function() end) it('does not crash on exit', function() - helpers.funcs.system({ + funcs.system({ helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', |