comparison src/testdir/test_stat.vim @ 15050:c7628d6bc0dc v8.1.0536

patch 8.1.0536: file time test fails when using NFS commit https://github.com/vim/vim/commit/addc156c38d442367854f71baee31f2eb003c699 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 18 12:25:09 2018 +0100 patch 8.1.0536: file time test fails when using NFS Problem: File time test fails when using NFS. Solution: Use three file times instead of localtim(). (James McCoy, closes #3618)
author Bram Moolenaar <Bram@vim.org>
date Sun, 18 Nov 2018 12:30:06 +0100
parents 40b10f98eb13
children 4935244c1128
comparison
equal deleted inserted replaced
15049:8fd94c25a939 15050:c7628d6bc0dc
1 " Tests for stat functions and checktime 1 " Tests for stat functions and checktime
2 2
3 func CheckFileTime(doSleep) 3 func CheckFileTime(doSleep)
4 let fname = 'Xtest.tmp' 4 let fnames = ['Xtest1.tmp', 'Xtest2.tmp', 'Xtest3.tmp']
5 let times = []
5 let result = 0 6 let result = 0
6 7
7 let ts = localtime() 8 " Use three files istead of localtim(), with a network filesystem the file
8 if a:doSleep 9 " times may differ at bit
9 sleep 1
10 endif
11 let fl = ['Hello World!'] 10 let fl = ['Hello World!']
12 call writefile(fl, fname) 11 for fname in fnames
13 let tf = getftime(fname) 12 call writefile(fl, fname)
14 if a:doSleep 13 call add(times, getftime(fname))
15 sleep 1 14 if a:doSleep
16 endif 15 sleep 1
17 let te = localtime() 16 endif
17 endfor
18 18
19 let time_correct = (ts <= tf && tf <= te) 19 let time_correct = (times[0] <= times[1] && times[1] <= times[2])
20 if a:doSleep || time_correct 20 if a:doSleep || time_correct
21 call assert_true(time_correct) 21 call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
22 call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) 22 call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0]))
23 call assert_equal('file', getftype(fname)) 23 call assert_equal('file', getftype(fnames[0]))
24 call assert_equal('rw-', getfperm(fname)[0:2]) 24 call assert_equal('rw-', getfperm(fnames[0])[0:2])
25 let result = 1 25 let result = 1
26 endif 26 endif
27 27
28 call delete(fname) 28 for fname in fnames
29 call delete(fname)
30 endfor
29 return result 31 return result
30 endfunc 32 endfunc
31 33
32 func Test_existent_file() 34 func Test_existent_file()
33 " On some systems the file timestamp is rounded to a multiple of 2 seconds. 35 " On some systems the file timestamp is rounded to a multiple of 2 seconds.