@@ -102,6 +102,9 @@ import Data.IORef.Extra (atomicModifyIORef_)
102
102
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
103
103
import Text.Regex.TDFA ((=~) )
104
104
import qualified Progress
105
+ import Development.IDE.Core.FileStore (getModTime )
106
+ import Control.Concurrent (threadDelay )
107
+ import Text.Printf (printf )
105
108
106
109
waitForProgressBegin :: Session ()
107
110
waitForProgressBegin = skipManyTill anyMessage $ satisfyMaybe $ \ case
@@ -5492,9 +5495,24 @@ unitTests = do
5492
5495
actualOrder <- liftIO $ readIORef orderRef
5493
5496
5494
5497
liftIO $ actualOrder @?= reverse [(1 :: Int ).. 20 ]
5498
+ , testCase " timestamps have millisecond resolution" $ do
5499
+ resolution_us <- findResolution_us 1
5500
+ let msg = printf " Timestamps do not have millisecond resolution: %dus" resolution_us
5501
+ assertBool msg (resolution_us <= 1000 )
5495
5502
, Progress. tests
5496
5503
]
5497
5504
5505
+ findResolution_us :: Int -> IO Int
5506
+ findResolution_us delay_us | delay_us >= 1000000 = error " Unable to compute timestamp resolution"
5507
+ findResolution_us delay_us = withTempFile $ \ f -> withTempFile $ \ f' -> do
5508
+ writeFile f " "
5509
+ threadDelay delay_us
5510
+ writeFile f' " "
5511
+ t <- getModTime f
5512
+ t' <- getModTime f'
5513
+ if t /= t' then return delay_us else findResolution_us (delay_us * 10 )
5514
+
5515
+
5498
5516
testIde :: IDE. Arguments -> Session () -> IO ()
5499
5517
testIde arguments session = do
5500
5518
config <- getConfigFromEnv
0 commit comments