aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/job_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/core/job_spec.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-rahm.tar.gz
rneovim-rahm.tar.bz2
rneovim-rahm.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'test/functional/core/job_spec.lua')
-rw-r--r--test/functional/core/job_spec.lua84
1 files changed, 73 insertions, 11 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 618c294566..e833b5127d 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -65,6 +65,39 @@ describe('jobs', function()
]])
end)
+ it('validation', function()
+ matches(
+ "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set",
+ pcall_err(command, "call jobstart(['cat', '-'], { 'pty': v:true, 'rpc': v:true })")
+ )
+ matches(
+ 'E475: Invalid argument: expected valid directory',
+ pcall_err(command, "call jobstart(['cat', '-'], { 'cwd': 9313843 })")
+ )
+ matches(
+ 'E475: Invalid argument: expected valid directory',
+ pcall_err(command, "call jobstart(['cat', '-'], { 'cwd': 'bogusssssss/bogus' })")
+ )
+ matches(
+ "E475: Invalid argument: 'term' must be Boolean",
+ pcall_err(command, "call jobstart(['cat', '-'], { 'term': 'bogus' })")
+ )
+ matches(
+ "E475: Invalid argument: 'term' must be Boolean",
+ pcall_err(command, "call jobstart(['cat', '-'], { 'term': 1 })")
+ )
+ command('set modified')
+ matches(
+ vim.pesc('jobstart(...,{term=true}) requires unmodified buffer'),
+ pcall_err(command, "call jobstart(['cat', '-'], { 'term': v:true })")
+ )
+
+ -- Non-failure cases:
+ command('set nomodified')
+ command("call jobstart(['cat', '-'], { 'term': v:true })")
+ command("call jobstart(['cat', '-'], { 'term': v:false })")
+ end)
+
it('must specify env option as a dict', function()
command('let g:job_opts.env = v:true')
local _, err = pcall(function()
@@ -940,6 +973,39 @@ describe('jobs', function()
feed('<CR>')
fn.jobstop(api.nvim_get_var('id'))
end)
+
+ it('does not set UI busy with zero timeout #31712', function()
+ local screen = Screen.new(50, 6)
+ command([[let g:id = jobstart(['sleep', '0.3'])]])
+ local busy = 0
+ screen._handle_busy_start = (function(orig)
+ return function()
+ orig(screen)
+ busy = busy + 1
+ end
+ end)(screen._handle_busy_start)
+ source([[
+ func PrintAndPoll()
+ echon "aaa\nbbb"
+ call jobwait([g:id], 0)
+ echon "\nccc"
+ endfunc
+ ]])
+ feed_command('call PrintAndPoll()')
+ screen:expect {
+ grid = [[
+ |
+ {3: }|
+ aaa |
+ bbb |
+ ccc |
+ {6:Press ENTER or type command to continue}^ |
+ ]],
+ }
+ feed('<CR>')
+ fn.jobstop(api.nvim_get_var('id'))
+ eq(0, busy)
+ end)
end)
pending('exit event follows stdout, stderr', function()
@@ -969,13 +1035,6 @@ describe('jobs', function()
eq({ 'notification', 'exit', { 0, 143 } }, next_msg())
end)
- it('cannot have both rpc and pty options', function()
- command('let g:job_opts.pty = v:true')
- command('let g:job_opts.rpc = v:true')
- local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)")
- matches("E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set", err)
- end)
-
it('does not crash when repeatedly failing to start shell', function()
source([[
set shell=nosuchshell
@@ -1198,7 +1257,7 @@ describe('jobs', function()
})
-- Wait for startup to complete, so that all terminal responses are received.
screen:expect([[
- {1: } |
+ ^ |
~ |*3
{1:[No Name] 0,0-1 All}|
|
@@ -1208,7 +1267,7 @@ describe('jobs', function()
feed(':q<CR>')
screen:expect([[
|
- [Process exited 0]{1: } |
+ [Process exited 0]^ |
|*4
{3:-- TERMINAL --} |
]])
@@ -1230,7 +1289,7 @@ describe('pty process teardown', function()
it('does not prevent/delay exit. #4798 #4900', function()
skip(fn.executable('sleep') == 0, 'missing "sleep" command')
-- Use a nested nvim (in :term) to test without --headless.
- fn.termopen({
+ fn.jobstart({
n.nvim_prog,
'-u',
'NONE',
@@ -1243,7 +1302,10 @@ describe('pty process teardown', function()
'+terminal',
'+!(sleep 300 &)',
'+qa',
- }, { env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } })
+ }, {
+ term = true,
+ env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
+ })
-- Exiting should terminate all descendants (PTY, its children, ...).
screen:expect([[