Merge pull request #10580 from blueyed/tests-cat

tests: use "cat" also on Windows
This commit is contained in:
Daniel Hahler 2019-07-27 00:59:27 +02:00 committed by GitHub
commit 809613c952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 13 deletions

View File

@ -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())
@ -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")
@ -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.
@ -223,7 +221,6 @@ 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',
@ -231,7 +228,6 @@ describe('jobs', function()
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', ''}}},
@ -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'}}},
@ -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"])')
@ -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)"))
@ -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)')
@ -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)

View File

@ -496,7 +496,7 @@ end
local function set_shell_powershell()
source([[
set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote=
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep;'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep; Remove-Item -Force alias:cat;'
]])
end