add small delay to avoid problems on systems with low-resolution mtime
I've seen intermittent failures of the test suite with v6 for a long time, it seems to have possibly gotten worse with the changes around v7. Or just being unlucky; all tests failed today. Seen on amd64 and i386 builders, repeatedly but intermittently: unused: FAIL (4.86s) Test.hs:928: git diff did not show changes to unlocked file And I think other such failures, all involving v7/v6 mode tests. I managed to reproduce the unused failure with --keep-failures, and inside the repo, git diff was indeed not showing any changes for the modified unlocked file. The two stats will be the same other than mtime; the old and new files have the same size and inode, since the test case writes to the file and then overwrites it. Indeed, notice the identical timestamps: builder@orca:~/gitbuilder/build/.t/tmprepo335$ echo 1 > foo; stat foo; echo 2 > foo; stat foo File: foo Size: 2 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 3546179 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ builder) Gid: ( 1000/ builder) Access: 2018-10-29 22:14:10.894942036 +0000 Modify: 2018-10-29 22:14:10.894942036 +0000 Change: 2018-10-29 22:14:10.894942036 +0000 Birth: - File: foo Size: 2 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 3546179 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ builder) Gid: ( 1000/ builder) Access: 2018-10-29 22:14:10.894942036 +0000 Modify: 2018-10-29 22:14:10.898942036 +0000 Change: 2018-10-29 22:14:10.898942036 +0000 Birth: - I'm seeing this in Linux VMs; it doesn't happen on my laptop. I've also not experienced the intermittent test suite failures on my laptop. So, I hope that this small delay will avoid the problem. Update: I didn't, indeed I then reproduced the same failure on my laptop, so it must be due to something else. But keeping this change anyway since not needing to worry about lowish-resolution mtime in the test suite seems worthwhile.
This commit is contained in:
parent
bdeba74d4d
commit
595fb98473
4 changed files with 95 additions and 46 deletions
|
@ -10,6 +10,7 @@ module Test.Framework where
|
|||
import Test.Tasty
|
||||
import Test.Tasty.Runners
|
||||
import Test.Tasty.HUnit
|
||||
import Control.Concurrent
|
||||
|
||||
import Common
|
||||
import Types.Test
|
||||
|
@ -503,8 +504,17 @@ content f
|
|||
| "import" `isPrefixOf` f = "imported content"
|
||||
| otherwise = "unknown file " ++ f
|
||||
|
||||
writecontent :: FilePath -> String -> IO ()
|
||||
writecontent f c = do
|
||||
-- Delay 1/10th of a second, because filesystem's
|
||||
-- mtime resolution may not be very high, and we want to make sure
|
||||
-- that git etc notices the file has been modified even when
|
||||
-- multiple modifications happen close together.
|
||||
threadDelay 100000
|
||||
writeFile f c
|
||||
|
||||
changecontent :: FilePath -> IO ()
|
||||
changecontent f = writeFile f $ changedcontent f
|
||||
changecontent f = writecontent f $ changedcontent f
|
||||
|
||||
changedcontent :: FilePath -> String
|
||||
changedcontent f = content f ++ " (modified)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue