summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-09 22:08:57 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-09 22:08:57 +0200
commit1598f9937a18c056d7b713dc254325c8f8456c8f (patch)
tree09214c58d720d08ebf2396fa191ca05d88620d9c
parent38efd1d17a6e6aa2add71efdf2cde4a788e5f5e5 (diff)
patch 8.1.0262: not enough testing for getftype()v8.1.0262
Problem: Not enough testing for getftype(). Solution: Add a test. (Dominique Pelle, closes #3300)
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/testdir/test_stat.vim35
-rw-r--r--src/version.c2
3 files changed, 38 insertions, 1 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 31096d75db..9673a1ae3d 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -5111,7 +5111,7 @@ f_getftype(typval_T *argvars, typval_T *rettv)
# endif
# ifdef S_ISSOCK
else if (S_ISSOCK(st.st_mode))
- t = "fifo";
+ t = "socket";
# endif
else
t = "other";
diff --git a/src/testdir/test_stat.vim b/src/testdir/test_stat.vim
index 307cf5e640..c627266646 100644
--- a/src/testdir/test_stat.vim
+++ b/src/testdir/test_stat.vim
@@ -122,6 +122,41 @@ func Test_nonexistent_file()
call assert_equal('', getfperm(fname))
endfunc
+func Test_getftype()
+ call assert_equal('file', getftype(v:progpath))
+ call assert_equal('dir', getftype('.'))
+
+ if !has('unix')
+ return
+ endif
+
+ silent !ln -s Xfile Xlink
+ call assert_equal('link', getftype('Xlink'))
+ call delete('Xlink')
+
+ if executable('mkfifo')
+ silent !mkfifo Xfifo
+ call assert_equal('fifo', getftype('Xfifo'))
+ call delete('Xfifo')
+ endif
+
+ for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null')
+ call assert_equal('cdev', getftype(cdevfile))
+ endfor
+
+ for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null')
+ call assert_equal('bdev', getftype(bdevfile))
+ endfor
+
+ " The /run/ directory typically contains socket files.
+ " If it does not, test won't fail but will not test socket files.
+ for socketfile in systemlist('find /run -type s -maxdepth 2 2>/dev/null')
+ call assert_equal('socket', getftype(socketfile))
+ endfor
+
+ " TODO: file type 'other' is not tested. How can we test it?
+endfunc
+
func Test_win32_symlink_dir()
" On Windows, non-admin users cannot create symlinks.
" So we use an existing symlink for this test.
diff --git a/src/version.c b/src/version.c
index 9e2ee2e8f8..1cd58f0c82 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 262,
+/**/
261,
/**/
260,