diff --git a/semantic-diff.cabal b/semantic-diff.cabal index d18ee9ac1..06f18b667 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -182,6 +182,7 @@ test-suite test , regex-compat , semantic-diff , text >= 1.2.1.3 + , unordered-containers , these , vector ghc-options: -threaded -rtsopts -with-rtsopts=-N -j -pgml=script/g++ diff --git a/src/GitmonClient.hs b/src/GitmonClient.hs index 59787f317..fcc586e4c 100644 --- a/src/GitmonClient.hs +++ b/src/GitmonClient.hs @@ -1,5 +1,5 @@ -- | We use BangPatterns to force evaluation of git operations to preserve accuracy in measuring system stats (particularly disk read bytes) -{-# LANGUAGE RecordWildCards, BangPatterns, DeriveGeneric, RankNTypes #-} +{-# LANGUAGE RecordWildCards, DeriveGeneric, RankNTypes #-} {-# OPTIONS_GHC -fno-warn-unused-do-bind #-} module GitmonClient where @@ -85,8 +85,7 @@ reportGitmon' SocketFactory{..} program gitCommand = gitmonStatus <- safeGitmonIO $ recv socket' 1024 (startTime, beforeProcIOContents) <- collectStats - -- | We are eagerly evaluating the gitCommand with BangPatterns. This is to preserve accuracy in measuring the process stats calculated, in particular disk read bytes. - let !result = withGitmonStatus gitmonStatus gitCommand + let result = withGitmonStatus gitmonStatus gitCommand (afterTime, afterProcIOContents) <- collectStats let (cpuTime, diskReadBytes, diskWriteBytes, resultCode) = procStats startTime afterTime beforeProcIOContents afterProcIOContents diff --git a/test/GitmonClientSpec.hs b/test/GitmonClientSpec.hs index c9ea00b7a..712a6ba0c 100644 --- a/test/GitmonClientSpec.hs +++ b/test/GitmonClientSpec.hs @@ -5,8 +5,9 @@ import Data.Aeson import Data.Aeson.Types import Data.ByteString.Char8 (ByteString, pack, unpack) import Data.Foldable -import Data.Maybe (fromJust) -import Data.Text +import Data.HashMap.Lazy (empty) +import Data.Maybe (fromJust, fromMaybe) +import Data.Text hiding (empty) import Git.Libgit2 import Git.Repository import Git.Types hiding (Object) @@ -201,10 +202,10 @@ infoToData input = data' . toObject <$> extract regex input ] toObject :: ByteString -> Object -toObject = fromJust . decodeStrict +toObject input = fromMaybe empty (decodeStrict input) regex :: Regex regex = mkRegexWithOpts "({.*\"update\".*\"}})({.*\"schedule\"})({.*\"finish\".*}})" False True extract :: Regex -> ByteString -> [ByteString] -extract regex input = Data.ByteString.Char8.pack <$> fromJust (matchRegex regex (Data.ByteString.Char8.unpack input)) +extract regex input = Data.ByteString.Char8.pack <$> fromMaybe [""] (matchRegex regex (Data.ByteString.Char8.unpack input))