]> granicus.if.org Git - vim/commitdiff
patch 8.1.0536: file time test fails when using NFS v8.1.0536
authorBram Moolenaar <Bram@vim.org>
Sun, 18 Nov 2018 11:25:09 +0000 (12:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 18 Nov 2018 11:25:09 +0000 (12:25 +0100)
Problem:    File time test fails when using NFS.
Solution:   Use three file times instead of localtim(). (James McCoy,
            closes #3618)

src/testdir/test_stat.vim
src/version.c

index 33509f02194b02b84b47e117fb55dc193a00927d..e48e8876680f4965c023a0c6281f615f2ec0dfa5 100644 (file)
@@ -1,31 +1,33 @@
 " Tests for stat functions and checktime
 
 func CheckFileTime(doSleep)
-  let fname = 'Xtest.tmp'
+  let fnames = ['Xtest1.tmp', 'Xtest2.tmp', 'Xtest3.tmp']
+  let times = []
   let result = 0
 
-  let ts = localtime()
-  if a:doSleep
-    sleep 1
-  endif
+  " Use three files istead of localtim(), with a network filesystem the file
+  " times may differ at bit
   let fl = ['Hello World!']
-  call writefile(fl, fname)
-  let tf = getftime(fname)
-  if a:doSleep
-    sleep 1
-  endif
-  let te = localtime()
+  for fname in fnames
+    call writefile(fl, fname)
+    call add(times, getftime(fname))
+    if a:doSleep
+      sleep 1
+    endif
+  endfor
 
-  let time_correct = (ts <= tf && tf <= te)
+  let time_correct = (times[0] <= times[1] && times[1] <= times[2])
   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])
+    call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
+    call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0]))
+    call assert_equal('file', getftype(fnames[0]))
+    call assert_equal('rw-', getfperm(fnames[0])[0:2])
     let result = 1
   endif
 
-  call delete(fname)
+  for fname in fnames
+    call delete(fname)
+  endfor
   return result
 endfunc
 
index eaaf98ae06787c0964937065c21e9fb539fdefa2..c0a5845d57ee25fab565feec14a16d9a2517c5a7 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    536,
 /**/
     535,
 /**/