diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-01-04 08:24:36 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-04 08:24:36 +0100 |
commit | 6f9be2464c9385d0f3c8a7bd6a10e765826ceddf (patch) | |
tree | 2cb67c82325e1a5a125b35eff0499682946815ac /test | |
parent | af828f22575c8591a176bd9d85ee07f87ba8b911 (diff) | |
parent | a63675c38426944001139b5eaf36d1eb7963df2f (diff) | |
download | rneovim-6f9be2464c9385d0f3c8a7bd6a10e765826ceddf.tar.gz rneovim-6f9be2464c9385d0f3c8a7bd6a10e765826ceddf.tar.bz2 rneovim-6f9be2464c9385d0f3c8a7bd6a10e765826ceddf.zip |
Merge #5872 justinmk/test_autochdir
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/helpers.lua | 7 | ||||
-rw-r--r-- | test/functional/legacy/autochdir_spec.lua | 26 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index d67f225ed1..ed153182ca 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -14,6 +14,7 @@ local neq = global_helpers.neq local eq = global_helpers.eq local ok = global_helpers.ok +local start_dir = lfs.currentdir() local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim' local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--cmd', 'set shortmess+=I background=light noswapfile noautoindent laststatus=1 undodir=. directory=. viewdir=. backupdir=.', @@ -440,6 +441,12 @@ end local function rmdir(path) local ret, _ = pcall(do_rmdir, path) + if not ret and os_name() == "windows" then + -- Maybe "Permission denied"; try again after changing the nvim + -- process to the top-level directory. + nvim_command([[exe 'cd '.fnameescape(']]..start_dir.."')") + ret, _ = pcall(do_rmdir, path) + end -- During teardown, the nvim process may not exit quickly enough, then rmdir() -- will fail (on Windows). if not ret then -- Try again. diff --git a/test/functional/legacy/autochdir_spec.lua b/test/functional/legacy/autochdir_spec.lua new file mode 100644 index 0000000000..06f7c1dd11 --- /dev/null +++ b/test/functional/legacy/autochdir_spec.lua @@ -0,0 +1,26 @@ +local lfs = require('lfs') +local helpers = require('test.functional.helpers')(after_each) +local clear, eq = helpers.clear, helpers.eq +local eval, execute = helpers.eval, helpers.execute + +describe('autochdir behavior', function() + local dir = 'Xtest-functional-legacy-autochdir' + + before_each(function() + lfs.mkdir(dir) + clear() + end) + + after_each(function() + helpers.rmdir(dir) + end) + + -- Tests vim/vim/777 without test_autochdir(). + it('sets filename', function() + execute('set acd') + execute('new') + execute('w '..dir..'/Xtest') + eq('Xtest', eval("expand('%')")) + eq(dir, eval([[substitute(getcwd(), '.*[/\\]\(\k*\)', '\1', '')]])) + end) +end) |