Mercurial > vim
changeset 14609:40b10f98eb13 v8.1.0318
patch 8.1.0318: the getftype() test may fail for char devices
commit https://github.com/vim/vim/commit/3b3a506f57a397d83db361be35189c591bff10fb
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 22 20:16:16 2018 +0200
patch 8.1.0318: the getftype() test may fail for char devices
Problem: The getftype() test may fail for char devices if the file
disappeared in between the listing and the getftype() call.
Solution: Ignore empty result. (Ozaki Kiichi, closes #3360)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 22 Aug 2018 20:30:08 +0200 |
parents | 36ec3ced2468 |
children | e6e9a1f2851f |
files | src/testdir/test_stat.vim src/version.c |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_stat.vim +++ b/src/testdir/test_stat.vim @@ -141,17 +141,29 @@ func Test_getftype() endif for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null') - call assert_equal('cdev', getftype(cdevfile)) + let type = getftype(cdevfile) + " ignore empty result, can happen if the file disappeared + if type != '' + call assert_equal('cdev', type) + endif endfor for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null') - call assert_equal('bdev', getftype(bdevfile)) + let type = getftype(bdevfile) + " ignore empty result, can happen if the file disappeared + if type != '' + call assert_equal('bdev', type) + endif 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)) + let type = getftype(socketfile) + " ignore empty result, can happen if the file disappeared + if type != '' + call assert_equal('socket', type) + endif endfor " TODO: file type 'other' is not tested. How can we test it?