aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_stat.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-02-13 21:33:28 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-02-13 21:33:28 +0800
commit03348e5b9db3f057057a70581ef71180c3cb6527 (patch)
treee7a169e48a0a2a06e4cdd0ee0470aeaebbb6ecca /src/nvim/testdir/test_stat.vim
parent6f5fae08a302bce6de453425a6b1c1d851112914 (diff)
downloadrneovim-03348e5b9db3f057057a70581ef71180c3cb6527.tar.gz
rneovim-03348e5b9db3f057057a70581ef71180c3cb6527.tar.bz2
rneovim-03348e5b9db3f057057a70581ef71180c3cb6527.zip
vim-patch:8.2.3510: changes are only detected with one second accuracy
Problem: Changes are only detected with one second accuracy. Solution: Use the nanosecond time if possible. (Leah Neukirchen, closes vim/vim#8873, closes vim/vim#8875) https://github.com/vim/vim/commit/0a7984af5601323fae7b3398f05a48087db7b767 In Nvim Test_checktime_fast() is also flaky. Add a delay to avoid that.
Diffstat (limited to 'src/nvim/testdir/test_stat.vim')
-rw-r--r--src/nvim/testdir/test_stat.vim36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
index 170358e023..a6fe31b85a 100644
--- a/src/nvim/testdir/test_stat.vim
+++ b/src/nvim/testdir/test_stat.vim
@@ -1,5 +1,7 @@
" Tests for stat functions and checktime
+source check.vim
+
func CheckFileTime(doSleep)
let fnames = ['Xtest1.tmp', 'Xtest2.tmp', 'Xtest3.tmp']
let times = []
@@ -74,6 +76,40 @@ func Test_checktime()
call delete(fname)
endfunc
+func Test_checktime_fast()
+ CheckFeature nanotime
+
+ let fname = 'Xtest.tmp'
+
+ let fl = ['Hello World!']
+ call writefile(fl, fname)
+ set autoread
+ exec 'e' fname
+ let fl = readfile(fname)
+ let fl[0] .= ' - checktime'
+ sleep 10m " make test less flaky in Nvim
+ call writefile(fl, fname)
+ checktime
+ call assert_equal(fl[0], getline(1))
+
+ call delete(fname)
+endfunc
+
+func Test_autoread_fast()
+ CheckFeature nanotime
+
+ new Xautoread
+ set autoread
+ call setline(1, 'foo')
+
+ w!
+ silent !echo bar > Xautoread
+ checktime
+
+ call assert_equal('bar', trim(getline(1)))
+ call delete('Xautoread')
+endfunc
+
func Test_autoread_file_deleted()
new Xautoread
set autoread