diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-01-03 19:15:40 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-01-03 19:16:17 +0100 |
commit | 0a881575dab1af7bf70b3c85385f71997efe8258 (patch) | |
tree | 53d1d82251f3660518e056762af1aeaa22a8c3cb | |
parent | 5898a1dcbbb08f33c34bc1b7bf4604b8b7e61640 (diff) | |
download | rneovim-0a881575dab1af7bf70b3c85385f71997efe8258.tar.gz rneovim-0a881575dab1af7bf70b3c85385f71997efe8258.tar.bz2 rneovim-0a881575dab1af7bf70b3c85385f71997efe8258.zip |
vim-patch:8.0.0955: Test_existent_file() fails on some file systems
Problem: Test_existent_file() fails on some file systems.
Solution: Run the test again with a sleep when the test fails without a
sleep. (James McCoy, closes vim/vim#1984)
https://github.com/vim/vim/commit/82de3c2c036bc89c2d9bdea236e0a7f1208a5571
-rw-r--r-- | src/nvim/testdir/test_stat.vim | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index dee0d13e84..1239fe9427 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -1,20 +1,41 @@ " Tests for stat functions and checktime -func Test_existent_file() +func CheckFileTime(doSleep) let fname = 'Xtest.tmp' + let result = 0 let ts = localtime() + if a:doSleep + sleep 1 + endif let fl = ['Hello World!'] call writefile(fl, fname) let tf = getftime(fname) + if a:doSleep + sleep 1 + endif let te = localtime() - call assert_true(ts <= tf && tf <= te) - call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) - call assert_equal('file', getftype(fname)) - call assert_equal('rw-', getfperm(fname)[0:2]) + let time_correct = (ts <= tf && tf <= te) + if a:doSleep || time_correct + call assert_true(time_correct) + call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) + call assert_equal('file', getftype(fname)) + call assert_equal('rw-', getfperm(fname)[0:2]) + let result = 1 + endif call delete(fname) + return result +endfunc + +func Test_existent_file() + " On some systems the file timestamp is rounded to a multiple of 2 seconds. + " We need to sleep to handle that, but that makes the test slow. First try + " without the sleep, and if it fails try again with the sleep. + if CheckFileTime(0) == 0 + call CheckFileTime(1) + endif endfunc func Test_existent_directory() |