Skip to content

Commit 022f9ef

Browse files
committed
patch 9.0.0028: MS-Windows: tests fail if there is a "runtime" directory
Problem: MS-Windows: tests fail if there is a stray "runtime" directory. Solution: Only use a "runtime" directory if it contains "defaults.vim".
1 parent 2d29501 commit 022f9ef

3 files changed

Lines changed: 37 additions & 21 deletions

File tree

src/filepath.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,26 @@ shorten_dir(char_u *str)
774774
shorten_dir_len(str, 1);
775775
}
776776

777+
/*
778+
* Return TRUE if "fname" is a readable file.
779+
*/
780+
int
781+
file_is_readable(char_u *fname)
782+
{
783+
int fd;
784+
785+
#ifndef O_NONBLOCK
786+
# define O_NONBLOCK 0
787+
#endif
788+
if (*fname && !mch_isdir(fname)
789+
&& (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
790+
{
791+
close(fd);
792+
return TRUE;
793+
}
794+
return FALSE;
795+
}
796+
777797
#if defined(FEAT_EVAL) || defined(PROTO)
778798

779799
/*
@@ -893,26 +913,6 @@ f_exepath(typval_T *argvars, typval_T *rettv)
893913
rettv->vval.v_string = p;
894914
}
895915

896-
/*
897-
* Return TRUE if "fname" is a readable file.
898-
*/
899-
int
900-
file_is_readable(char_u *fname)
901-
{
902-
int fd;
903-
904-
#ifndef O_NONBLOCK
905-
# define O_NONBLOCK 0
906-
#endif
907-
if (*fname && !mch_isdir(fname)
908-
&& (fd = mch_open((char *)fname, O_RDONLY | O_NONBLOCK, 0)) >= 0)
909-
{
910-
close(fd);
911-
return TRUE;
912-
}
913-
return FALSE;
914-
}
915-
916916
/*
917917
* "filereadable()" function
918918
*/

src/misc1.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,21 @@ vim_version_dir(char_u *vimdir)
16551655
vim_free(p);
16561656
p = concat_fnames(vimdir, (char_u *)RUNTIME_DIRNAME, TRUE);
16571657
if (p != NULL && mch_isdir(p))
1658-
return p;
1658+
{
1659+
char_u *fname = concat_fnames(p, (char_u *)"defaults.vim", TRUE);
1660+
1661+
// Check that "defaults.vim" exists in this directory, to avoid picking
1662+
// up a stray "runtime" directory, it would make many tests fail in
1663+
// mysterious ways.
1664+
if (fname != NULL)
1665+
{
1666+
int exists = file_is_readable(fname);
1667+
1668+
vim_free(fname);
1669+
if (exists)
1670+
return p;
1671+
}
1672+
}
16591673
vim_free(p);
16601674
return NULL;
16611675
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
28,
738740
/**/
739741
27,
740742
/**/

0 commit comments

Comments
 (0)