[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#815519: haskell-mockery: testsuite fails on some filesystems

Package: src:haskell-mockery
Version: 0.3.2-3
Severity: normal
Tags: patch


haskell-mockery has a test that:
  * creates file 'foo'
  * gets its mtime (t0)
  * sleeps ~10ms
  * touches it
  * gets its mtime (t1)
  * asserts t1 > t0

This doesn't work on some filesystems, such as GNU/kFreeBSD's ufs or
GNU/Hurd's implementation of extfs, because those don't store mtime
with sub-second precision.  Maybe not all Linux filesystems do either.

| Test.Mockery.Directory
|   withFile
|     creates a temporary file with the given contents
|   touch
|     creates an empty file
|     creates any missing directories
|     when file already exists
|       updates modification time FAILED [1]
|       does not modify file content
| Test.Mockery.Logging
|   captureLogs
|     returns all log messages of an action
|     restores the original log sink
| Failures:
|   test/Test/Mockery/DirectorySpec.hs:42: 
|   1) Test.Mockery.Directory.touch, when file already exists, updates
| modification time
|        predicate failed on: 2016-02-22 00:15:19 UTC
| Randomized with seed 569868309
| Finished in 0.0244 seconds

Since the test ran for only a fraction of a second, it's very unlikely
the file mtime (in whole seconds) would increment during that time.
Please could you increase the delay to >= 1 second so that the test
works properly on such filesystems.

I've attached a patch, although I don't know Haskell and I wasn't sure
what the two different intervals mean.  So I added some extra zeros to
both, and it now runs for 1-2 seconds and it gets the expected result on
kfreebsd-amd64 with UFS.


-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 10.1-0-amd64
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Subject: delay >1sec between testing mtime
From: Steven Chamberlain <steven@pyro.eu.org>
Date: Mon, 22 Feb 2016 00:03:42 +0000

Not all filesystems store mtime with sub-second precision.  So,
delay for at least 1 second between sampling the test file's mtime.

--- ./test/Test/Mockery/DirectorySpec.hs.orig	2015-08-08 03:50:38.000000000 +0100
+++ ./test/Test/Mockery/DirectorySpec.hs	2016-02-21 23:59:34.327640846 +0000
@@ -35,8 +35,8 @@
         before_ (writeFile name "bar") $ do
           it "updates modification time" $ do
             t0 <- getModificationTime name
-            threadDelay 10000
-            whenTravis (threadDelay 1000000)
+            threadDelay 1000000
+            whenTravis (threadDelay 10000000)
             touch name
             t1 <- getModificationTime name
             t0 `shouldSatisfy` (< t1)

Reply to: