@@ -75,9 +75,6 @@ func Test_signcolumn()
7575endfunc
7676
7777func Test_filetype_valid ()
78- if ! has (' autocmd' )
79- return
80- endif
8178 set ft = valid_name
8279 call assert_equal (" valid_name" , &filetype )
8380 set ft = valid - name
@@ -349,17 +346,49 @@ func Test_set_indentexpr()
349346endfunc
350347
351348func 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+
352355 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 )
354358 elseif has (" unix" )
355- call assert_match (' /tmp/\*' , &bsk )
359+ let found = (index (bsklist, ' /tmp/*' ) >= 0 )
360+ call assert_true (found, ' /tmp not in option bsk: ' . &bsk )
361+ endif
362+
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
356383 endif
357384
358- let bskvalue = substitute (&bsk , ' \\' , ' /' , ' g' )
359- for var in [' $TEMPDIR' , ' $TMP' , ' $TEMP' ]
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' ]
360388 if exists (var )
361389 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 )
363392 endif
364393 endfor
365394endfunc
0 commit comments