From 508ee7f245fc164f6a3792e69bd744a2f819a362 Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Fri, 6 May 2016 19:53:57 -0400 Subject: [PATCH 1/3] test/functional: prefix the cd command with silent to prevent hanging In longer directory paths, the test can hang waiting for the user to hit enter to continue. Let's use the silent prefix to avoid this. --- test/functional/ex_cmds/cd_spec.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index b503eba46e..2c62218d1b 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -53,7 +53,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Change tab-local working directory and verify it is different - execute('t' .. cmd .. ' ' .. directories[1]) + execute('silent t' .. cmd .. ' ' .. directories[1]) eq(globalDir .. '/' .. directories[1], cwd()) eq(cwd(), tcwd()) -- working directory maches tab directory eq(1, tlwd()) @@ -65,7 +65,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(1, tlwd()) -- Still tab-local working directory eq(0, wlwd()) -- Still no window-local working directory eq(globalDir .. '/' .. directories[1], cwd()) - execute('l' .. cmd .. ' ../' .. directories[2]) + execute('silent l' .. cmd .. ' ../' .. directories[2]) eq(globalDir .. '/' .. directories[2], cwd()) eq(globalDir .. '/' .. directories[1], tcwd()) eq(1, wlwd()) @@ -83,7 +83,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Verify global changes don't affect local ones - execute('' .. cmd .. ' ' .. directories[3]) + execute('silent ' .. cmd .. ' ' .. directories[3]) eq(globalDir .. '/' .. directories[3], cwd()) execute('tabnext') eq(globalDir .. '/' .. directories[1], cwd()) @@ -91,7 +91,7 @@ for _, cmd in ipairs {'cd', 'chdir'} do eq(0, wlwd()) -- Still no window-local directory in this window -- Unless the global change happened in a tab with local directory - execute('' .. cmd .. ' ..') + execute('silent ' .. cmd .. ' ..') eq(globalDir, cwd() ) eq(0 , tlwd()) eq(0 , wlwd()) From e91afdcda69b408b6f2572e82de3eb0ad4eee0b5 Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Fri, 6 May 2016 19:55:14 -0400 Subject: [PATCH 2/3] test/functional: fix a dependency on the previous test suite While trying to debug an issue, I discovered that the tests for illegal arguments depended on the prior suite having run and started a session. Let's remove that unintentional dependency by starting our own session before each test. --- test/functional/ex_cmds/cd_spec.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua index 2c62218d1b..69467632a4 100644 --- a/test/functional/ex_cmds/cd_spec.lua +++ b/test/functional/ex_cmds/cd_spec.lua @@ -111,6 +111,10 @@ end -- Test legal parameters for 'getcwd' and 'haslocaldir' for _, cmd in ipairs {'getcwd', 'haslocaldir'} do describe(cmd..'()', function() + before_each(function() + clear() + end) + -- Test invalid argument types local err474 = 'Vim(call):E474: Invalid argument' it('fails on string', function() From 69d1bc1a474591e28c700193099e5c46968b1c78 Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Fri, 6 May 2016 20:53:53 -0400 Subject: [PATCH 3/3] test/functional: clear the temp directory before each tempfile test It's possible that the first test encounters a temp directory with files in it, due to a previous test causing the first test to fail. Instead, let's clean up before and after the test to make sure the temp area is pristine before and after the test. --- test/unit/tempfile_spec.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/unit/tempfile_spec.lua b/test/unit/tempfile_spec.lua index b3e84db132..7975d11aed 100644 --- a/test/unit/tempfile_spec.lua +++ b/test/unit/tempfile_spec.lua @@ -5,6 +5,9 @@ local os = helpers.cimport './src/nvim/os/os.h' local tempfile = helpers.cimport './src/nvim/fileio.h' describe('tempfile related functions', function() + before_each(function() + tempfile.vim_deltempdir() + end) after_each(function() tempfile.vim_deltempdir() end)