Mercurial > vim
comparison src/testdir/test_options.vim @ 15685:e472308af17d v8.1.0850
patch 8.1.0850: test for 'backupskip' is not correct
commit https://github.com/vim/vim/commit/98ad1e17c3f71962862f959c6ba57dd01e8a83c2
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jan 30 21:51:27 2019 +0100
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 30 Jan 2019 22:00:06 +0100 |
parents | 63b02fcf1361 |
children | a8ed064ed316 |
comparison
equal
deleted
inserted
replaced
15684:fcf0076c0fa4 | 15685:e472308af17d |
---|---|
73 call assert_fails('set signcolumn=nope') | 73 call assert_fails('set signcolumn=nope') |
74 endif | 74 endif |
75 endfunc | 75 endfunc |
76 | 76 |
77 func Test_filetype_valid() | 77 func Test_filetype_valid() |
78 if !has('autocmd') | |
79 return | |
80 endif | |
81 set ft=valid_name | 78 set ft=valid_name |
82 call assert_equal("valid_name", &filetype) | 79 call assert_equal("valid_name", &filetype) |
83 set ft=valid-name | 80 set ft=valid-name |
84 call assert_equal("valid-name", &filetype) | 81 call assert_equal("valid-name", &filetype) |
85 | 82 |
347 call assert_equal('', &indentexpr) | 344 call assert_equal('', &indentexpr) |
348 bwipe! | 345 bwipe! |
349 endfunc | 346 endfunc |
350 | 347 |
351 func Test_backupskip() | 348 func Test_backupskip() |
349 " Option 'backupskip' may contain several comma-separated path | |
350 " specifications if one or more of the environment variables TMPDIR, TMP, | |
351 " or TEMP is defined. To simplify testing, convert the string value into a | |
352 " list. | |
353 let bsklist = split(&bsk, ',') | |
354 | |
352 if has("mac") | 355 if has("mac") |
353 call assert_match('/private/tmp/\*', &bsk) | 356 let found = (index(bsklist, '/private/tmp/*') >= 0) |
357 call assert_true(found, '/private/tmp not in option bsk: ' . &bsk) | |
354 elseif has("unix") | 358 elseif has("unix") |
355 call assert_match('/tmp/\*', &bsk) | 359 let found = (index(bsklist, '/tmp/*') >= 0) |
356 endif | 360 call assert_true(found, '/tmp not in option bsk: ' . &bsk) |
357 | 361 endif |
358 let bskvalue = substitute(&bsk, '\\', '/', 'g') | 362 |
359 for var in ['$TEMPDIR', '$TMP', '$TEMP'] | 363 " If our test platform is Windows, the path(s) in option bsk will use |
364 " backslash for the path separator and the components could be in short | |
365 " (8.3) format. As such, we need to replace the backslashes with forward | |
366 " slashes and convert the path components to long format. The expand() | |
367 " function will do this but it cannot handle comma-separated paths. This is | |
368 " why bsk was converted from a string into a list of strings above. | |
369 " | |
370 " One final complication is that the wildcard "/*" is at the end of each | |
371 " path and so expand() might return a list of matching files. To prevent | |
372 " this, we need to remove the wildcard before calling expand() and then | |
373 " append it afterwards. | |
374 if has('win32') | |
375 let item_nbr = 0 | |
376 while item_nbr < len(bsklist) | |
377 let path_spec = bsklist[item_nbr] | |
378 let path_spec = strcharpart(path_spec, 0, strlen(path_spec)-2) | |
379 let path_spec = substitute(expand(path_spec), '\\', '/', 'g') | |
380 let bsklist[item_nbr] = path_spec . '/*' | |
381 let item_nbr += 1 | |
382 endwhile | |
383 endif | |
384 | |
385 " Option bsk will also include these environment variables if defined. | |
386 " If they're defined, verify they appear in the option value. | |
387 for var in ['$TMPDIR', '$TMP', '$TEMP'] | |
360 if exists(var) | 388 if exists(var) |
361 let varvalue = substitute(expand(var), '\\', '/', 'g') | 389 let varvalue = substitute(expand(var), '\\', '/', 'g') |
362 call assert_match(varvalue . '/\=\*', bskvalue) | 390 let found = (index(bsklist, varvalue.'/*') >= 0) |
391 call assert_true(found, var . ' not in option bsk: ' . &bsk) | |
363 endif | 392 endif |
364 endfor | 393 endfor |
365 endfunc | 394 endfunc |
366 | 395 |
367 func Test_copy_winopt() | 396 func Test_copy_winopt() |