mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
vim-patch:8.1.0850: test for 'backupskip' is not correct
Problem: Test for 'backupskip' is not correct.
Solution: Split the option in parts and use expand(). (Michael Soyka)
98ad1e17c3
This commit is contained in:
@@ -92,9 +92,6 @@ function! Test_path_keep_commas()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
func Test_filetype_valid()
|
func Test_filetype_valid()
|
||||||
if !has('autocmd')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
set ft=valid_name
|
set ft=valid_name
|
||||||
call assert_equal("valid_name", &filetype)
|
call assert_equal("valid_name", &filetype)
|
||||||
set ft=valid-name
|
set ft=valid-name
|
||||||
@@ -347,17 +344,49 @@ func Test_set_indentexpr()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_backupskip()
|
func Test_backupskip()
|
||||||
|
" Option 'backupskip' may contain several comma-separated path
|
||||||
|
" specifications if one or more of the environment variables TMPDIR, TMP,
|
||||||
|
" or TEMP is defined. To simplify testing, convert the string value into a
|
||||||
|
" list.
|
||||||
|
let bsklist = split(&bsk, ',')
|
||||||
|
|
||||||
if has("mac")
|
if has("mac")
|
||||||
call assert_match('/private/tmp/\*', &bsk)
|
let found = (index(bsklist, '/private/tmp/*') >= 0)
|
||||||
|
call assert_true(found, '/private/tmp not in option bsk: ' . &bsk)
|
||||||
elseif has("unix")
|
elseif has("unix")
|
||||||
call assert_match('/tmp/\*', &bsk)
|
let found = (index(bsklist, '/tmp/*') >= 0)
|
||||||
|
call assert_true(found, '/tmp not in option bsk: ' . &bsk)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let bskvalue = substitute(&bsk, '\\', '/', 'g')
|
" If our test platform is Windows, the path(s) in option bsk will use
|
||||||
for var in ['$TEMPDIR', '$TMP', '$TEMP']
|
" backslash for the path separator and the components could be in short
|
||||||
|
" (8.3) format. As such, we need to replace the backslashes with forward
|
||||||
|
" slashes and convert the path components to long format. The expand()
|
||||||
|
" function will do this but it cannot handle comma-separated paths. This is
|
||||||
|
" why bsk was converted from a string into a list of strings above.
|
||||||
|
"
|
||||||
|
" One final complication is that the wildcard "/*" is at the end of each
|
||||||
|
" path and so expand() might return a list of matching files. To prevent
|
||||||
|
" this, we need to remove the wildcard before calling expand() and then
|
||||||
|
" append it afterwards.
|
||||||
|
if has('win32')
|
||||||
|
let item_nbr = 0
|
||||||
|
while item_nbr < len(bsklist)
|
||||||
|
let path_spec = bsklist[item_nbr]
|
||||||
|
let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2)
|
||||||
|
let path_spec = substitute(expand(path_spec), '\\', '/', 'g')
|
||||||
|
let bsklist[item_nbr] = path_spec . '/*'
|
||||||
|
let item_nbr += 1
|
||||||
|
endwhile
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Option bsk will also include these environment variables if defined.
|
||||||
|
" If they're defined, verify they appear in the option value.
|
||||||
|
for var in ['$TMPDIR', '$TMP', '$TEMP']
|
||||||
if exists(var)
|
if exists(var)
|
||||||
let varvalue = substitute(expand(var), '\\', '/', 'g')
|
let varvalue = substitute(expand(var), '\\', '/', 'g')
|
||||||
call assert_match(varvalue . '/\=\*', bskvalue)
|
let found = (index(bsklist, varvalue.'/*') >= 0)
|
||||||
|
call assert_true(found, var . ' not in option bsk: ' . &bsk)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user