# HG changeset patch # User Christian Brabandt # Date 1502984705 -7200 # Node ID 709b898e2119c978b0229653d59394702bfcc719 # Parent f819c1e17fb92d1ee44ca0f6ee45b42d89057126 patch 8.0.0955: Test_existent_file() fails on some file systems commit https://github.com/vim/vim/commit/82de3c2c036bc89c2d9bdea236e0a7f1208a5571 Author: Bram Moolenaar Date: Thu Aug 17 17:35:36 2017 +0200 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 #1984) diff --git a/src/testdir/test_stat.vim b/src/testdir/test_stat.vim --- a/src/testdir/test_stat.vim +++ b/src/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() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 955, +/**/ 954, /**/ 953,