Skip to content

Commit

Permalink
tests: use "cat" also on Windows
Browse files Browse the repository at this point in the history
Fixes neovim#10574.

Keeps 'can be called recursively' pending for now, see
neovim#10580 (comment).
  • Loading branch information
blueyed authored and timeyyy committed Aug 8, 2019
1 parent a396341 commit 67b99a4
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions test/functional/core/job_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('jobs', function()
end)

it('allows interactive commands', function()
nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")')
eq({'notification', 'stdout', {0, {'abc', ''}}}, next_msg())
Expand Down Expand Up @@ -187,7 +187,6 @@ describe('jobs', function()
end)

it('preserves NULs', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
-- Make a file with NULs in it.
local filename = helpers.tmpname()
write_file(filename, "abc\0def\n")
Expand All @@ -206,7 +205,6 @@ describe('jobs', function()
end)

it("will not buffer data if it doesn't end in newlines", function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
if os.getenv("TRAVIS") and os.getenv("CC") == "gcc-4.9"
and helpers.os_name() == "osx" then
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
Expand All @@ -223,15 +221,13 @@ describe('jobs', function()
end)

it('preserves newlines', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobsend(j, "a\\n\\nc\\n\\n\\n\\nb\\n\\n")')
eq({'notification', 'stdout',
{0, {'a', '', 'c', '', '', '', 'b', '', ''}}}, next_msg())
end)

it('preserves NULs', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobsend(j, ["\n123\n", "abc\\nxyz\n", ""])')
eq({'notification', 'stdout', {0, {'\n123\n', 'abc\nxyz\n', ''}}},
Expand All @@ -242,7 +238,6 @@ describe('jobs', function()
end)

it('avoids sending final newline', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobsend(j, ["some data", "without\nfinal nl"])')
eq({'notification', 'stdout', {0, {'some data', 'without\nfinal nl'}}},
Expand All @@ -253,14 +248,14 @@ describe('jobs', function()
end)

it('closes the job streams with jobclose', function()
nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")')
eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, iswin() and 1 or 0}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg())
end)

it("disallows jobsend on a job that closed stdin", function()
nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")')
eq(false, pcall(function()
nvim('command', 'call jobsend(j, ["some data"])')
Expand All @@ -273,7 +268,7 @@ describe('jobs', function()
end)

it('disallows jobstop twice on the same job', function()
nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j'))
eq(true, pcall(eval, "jobstop(j)"))
eq(false, pcall(eval, "jobstop(j)"))
Expand All @@ -284,7 +279,7 @@ describe('jobs', function()
end)

it('can get the pid value using getpid', function()
nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
local pid = eval('jobpid(j)')
neq(NIL, meths.get_proc(pid))
nvim('command', 'call jobstop(j)')
Expand Down Expand Up @@ -759,7 +754,7 @@ describe('jobs', function()
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(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)")
ok(string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") ~= nil)
end)

Expand Down

0 comments on commit 67b99a4

Please sign in to comment.