As coded, the test needs to be extended to handle short (8.3) paths (Windows XP) and the possibility that option bsk may have multiple, comma-separated paths.
Also, the wrong environment variable is tested: TEMPDIR instead of TMPDIR. This time I've remembered to attach a proposed patch. It's a bit involved but does the job. -mike -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
>From 80799abce3d80eaff5671906a750aa50daec2541 Mon Sep 17 00:00:00 2001 From: msoyka-of-wharton <[email protected]> Date: Sun, 27 Jan 2019 21:37:22 -0500 Subject: [PATCH] Extend and correct Test_backupskip() The backupskip test has been extended to handle the following situations: 1. it does not accommodate short (8.3) paths and 2. the option value may contain several, comma-separated paths. Also, the environment variable TEMPDIR was tested instead of TMPDIR. --- src/testdir/test_options.vim | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 70f6b96de..c5d826cd8 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -349,17 +349,40 @@ func Test_set_indentexpr() endfunc 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") - call assert_match('/private/tmp/\*', &bsk) + let path_spec_in_bsk = (index(bsklist, '/private/tmp/*') >= 0) + call assert_true(path_spec_in_bsk, '/private/tmp not in option bsk') elseif has("unix") - call assert_match('/tmp/\*', &bsk) + let path_spec_in_bsk = (index(bsklist, '/tmp/*') >= 0) + call assert_true(path_spec_in_bsk, '/tmp not in option bsk') + endif + + " If our platform is Windows, the path separator will be a backslash and + " the path specification could be in short (8.3) format. Also, the '/*' + " at the end of each path must be removed before it is passed to expand(). + 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 - let bskvalue = substitute(&bsk, '\\', '/', 'g') - for var in ['$TEMPDIR', '$TMP', '$TEMP'] + " Option bsk will also include these environment variables if defined. + for var in ['$TMPDIR', '$TMP', '$TEMP'] if exists(var) let varvalue = substitute(expand(var), '\\', '/', 'g') - call assert_match(varvalue . '/\=\*', bskvalue) + let path_spec_in_bsk = (index(bsklist, varvalue.'/*') >= 0) + call assert_true(path_spec_in_bsk, var . ' not in option bsk') endif endfor endfunc -- 2.18.0.windows.1
