aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-13 16:01:56 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-08-13 16:06:29 -0400
commita1a5e35e9a80440c8674e9473988ccd66bb39e0c (patch)
treed0c0cfd6150b02ca8991b38b848673a5216c5162 /src
parent163680a58ebb7d3b7c650454a3307f62e6d87f15 (diff)
downloadrneovim-a1a5e35e9a80440c8674e9473988ccd66bb39e0c.tar.gz
rneovim-a1a5e35e9a80440c8674e9473988ccd66bb39e0c.tar.bz2
rneovim-a1a5e35e9a80440c8674e9473988ccd66bb39e0c.zip
vim-patch:8.1.0262: not enough testing for getftype()
Problem: Not enough testing for getftype(). Solution: Add a test. (Dominique Pelle, closes vim/vim#3300) https://github.com/vim/vim/commit/1598f9937a18c056d7b713dc254325c8f8456c8f
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/testdir/test_stat.vim35
2 files changed, 36 insertions, 1 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 77f5360614..86f57ee5a2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9874,7 +9874,7 @@ static void f_getftype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
# endif
# ifdef S_ISSOCK
else if (S_ISSOCK(mode))
- t = "fifo";
+ t = "socket";
# endif
else
t = "other";
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
index 8c44c2ed65..be98018904 100644
--- a/src/nvim/testdir/test_stat.vim
+++ b/src/nvim/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.