]> granicus.if.org Git - vim/commitdiff
patch 9.0.0028: MS-Windows: tests fail if there is a "runtime" directory v9.0.0028
authorBram Moolenaar <Bram@vim.org>
Sat, 2 Jul 2022 16:36:31 +0000 (17:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 2 Jul 2022 16:36:31 +0000 (17:36 +0100)
Problem:    MS-Windows: tests fail if there is a stray "runtime" directory.
Solution:   Only use a "runtime" directory if it contains "defaults.vim".

src/filepath.c
src/misc1.c
src/version.c

index 854d823c9750d97aa5a2b228dde98a50342c155d..f1ae18e0bd680c439c906b08237742d0c8f4c997 100644 (file)
@@ -774,6 +774,26 @@ shorten_dir(char_u *str)
     shorten_dir_len(str, 1);
 }
 
+/*
+ * Return TRUE if "fname" is a readable file.
+ */
+    int
+file_is_readable(char_u *fname)
+{
+    int                fd;
+
+#ifndef O_NONBLOCK
+# define O_NONBLOCK 0
+#endif
+    if (*fname && !mch_isdir(fname)
+             && (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
+    {
+       close(fd);
+       return TRUE;
+    }
+    return FALSE;
+}
+
 #if defined(FEAT_EVAL) || defined(PROTO)
 
 /*
@@ -893,26 +913,6 @@ f_exepath(typval_T *argvars, typval_T *rettv)
     rettv->vval.v_string = p;
 }
 
-/*
- * Return TRUE if "fname" is a readable file.
- */
-    int
-file_is_readable(char_u *fname)
-{
-    int                fd;
-
-#ifndef O_NONBLOCK
-# define O_NONBLOCK 0
-#endif
-    if (*fname && !mch_isdir(fname)
-             && (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
-    {
-       close(fd);
-       return TRUE;
-    }
-    return FALSE;
-}
-
 /*
  * "filereadable()" function
  */
index 91e208b3524118ec9c9ae14db2ac24b6d7dda5cf..1ab31594135d059dd76a3bc782ea987e0d6914f1 100644 (file)
@@ -1655,7 +1655,21 @@ vim_version_dir(char_u *vimdir)
     vim_free(p);
     p = concat_fnames(vimdir, (char_u *)RUNTIME_DIRNAME, TRUE);
     if (p != NULL && mch_isdir(p))
-       return p;
+    {
+       char_u *fname = concat_fnames(p, (char_u *)"defaults.vim", TRUE);
+
+       // Check that "defaults.vim" exists in this directory, to avoid picking
+       // up a stray "runtime" directory, it would make many tests fail in
+       // mysterious ways.
+       if (fname != NULL)
+       {
+           int exists = file_is_readable(fname);
+
+           vim_free(fname);
+           if (exists)
+               return p;
+       }
+    }
     vim_free(p);
     return NULL;
 }
index 458591515ef8eb0798708c3a5266b8547c97c9d8..77be61cf89836463d300dfc6ba38acb3dcc6f9a7 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    28,
 /**/
     27,
 /**/