@@ -6,8 +6,6 @@ import Control.Monad
6import Control.Monad.IO.Class
6import Control.Monad.IO.Class
7import Data.Int
7import Data.Int
8import GHC.Stats
8import GHC.Stats
9−import Language.Javascript.JSaddle.Types (liftJSM)
10−import Language.Javascript.JSaddle.Run
11import Language.Javascript.JSaddle.Warp
9import Language.Javascript.JSaddle.Warp
12import Reflex.Dom.Core
10import Reflex.Dom.Core
13import System.Exit
11import System.Exit
@@ -20,7 +18,7 @@ import System.Process
20-- probably have a memory leak; going under the minimum doesn't indicate a
18-- probably have a memory leak; going under the minimum doesn't indicate a
21-- memory leak, but may mean the test needs to be updated.
19-- memory leak, but may mean the test needs to be updated.
22minBytesAllowed, resetThreshold, maxBytesAllowed :: Int64
20minBytesAllowed, resetThreshold, maxBytesAllowed :: Int64
23−(minBytesAllowed, resetThreshold, maxBytesAllowed) = (200000, 400000, 440000)
21+(minBytesAllowed, resetThreshold, maxBytesAllowed) = (200000, 400000, 490000)
25main :: IO ()
23main :: IO ()
@@ -40,13 +38,9 @@ main = do
40 d <- holdDyn mempty $ mempty <$ domEvent Click e
38 d <- holdDyn mempty $ mempty <$ domEvent Click e
42 postBuild <- getPostBuild
40 postBuild <- getPostBuild
43− let f (!failures, !n) = if n < 3000
41+ let f (!failures, !n) = liftIO $ if n < 3000
45− liftIO $ performMajorGC
42+ then do performMajorGC
46− liftJSM $ do
43+ threadDelay 5000 -- Wait a bit to allow requestAnimationFrame to call its callback sometimes; this value was experimentally determined
47− _ <- waitForAnimationFrame
50 gcStats <- getGCStats
44 gcStats <- getGCStats
51 print $ currentBytesUsed gcStats
45 print $ currentBytesUsed gcStats
52 when (currentBytesUsed gcStats < minBytesAllowed) $ do
46 when (currentBytesUsed gcStats < minBytesAllowed) $ do
@@ -58,10 +52,9 @@ main = do
58 putStrLn "FAILED: currentBytesUsed > maxBytesAllowed"
52 putStrLn "FAILED: currentBytesUsed > maxBytesAllowed"
59 finishTest $ ExitFailure 1
53 finishTest $ ExitFailure 1
60 return $ Just (if overMax then succ failures else (if underReset then 0 else failures), succ n)
54 return $ Just (if overMax then succ failures else (if underReset then 0 else failures), succ n)
62− putStrLn "SUCCEEDED"
55+ else do putStrLn "SUCCEEDED"
63− finishTest ExitSuccess
56+ finishTest ExitSuccess
64− return Nothing
57+ return Nothing
65 rec redraw <- performEvent <=< delay 0 $ f <$> leftmost
58 rec redraw <- performEvent <=< delay 0 $ f <$> leftmost
66 [ ((0 :: Int), (0 :: Int)) <$ postBuild
59 [ ((0 :: Int), (0 :: Int)) <$ postBuild
67 , fmapMaybe id redraw
60 , fmapMaybe id redraw