mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: add tests for cwd handling
Add both a test for cwd=/ and cwd=/tmp/nvim.XXXXX, to make sure that we don't have regressions in cwd handling. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
parent
2c44d92572
commit
1bb8930c92
@ -1,11 +1,11 @@
|
||||
|
||||
local helpers = require('test.functional.helpers')
|
||||
local clear, eq, eval, execute, feed, insert, neq, next_msg, nvim,
|
||||
nvim_dir, ok, source, write_file = helpers.clear,
|
||||
nvim_dir, ok, source, write_file, mkdir, rmdir = helpers.clear,
|
||||
helpers.eq, helpers.eval, helpers.execute, helpers.feed,
|
||||
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
|
||||
helpers.nvim_dir, helpers.ok, helpers.source,
|
||||
helpers.write_file
|
||||
helpers.write_file, helpers.mkdir, helpers.rmdir
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
|
||||
|
||||
@ -37,6 +37,31 @@ describe('jobs', function()
|
||||
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||
end)
|
||||
|
||||
it('changes to / when cwd provided', function()
|
||||
nvim('command', "let g:job_opts.cwd = '/'")
|
||||
nvim('command', "let j = jobstart('pwd', g:job_opts)")
|
||||
eq({'notification', 'stdout', {0, {'/', ''}}}, next_msg())
|
||||
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||
end)
|
||||
|
||||
it('changes to random directory when cwd provided', function()
|
||||
local dir = eval('resolve(tempname())')
|
||||
mkdir(dir)
|
||||
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
|
||||
nvim('command', "let j = jobstart('pwd', g:job_opts)")
|
||||
eq({'notification', 'stdout', {0, {dir, ''}}}, next_msg())
|
||||
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||
rmdir(dir)
|
||||
end)
|
||||
|
||||
it('fails to change to non-existent directory when provided', function()
|
||||
local _, err = pcall(function()
|
||||
nvim('command', "let g:job_opts.cwd = '/NONEXISTENT'")
|
||||
nvim('command', "let j = jobstart('pwd', g:job_opts)")
|
||||
end)
|
||||
ok(string.find(err, "E475: Invalid argument: expected valid directory$") ~= nil)
|
||||
end)
|
||||
|
||||
it('returns 0 when it fails to start', function()
|
||||
local status, rv = pcall(eval, "jobstart([])")
|
||||
eq(false, status)
|
||||
|
Loading…
Reference in New Issue
Block a user