Skip to content

Commit 82de3c2

Browse files
committed
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)
1 parent bc906e4 commit 82de3c2

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/testdir/test_stat.vim

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
" Tests for stat functions and checktime
22

3-
func Test_existent_file()
3+
func CheckFileTime(doSleep)
44
let fname = 'Xtest.tmp'
5+
let result = 0
56

67
let ts = localtime()
8+
if a:doSleep
9+
sleep 1
10+
endif
711
let fl = ['Hello World!']
812
call writefile(fl, fname)
913
let tf = getftime(fname)
14+
if a:doSleep
15+
sleep 1
16+
endif
1017
let te = localtime()
1118

12-
call assert_true(ts <= tf && tf <= te)
13-
call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
14-
call assert_equal('file', getftype(fname))
15-
call assert_equal('rw-', getfperm(fname)[0:2])
19+
let time_correct = (ts <= tf && tf <= te)
20+
if a:doSleep || time_correct
21+
call assert_true(time_correct)
22+
call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
23+
call assert_equal('file', getftype(fname))
24+
call assert_equal('rw-', getfperm(fname)[0:2])
25+
let result = 1
26+
endif
1627

1728
call delete(fname)
29+
return result
30+
endfunc
31+
32+
func Test_existent_file()
33+
" On some systems the file timestamp is rounded to a multiple of 2 seconds.
34+
" We need to sleep to handle that, but that makes the test slow. First try
35+
" without the sleep, and if it fails try again with the sleep.
36+
if CheckFileTime(0) == 0
37+
call CheckFileTime(1)
38+
endif
1839
endfunc
1940

2041
func Test_existent_directory()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
955,
772774
/**/
773775
954,
774776
/**/

0 commit comments

Comments
 (0)