on develop help sign in
Merge pull request #258 from reflex-frp/ts-fix-gc-test

Fix gc test for GHC 8.4

commite9406f22c74541b95d97bd4af7db1c289b6c4440 authorRyan Trinkle <ryan.trinkle@gmail.com> dateMon 3 Dec 2018, 08:13 (8 years ago) parent8bde2d737a7c6a
2 files changed+11−4
reflex-dom-core/reflex-dom-core.cabal+1−3 reflex-dom-core/test/gc.hs+10−1
reflex-dom-core/reflex-dom-core.cabal+1−3
@@ -149,8 +149,6 @@ test-suite hlint
149149 main-is: hlint.hs
150150 type: exitcode-stdio-1.0
151151
152−-- broken test on base 4.11 & ghc 8.4.3
153−-- needs to be updated for changes in GHC.Stats
154152test-suite gc
155153 build-depends: base
156154 , reflex
@@ -166,7 +164,7 @@ test-suite gc
166164 ghc-prof-options: -fprof-auto -optP-DPROFILING
167165 main-is: gc.hs
168166 type: exitcode-stdio-1.0
169− if !os(linux) || !arch(x86_64) || impl(ghc >= 8.4.0)
167+ if !os(linux) || !arch(x86_64)
170168 buildable: False
171169
172170source-repository head
reflex-dom-core/test/gc.hs+10−1
@@ -19,6 +19,15 @@ import System.Mem
1919import System.Posix
2020import System.Process
2121
22+#if MIN_VERSION_base(4,11,0)
23+import GHC.Stats (getRTSStatsEnabled, getRTSStats, RTSStats(..), gcdetails_live_bytes, gc)
24+currentBytesUsed :: RTSStats -> Int64
25+currentBytesUsed = fromIntegral . gcdetails_live_bytes . gc
26+#else
27+import GHC.Stats (getGCStats, GCStats(..))
28+getRTSStats = getGCStats
29+#endif
30+
2231-- In initial testing, the minimum live bytes count was 233128 and maximum was
2332-- 363712. Going over the maximum means the test has actually failed - we
2433-- probably have a memory leak; going under the minimum doesn't indicate a
@@ -63,7 +72,7 @@ main = do
6372 let f (!failures, !n) = liftIO $ if n < 3000
6473 then do performMajorGC
6574 threadDelay 5000 -- Wait a bit to allow requestAnimationFrame to call its callback sometimes; this value was experimentally determined
66− gcStats <- getGCStats
75+ gcStats <- getRTSStats
6776 print $ currentBytesUsed gcStats
6877 when (currentBytesUsed gcStats < minBytesAllowed) $ do
6978 putStrLn "FAILED: currentBytesUsed < minBytesAllowed"