packages feed

tasty-lua 0.2.0.1 → 0.2.1

raw patch · 5 files changed

+35/−9 lines, 5 files

Files

CHANGELOG.md view
@@ -1,5 +1,16 @@ # Revision history for tasty-lua +## 0.2.1 -- 2020-01-26++- Fixed an issue with error reporting: the bug caused test-group+  names to be added multiple times when reporting a test failure.++## 0.2.0.1 -- 2019-06-19++- List all files in cabal file: *stack.yaml* and+  *test/tasty-lua.lua* were added to the list of extra source+  files.+ ## 0.2.0 -- 2019-05-19  - Renamed `testFileWith` to `testLuaFile`, and
src/Test/Tasty/Lua.hs view
@@ -22,6 +22,7 @@ where  import Control.Exception (SomeException, try)+import Data.Bifunctor (first) import Data.List (intercalate) import Data.Semigroup (Semigroup (..)) import Foreign.Lua (Lua)@@ -83,22 +84,29 @@ stringifyFailureGist (names, msg) =   intercalate " // " names ++ ":\n" ++ msg ++ "\n\n" --- | Extract all failures from a test result tree.+-- | Combine all failures (or successes) from a test result tree into a+-- @'ResultSummary'@. If the tree contains only successes, the result+-- will be @'SuccessSummary'@ with the number of successful tests; if+-- there was at least one failure, the result will be+-- @'FailureSummary'@, with a @'FailureInfo'@ for each failure. collectSummary :: ResultTree -> ResultSummary collectSummary (ResultTree name tree) =   case tree of     SingleTest Success       -> SuccessSummary 1     SingleTest (Failure msg) -> FailureSummary [([name], msg)]-    TestGroup subtree        -> foldr go (SuccessSummary 0) subtree-      where go r summary = collectSummary r <> addGroup name summary+    TestGroup subtree        -> foldMap (addGroup name . collectSummary)+                                        subtree +-- | Add the name of the current test group to all failure summaries. addGroup :: TestName -> ResultSummary -> ResultSummary-addGroup name (FailureSummary fs) = FailureSummary (map addName fs)-  where addName (names, msg) = (name : names, msg)-addGroup _name summary = summary+addGroup name  (FailureSummary fs) = FailureSummary (map (first (name:)) fs)+addGroup _name summary             = summary  instance Semigroup ResultSummary where   (SuccessSummary n)  <> (SuccessSummary m)  = SuccessSummary (n + m)   (SuccessSummary _)  <> (FailureSummary fs) = FailureSummary fs   (FailureSummary fs) <> (SuccessSummary _)  = FailureSummary fs   (FailureSummary fs) <> (FailureSummary gs) = FailureSummary (fs ++ gs)++instance Monoid ResultSummary where+  mempty = SuccessSummary 0
+ stack.yaml view
@@ -0,0 +1,5 @@+resolver: lts-13.18+packages:+  - .+extra-deps:+  - hslua-1.0.3.1
tasty-lua.cabal view
@@ -1,5 +1,5 @@ name:                tasty-lua-version:             0.2.0.1+version:             0.2.1 synopsis:            Write tests in Lua, integrate into tasty. description:         Allow users to define tasty tests from Lua. homepage:            https://github.com/hslua/tasty-lua@@ -13,6 +13,7 @@ extra-source-files:  CHANGELOG.md                    , tasty.lua                    , test/test-tasty.lua+                   , stack.yaml cabal-version:       >=1.10 tested-with:         GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5 
test/test-tasty-lua.hs view
@@ -46,8 +46,9 @@       assertEqual' "loading the module fails " Lua.OK =<<         Lua.dostring "require 'tasty'" -  , testGroup "testFileWith" $-      [testLuaFile Lua.run "test-tasty.lua" ("test" </> "test-tasty.lua")]+  , testGroup "testFileWith"+    [ testLuaFile Lua.run "test-tasty.lua" ("test" </> "test-tasty.lua")+    ]   ]  assertEqual' :: (Show a, Eq a) => String -> a -> a -> Lua ()