mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-03 17:24:29 +00:00 
			
		
		
		
	refactor: Remove VimL function test_autochdir()
				
					
				
			- Eliminate global test_autochdir.
- Eliminate VimL function test_autochdir()
- Use a lua test instead. Fails correctly after reverting
  0c43479979 / vim-patch:7.4.2015.
			
			
This commit is contained in:
		@@ -2207,7 +2207,6 @@ tagfiles()			List	tags files used
 | 
				
			|||||||
tan({expr})			Float	tangent of {expr}
 | 
					tan({expr})			Float	tangent of {expr}
 | 
				
			||||||
tanh({expr})			Float	hyperbolic tangent of {expr}
 | 
					tanh({expr})			Float	hyperbolic tangent of {expr}
 | 
				
			||||||
tempname()			String	name for a temporary file
 | 
					tempname()			String	name for a temporary file
 | 
				
			||||||
test_autochdir()		none	enable 'autochdir' during startup
 | 
					 | 
				
			||||||
timer_start({time}, {callback} [, {options}])
 | 
					timer_start({time}, {callback} [, {options}])
 | 
				
			||||||
				Number	create a timer
 | 
									Number	create a timer
 | 
				
			||||||
timer_stop({timer})		none	stop a timer
 | 
					timer_stop({timer})		none	stop a timer
 | 
				
			||||||
@@ -7214,10 +7213,6 @@ tempname()					*tempname()* *temp-file-name*
 | 
				
			|||||||
		For MS-Windows forward slashes are used when the 'shellslash'
 | 
							For MS-Windows forward slashes are used when the 'shellslash'
 | 
				
			||||||
		option is set or when 'shellcmdflag' starts with '-'.
 | 
							option is set or when 'shellcmdflag' starts with '-'.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test_autochdir()					*test_autochdir()*
 | 
					 | 
				
			||||||
		Set a flag to enable the effect of 'autochdir' before Vim
 | 
					 | 
				
			||||||
		startup has finished.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
termopen({cmd}[, {opts}])			{Nvim} *termopen()*
 | 
					termopen({cmd}[, {opts}])			{Nvim} *termopen()*
 | 
				
			||||||
		Spawns {cmd} in a new pseudo-terminal session connected
 | 
							Spawns {cmd} in a new pseudo-terminal session connected
 | 
				
			||||||
		to the current buffer.  {cmd} is the same as the one passed to
 | 
							to the current buffer.  {cmd} is the same as the one passed to
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -904,7 +904,6 @@ Testing:				    *test-functions*
 | 
				
			|||||||
	assert_true()		assert that an expression is true
 | 
						assert_true()		assert that an expression is true
 | 
				
			||||||
	assert_exception()	assert that a command throws an exception
 | 
						assert_exception()	assert that a command throws an exception
 | 
				
			||||||
	assert_fails()		assert that a function call fails
 | 
						assert_fails()		assert that a function call fails
 | 
				
			||||||
	test_autochdir()	enable 'autochdir' during startup
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Various:					*various-functions*
 | 
					Various:					*various-functions*
 | 
				
			||||||
	mode()			get current editing mode
 | 
						mode()			get current editing mode
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1330,7 +1330,7 @@ void enter_buffer(buf_T *buf)
 | 
				
			|||||||
void do_autochdir(void)
 | 
					void do_autochdir(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (p_acd) {
 | 
					  if (p_acd) {
 | 
				
			||||||
    if ((starting == 0 || test_autochdir)
 | 
					    if (starting == 0
 | 
				
			||||||
        && curbuf->b_ffname != NULL
 | 
					        && curbuf->b_ffname != NULL
 | 
				
			||||||
        && vim_chdirfile(curbuf->b_ffname) == OK) {
 | 
					        && vim_chdirfile(curbuf->b_ffname) == OK) {
 | 
				
			||||||
      shorten_fnames(true);
 | 
					      shorten_fnames(true);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17159,12 +17159,6 @@ static void f_tempname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
				
			|||||||
  rettv->vval.v_string = vim_tempname();
 | 
					  rettv->vval.v_string = vim_tempname();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// "test_autochdir()" function
 | 
					 | 
				
			||||||
static void f_test_autochdir(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  test_autochdir = true;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// "termopen(cmd[, cwd])" function
 | 
					// "termopen(cmd[, cwd])" function
 | 
				
			||||||
static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
					static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -301,7 +301,6 @@ return {
 | 
				
			|||||||
    tan={args=1, func="float_op_wrapper", data="&tan"},
 | 
					    tan={args=1, func="float_op_wrapper", data="&tan"},
 | 
				
			||||||
    tanh={args=1, func="float_op_wrapper", data="&tanh"},
 | 
					    tanh={args=1, func="float_op_wrapper", data="&tanh"},
 | 
				
			||||||
    tempname={},
 | 
					    tempname={},
 | 
				
			||||||
    test_autochdir={},
 | 
					 | 
				
			||||||
    termopen={args={1, 2}},
 | 
					    termopen={args={1, 2}},
 | 
				
			||||||
    test={args=1},
 | 
					    test={args=1},
 | 
				
			||||||
    timer_start={args={2,3}},
 | 
					    timer_start={args={2,3}},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -641,8 +641,6 @@ EXTERN volatile int full_screen INIT(= FALSE);
 | 
				
			|||||||
/* TRUE when doing full-screen output
 | 
					/* TRUE when doing full-screen output
 | 
				
			||||||
 * otherwise only writing some messages */
 | 
					 * otherwise only writing some messages */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EXTERN int test_autochdir INIT(= false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXTERN int restricted INIT(= FALSE);
 | 
					EXTERN int restricted INIT(= FALSE);
 | 
				
			||||||
// TRUE when started in restricted mode (-Z)
 | 
					// TRUE when started in restricted mode (-Z)
 | 
				
			||||||
EXTERN int secure INIT(= FALSE);
 | 
					EXTERN int secure INIT(= FALSE);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,6 @@ SCRIPTS := \
 | 
				
			|||||||
# Tests using runtest.vim.vim.
 | 
					# Tests using runtest.vim.vim.
 | 
				
			||||||
# Keep test_alot*.res as the last one, sort the others.
 | 
					# Keep test_alot*.res as the last one, sort the others.
 | 
				
			||||||
NEW_TESTS = \
 | 
					NEW_TESTS = \
 | 
				
			||||||
	    test_autochdir.res \
 | 
					 | 
				
			||||||
	    test_bufwintabinfo.res \
 | 
						    test_bufwintabinfo.res \
 | 
				
			||||||
	    test_cmdline.res \
 | 
						    test_cmdline.res \
 | 
				
			||||||
	    test_cscope.res \
 | 
						    test_cscope.res \
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +0,0 @@
 | 
				
			|||||||
" Test 'autochdir' behavior
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if !exists("+autochdir")
 | 
					 | 
				
			||||||
  finish
 | 
					 | 
				
			||||||
endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func Test_set_filename()
 | 
					 | 
				
			||||||
  call test_autochdir()
 | 
					 | 
				
			||||||
  set acd
 | 
					 | 
				
			||||||
  new
 | 
					 | 
				
			||||||
  w samples/Xtest
 | 
					 | 
				
			||||||
  call assert_equal("Xtest", expand('%'))
 | 
					 | 
				
			||||||
  call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
 | 
					 | 
				
			||||||
  bwipe!
 | 
					 | 
				
			||||||
  set noacd
 | 
					 | 
				
			||||||
  call delete('samples/Xtest')
 | 
					 | 
				
			||||||
endfunc
 | 
					 | 
				
			||||||
							
								
								
									
										26
									
								
								test/functional/legacy/autochdir_spec.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								test/functional/legacy/autochdir_spec.lua
									
									
									
									
									
										Normal file
									
								
							@@ -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)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user