Commits

Bryan O'Sullivan committed 8931bbb

Begin support for Hastache-based reporting.

Comments (0)

Files changed (2)

lib/Network/HTTP/LoadTest/Report.hs

       reportBasic
     , reportEvents
     , reportFull
+    , writeReportBasic
     -- * Other reports
     , csvEvents
     -- * Helper functions
 import Data.Vector (Vector)
 import Network.HTTP.LoadTest.Types (Analysis(..), Basic(..), Event(..),
                                     Summary(..))
+import Paths_pronk (getDataFileName)
 import Prelude hiding (print)
 import Statistics.Resampling.Bootstrap (Estimate(..))
+import System.FilePath ((</>))
 import System.IO (Handle)
+import Text.Hastache (MuType(..))
+import Text.Hastache.Context (mkGenericContext)
+import qualified Data.ByteString.Lazy as L
 import qualified Data.HashMap.Strict as H
 import qualified Data.Text.Format as T
 import qualified Data.Vector.Generic as G
+import qualified Text.Hastache as H
 
 reportBasic :: Handle -> Analysis Basic -> IO ()
 reportBasic h Analysis{..} = do
                        ] `mappend` b
     classify Timeout          = "timeout"
     classify HttpResponse{..} = build respCode
+
+templateDir :: FilePath
+templateDir = "templates"
+
+writeReportBasic :: Handle -> Analysis Basic -> IO ()
+writeReportBasic h Analysis{..} = do
+  tpl <- getDataFileName templateDir
+  let context n@"latency" = mkGenericContext latency n
+      context _           = MuNothing
+  bs <- H.hastacheFile H.defaultConfig (tpl </> "report.tpl") context
+  L.hPutStr h bs
     Network.HTTP.LoadTest.Environment
     Network.HTTP.LoadTest.Report
     Network.HTTP.LoadTest.Types
+  other-modules:
+    Paths_pronk
 
   ghc-options: -Wall
   if flag(developer)
     case-insensitive,
     criterion >= 0.6.0.0,
     deepseq,
+    filepath,
     hashable >= 1.1.2.0,
+    hastache,
     http-enumerator >= 0.7,
     http-types,
     statistics >= 0.10.0.0,