test: Fix problems in job_spec.lua

Nvim wasn't exiting cleanly in some job tests due to errors.

This can't be noticed until the next commit, which will perform a refactoring to
selectively process K_EVENT, so the `qa!` command executed at the end of each
test blocks forever if there are errors which require the user to press ENTER(in
that state Nvim no longer will process events).
This commit is contained in:
Thiago de Arruda
2014-11-21 15:21:03 -03:00
parent 179c51319d
commit 230c935e73

View File

@@ -37,7 +37,7 @@ describe('jobs', function()
end) end)
it('allows interactive commands', function() it('allows interactive commands', function()
nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]')) nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])") nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
neq(0, eval('j')) neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")') nvim('command', 'call jobsend(j, "abc\\n")')
@@ -46,9 +46,8 @@ describe('jobs', function()
eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message()) eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
nvim('command', 'call jobsend(j, [123, "xyz"])') nvim('command', 'call jobsend(j, [123, "xyz"])')
eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message()) eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
nvim('command', notify_str('v:job_data[1])'))
nvim('command', "call jobstop(j)") nvim('command', "call jobstop(j)")
eq({'notification', 'exit', {}}, next_message()) eq({'notification', 'exit', {0}}, next_message())
end) end)
it('preserves NULs', function() it('preserves NULs', function()
@@ -59,9 +58,10 @@ describe('jobs', function()
file:close() file:close()
-- v:job_data preserves NULs. -- v:job_data preserves NULs.
nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]')) nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['"..filename.."'])") nvim('command', "let j = jobstart('xxx', 'cat', ['"..filename.."'])")
eq({'notification', 'stdout', {{'abc\ndef'}}}, next_message()) eq({'notification', 'stdout', {{'abc\ndef'}}}, next_message())
eq({'notification', 'exit', {0}}, next_message())
os.remove(filename) os.remove(filename)
-- jobsend() preserves NULs. -- jobsend() preserves NULs.
@@ -72,12 +72,13 @@ describe('jobs', function()
end) end)
it('will hold data if it does not end in a newline', function() it('will hold data if it does not end in a newline', function()
nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]')) nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])") nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
nvim('command', 'call jobsend(j, "abc\\nxyz")') nvim('command', 'call jobsend(j, "abc\\nxyz")')
eq({'notification', 'stdout', {{'abc'}}}, next_message()) eq({'notification', 'stdout', {{'abc'}}}, next_message())
nvim('command', "call jobstop(j)") nvim('command', "call jobstop(j)")
eq({'notification', 'stdout', {{'xyz'}}}, next_message()) eq({'notification', 'stdout', {{'xyz'}}}, next_message())
eq({'notification', 'exit', {0}}, next_message())
end) end)
it('will not allow jobsend/stop on a non-existent job', function() it('will not allow jobsend/stop on a non-existent job', function()