diff src/testdir/test_functions.vim @ 22977:515d1651c6c6 v8.2.2035

patch 8.2.2035: MS-Windows: some tests may fail Commit: https://github.com/vim/vim/commit/f637bceb6135139dc1891a15de8fa134c2ca2d97 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 23 18:14:56 2020 +0100 patch 8.2.2035: MS-Windows: some tests may fail Problem: MS-Windows: some tests may fail. Solution: Avoid test failures. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7346)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Nov 2020 18:30:04 +0100
parents fdc72bf4de35
children 4ba6c5eebb28
line wrap: on
line diff
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1273,7 +1273,16 @@ endfunc
 func Test_executable_longname()
   CheckMSWindows
 
-  let fname = 'X' . repeat('あ', 200) . '.bat'
+  " Create a temporary .bat file with 205 characters in the name.
+  " Maximum length of a filename (including the path) on MS-Windows is 259
+  " characters.
+  " See https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
+  let len = 259 - getcwd()->len() - 6
+  if len > 200
+    let len = 200
+  endif
+
+  let fname = 'X' . repeat('あ', len) . '.bat'
   call writefile([], fname)
   call assert_equal(1, executable(fname))
   call delete(fname)