Mercurial > vim
comparison src/testdir/test_stat.vim @ 12150:709b898e2119 v8.0.0955
patch 8.0.0955: Test_existent_file() fails on some file systems
commit https://github.com/vim/vim/commit/82de3c2c036bc89c2d9bdea236e0a7f1208a5571
Author: Bram Moolenaar <Bram@vim.org>
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2017 17:45:05 +0200 |
parents | 750779134e67 |
children | 977cab3d5474 |
comparison
equal
deleted
inserted
replaced
12149:f819c1e17fb9 | 12150:709b898e2119 |
---|---|
1 " Tests for stat functions and checktime | 1 " Tests for stat functions and checktime |
2 | 2 |
3 func Test_existent_file() | 3 func CheckFileTime(doSleep) |
4 let fname = 'Xtest.tmp' | 4 let fname = 'Xtest.tmp' |
5 let result = 0 | |
5 | 6 |
6 let ts = localtime() | 7 let ts = localtime() |
8 if a:doSleep | |
9 sleep 1 | |
10 endif | |
7 let fl = ['Hello World!'] | 11 let fl = ['Hello World!'] |
8 call writefile(fl, fname) | 12 call writefile(fl, fname) |
9 let tf = getftime(fname) | 13 let tf = getftime(fname) |
14 if a:doSleep | |
15 sleep 1 | |
16 endif | |
10 let te = localtime() | 17 let te = localtime() |
11 | 18 |
12 call assert_true(ts <= tf && tf <= te) | 19 let time_correct = (ts <= tf && tf <= te) |
13 call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) | 20 if a:doSleep || time_correct |
14 call assert_equal('file', getftype(fname)) | 21 call assert_true(time_correct) |
15 call assert_equal('rw-', getfperm(fname)[0:2]) | 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 | |
16 | 27 |
17 call delete(fname) | 28 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 | |
18 endfunc | 39 endfunc |
19 | 40 |
20 func Test_existent_directory() | 41 func Test_existent_directory() |
21 let dname = '.' | 42 let dname = '.' |
22 | 43 |