diff options
author | Aleksa Sarai <cyphar@cyphar.com> | 2016-05-25 18:09:33 +1000 |
---|---|---|
committer | Aleksa Sarai <cyphar@cyphar.com> | 2016-06-07 17:26:49 +1000 |
commit | 1bb8930c92ae603f7dcef935fc1b7d760ed9e372 (patch) | |
tree | 837c1f34031cf30b86600e7b14bc69cc37d66c97 | |
parent | 2c44d9257287c3e804dcc5a2bfe073c20554c0b9 (diff) | |
download | rneovim-1bb8930c92ae603f7dcef935fc1b7d760ed9e372.tar.gz rneovim-1bb8930c92ae603f7dcef935fc1b7d760ed9e372.tar.bz2 rneovim-1bb8930c92ae603f7dcef935fc1b7d760ed9e372.zip |
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>
-rw-r--r-- | test/functional/job/job_spec.lua | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index d21b9051e2..ec0bc84ea8 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -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) |