From e346c01c314bcb8e673cef72dd761b9612ea86db Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 13 Aug 2018 06:59:30 -0400 Subject: vim-patch:8.1.0161: buffer not updated with 'autoread' set if file was deleted Problem: Buffer not updated with 'autoread' set if file was deleted. (Michael Naumann) Solution: Don't set the timestamp to zero. (closes vim/vim#3165) https://github.com/vim/vim/commit/386bc82a3f82f70bad75aaad74dba57a176b5840 Sleep 2 seconds for autoread (https://github.com/neovim/neovim/pull/7592). --- src/nvim/testdir/test_stat.vim | 56 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) (limited to 'src/nvim/testdir/test_stat.vim') diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index 0a09130b0c..8c44c2ed65 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -46,6 +46,15 @@ func Test_existent_directory() call assert_equal('rwx', getfperm(dname)[0:2]) endfunc +func SleepForTimestamp() + " FAT has a granularity of 2 seconds, otherwise it's usually 1 second + if has('win32') + sleep 2 + else + sleep 2 + endif +endfunc + func Test_checktime() let fname = 'Xtest.tmp' @@ -53,12 +62,7 @@ func Test_checktime() call writefile(fl, fname) set autoread exec 'e' fname - " FAT has a granularity of 2 seconds, otherwise it's usually 1 second - if has('win32') - sleep 2 - else - sleep 2 - endif + call SleepForTimestamp() let fl = readfile(fname) let fl[0] .= ' - checktime' call writefile(fl, fname) @@ -68,6 +72,46 @@ func Test_checktime() call delete(fname) endfunc +func Test_autoread_file_deleted() + new Xautoread + set autoread + call setline(1, 'original') + w! + + call SleepForTimestamp() + if has('win32') + silent !echo changed > Xautoread + else + silent !echo 'changed' > Xautoread + endif + checktime + call assert_equal('changed', trim(getline(1))) + + call SleepForTimestamp() + messages clear + if has('win32') + silent !del Xautoread + else + silent !rm Xautoread + endif + checktime + call assert_match('E211:', execute('messages')) + call assert_equal('changed', trim(getline(1))) + + call SleepForTimestamp() + if has('win32') + silent !echo recreated > Xautoread + else + silent !echo 'recreated' > Xautoread + endif + checktime + call assert_equal('recreated', trim(getline(1))) + + call delete('Xautoread') + bwipe! +endfunc + + func Test_nonexistent_file() let fname = 'Xtest.tmp' -- cgit From a1a5e35e9a80440c8674e9473988ccd66bb39e0c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 13 Aug 2018 16:01:56 -0400 Subject: 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 --- src/nvim/testdir/test_stat.vim | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/nvim/testdir/test_stat.vim') 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. -- cgit From 538ace9aae0c3b9e7e1ef242e00c53df6ec2e7da Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 13 Aug 2018 20:56:41 -0400 Subject: oldtests: win: a directory is not executable Tests in 'test/functional/core/job_spec.lua' depend on this behavior. --- src/nvim/testdir/test_stat.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_stat.vim') diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index be98018904..c276df0a92 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -43,7 +43,7 @@ func Test_existent_directory() call assert_equal(0, getfsize(dname)) call assert_equal('dir', getftype(dname)) - call assert_equal('rwx', getfperm(dname)[0:2]) + call assert_equal(has('win32') ? 'rw-' : 'rwx', getfperm(dname)[0:2]) endfunc func SleepForTimestamp() -- cgit