packages feed

tasty-html 0.4.1 → 0.4.1.1

raw patch · 4 files changed

+46/−25 lines, 4 filesnew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Test.Tasty.Runners.Html: instance Constructor C1_0Summary
- Test.Tasty.Runners.Html: instance Datatype D1Summary
- Test.Tasty.Runners.Html: instance Generic Summary
- Test.Tasty.Runners.Html: instance IsOption (Maybe AssetsPath)
- Test.Tasty.Runners.Html: instance IsOption (Maybe HtmlPath)
- Test.Tasty.Runners.Html: instance Monoid Summary
- Test.Tasty.Runners.Html: instance Selector S1_0_0Summary
- Test.Tasty.Runners.Html: instance Selector S1_0_1Summary
- Test.Tasty.Runners.Html: instance Selector S1_0_2Summary
- Test.Tasty.Runners.Html: instance Typeable AssetsPath
- Test.Tasty.Runners.Html: instance Typeable HtmlPath
+ Test.Tasty.Runners.Html: instance GHC.Base.Monoid Test.Tasty.Runners.Html.Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Constructor Test.Tasty.Runners.Html.C1_0Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Datatype Test.Tasty.Runners.Html.D1Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Generic Test.Tasty.Runners.Html.Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Selector Test.Tasty.Runners.Html.S1_0_0Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Selector Test.Tasty.Runners.Html.S1_0_1Summary
+ Test.Tasty.Runners.Html: instance GHC.Generics.Selector Test.Tasty.Runners.Html.S1_0_2Summary
+ Test.Tasty.Runners.Html: instance Test.Tasty.Options.IsOption (GHC.Base.Maybe Test.Tasty.Runners.Html.AssetsPath)
+ Test.Tasty.Runners.Html: instance Test.Tasty.Options.IsOption (GHC.Base.Maybe Test.Tasty.Runners.Html.HtmlPath)

Files

CHANGELOG.md view
@@ -1,4 +1,9 @@-0.4.1 - 2014-18-11+0.4.1.1 - 2015-11-10+--------------------++- Report running time for tests.++0.4.1 - 2014-11-18 ------------------  - Export `AssetsPath`.
README.md view
@@ -18,7 +18,7 @@ import Data.List import Data.Ord -main = defaultMainWithIngredients (htmlRunner:deafultIngredients) tests+main = defaultMainWithIngredients (htmlRunner:defaultIngredients) tests  tests :: TestTree tests = testGroup "Tests" [properties, unitTests]@@ -58,7 +58,14 @@   ] ``` -And here is the output of the above program rendered to HTML:+To produce the HTML output, run the test program with the `--html` option,+giving it the html file path:++```+./test --html results.html+```++Here is the output of the above program rendered to HTML:  ![](https://raw.github.com/feuerbach/tasty-html/master/screenshot.png) 
Test/Tasty/Runners/Html.hs view
@@ -11,7 +11,7 @@   ) where  import Control.Applicative (Const(..), (<$))-import Control.Monad ((>=>), unless, forM_)+import Control.Monad ((>=>), unless, forM_, when) import Control.Monad.Trans.Class (lift) import Control.Concurrent.STM (atomically, readTVar) import qualified Control.Concurrent.STM as STM(retry)@@ -42,6 +42,7 @@ import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A import Text.Blaze.Html.Renderer.Text (renderHtml)+import Text.Printf (printf)  import Paths_tasty_html (getDataFileName) @@ -90,9 +91,8 @@         options         testTree -    -- Ignore elapsed time-    return $ const $ do-      generateHtml summary htmlPath mAssetsPath+    return $ \time -> do+      generateHtml summary time htmlPath mAssetsPath       return $ getSum (summaryFailures summary) == 0   where@@ -141,9 +141,10 @@    -- Generate HTML for the test   msg <- liftIO . Tasty.formatMessage . Tasty.resultDescription $ result-  let summary = if Tasty.resultSuccessful result-                then mkSuccess testName msg-                else mkFailure testName msg+  let time = Tasty.resultTime result+      summary = if Tasty.resultSuccessful result+                then mkSuccess (testName, time) msg+                else mkFailure (testName, time) msg    Const summary <$ State.modify (+1) @@ -168,10 +169,11 @@  -- | Generates the final HTML report. generateHtml :: Summary  -- ^ Test summary.+             -> Tasty.Time -- ^ Total run time.              -> FilePath -- ^ Where to write.              -> Maybe AssetsPath -- ^ Path to external assets              -> IO ()-generateHtml summary htmlPath mAssetsPath = do+generateHtml summary time htmlPath mAssetsPath = do       -- Helpers to load external assets   let getRead = getDataFileName >=> B.readFile       includeMarkup = getRead >=> return . H.unsafeByteString@@ -215,13 +217,15 @@                       H.toMarkup . getSum $ summaryFailures summary                       " out of " :: Markup                       H.toMarkup tests-                      " tests failed"+                      " tests failed" :: Markup+                      H.span ! A.class_ "text-muted" $ H.toMarkup (formatTime time)                 else                   H.div ! A.class_ "alert alert-success" $                     H.p ! A.class_ "lead text-center" $ do                       "All " :: Markup                       H.toMarkup tests-                      " tests passed"+                      " tests passed" :: Markup+                      H.span ! A.class_ "text-muted" $ H.toMarkup (formatTime time)              H.div ! A.class_ "row" $               H.div ! A.class_ "well" $@@ -237,12 +241,12 @@ mkSummary contents = mempty { htmlRenderer = itemMarkup contents }  -- | Create an HTML 'Summary' with a test success.-mkSuccess :: TestName+mkSuccess :: (TestName, Tasty.Time)           -> String -- ^ Description for the test.           -> Summary-mkSuccess testName desc =+mkSuccess nameAndTime desc =       ( mkSummary $ testItemMarkup-          testName+          nameAndTime           (desc, "text-muted")           "glyphicon-ok-sign"           "btn-success"@@ -250,12 +254,12 @@       ) { summarySuccesses = Sum 1 }  -- | Create an HTML 'Summary' with a test failure.-mkFailure :: TestName+mkFailure :: (TestName, Tasty.Time)           -> String -- ^ Description for the test.           -> Summary-mkFailure testName desc =+mkFailure nameAndTime desc =       ( mkSummary $ testItemMarkup-          testName+          nameAndTime           (desc, "text-danger")           "glyphicon-remove-sign"           "btn-danger"@@ -292,23 +296,28 @@       buttonMarkup (extra <> " collapsible") "glyphicon-folder-open"       H.div ! A.class_ "media-body" $ do         H.h4 ! A.class_ ("media-heading " <> text) $-          H.toMarkup $ "  " ++ groupName+          H.toMarkup groupName         body  -- | Markup for a single test.-testItemMarkup :: TestName+testItemMarkup :: (TestName, Tasty.Time)                -> CssDescription                -> CssIcon                -> CssExtra                -> CssText                -> Markup-testItemMarkup testName (desc,desca) icon extra text = do+testItemMarkup (testName,time) (desc,desca) icon extra text = do   buttonMarkup extra icon   H.div ! A.class_ "media-body" $ do-    H.h5 ! A.class_ ("media-heading " <> text) $-      H.toMarkup $ "  " ++ testName+    H.h5 ! A.class_ ("media-heading " <> text) $ do+      H.toMarkup testName+      when (time >= 0.01) $+        H.span ! A.class_ "text-muted" $ H.toMarkup (formatTime time)      unless (null desc) $       H.pre $ H.small ! A.class_ desca $ H.toMarkup desc++formatTime :: Tasty.Time -> String+formatTime = printf " (%.2fs)"  -- vim: textwidth=79 shiftwidth=2
tasty-html.cabal view
@@ -1,5 +1,5 @@ name:                tasty-html-version:             0.4.1+version:             0.4.1.1 synopsis:            Render tasty output to HTML description:         A tasty ingredient to output test results in HTML5. license:             MIT