From c8d5e9230ee3ddc530ddb251fbe11e3b02293c80 Mon Sep 17 00:00:00 2001 From: Aaron Williamson Date: Thu, 24 Nov 2016 17:23:54 -0700 Subject: jobstart(): Return -1 if cmd is not executable. #5671 Closes #5465 --- test/functional/core/job_spec.lua | 6 ++++++ test/functional/fixtures/non_executable.txt | 1 + 2 files changed, 7 insertions(+) create mode 100644 test/functional/fixtures/non_executable.txt (limited to 'test') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 9d24ba62db..61bd4f8b44 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -70,6 +70,12 @@ describe('jobs', function() ok(rv ~= nil) end) + it('returns -1 when target is not executable', function() + local rv = eval("jobstart(['./test/functional/fixtures/non_executable.txt'])") + eq(-1, rv) + eq("", eval("v:errmsg")) + end) + it('invokes callbacks when the job writes and exits', function() nvim('command', "call jobstart(['echo'], g:job_opts)") eq({'notification', 'stdout', {0, {'', ''}}}, next_msg()) diff --git a/test/functional/fixtures/non_executable.txt b/test/functional/fixtures/non_executable.txt new file mode 100644 index 0000000000..cc27ecc664 --- /dev/null +++ b/test/functional/fixtures/non_executable.txt @@ -0,0 +1 @@ +This file is not an executable -- cgit From d32888073f07326550b32ed6b497260aef19ec1e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 10 Dec 2016 15:50:08 +0100 Subject: test: jobstart() --- test/functional/core/job_spec.lua | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index 61bd4f8b44..79cc877cac 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -65,15 +65,22 @@ describe('jobs', function() end) it('returns 0 when it fails to start', function() - local status, rv = pcall(eval, "jobstart([])") - eq(false, status) - ok(rv ~= nil) - end) - - it('returns -1 when target is not executable', function() - local rv = eval("jobstart(['./test/functional/fixtures/non_executable.txt'])") - eq(-1, rv) eq("", eval("v:errmsg")) + execute("let g:test_jobid = jobstart([])") + eq(0, eval("g:test_jobid")) + eq("E474:", string.match(eval("v:errmsg"), "E%d*:")) + end) + + it('returns -1 when target is not executable #5465', function() + local function new_job() return eval([[jobstart(['echo', 'foo'])]]) end + local executable_jobid = new_job() + local nonexecutable_jobid = eval( + "jobstart(['./test/functional/fixtures/non_executable.txt'])") + eq(-1, nonexecutable_jobid) + -- Should _not_ throw an error. + eq("", eval("v:errmsg")) + -- Non-executable job should not increment the job ids. #5465 + eq(executable_jobid + 1, new_job()) end) it('invokes callbacks when the job writes and exits', function() -- cgit