packages feed

tasty-rerun 1.1.19 → 1.1.20

raw patch · 3 files changed

+87/−69 lines, 3 filesdep +filepathdep ~basedep ~optparse-applicativedep ~tasty

Dependencies added: filepath

Dependency ranges changed: base, optparse-applicative, tasty

Files

Changelog.md view
@@ -1,3 +1,8 @@+# 1.1.20++* Append the base name of the calling executable to the name of the default log file.+* Use `System.IO.readFile'` to read the state.+ # 1.1.19  * Support tasty 1.5.
src/Test/Tasty/Ingredients/Rerun.hs view
@@ -48,10 +48,6 @@ -- of 'Tasty.defaultMainWithIngredients' -- into 'rerunningTests'. -{-# LANGUAGE CPP #-}-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE FlexibleContexts #-}- module Test.Tasty.Ingredients.Rerun   ( defaultMainWithRerun   , rerunningTests@@ -76,9 +72,10 @@ import Data.Ord (Ord) import Data.Proxy (Proxy(..)) import Data.String (String)-import Data.Typeable (Typeable)-import System.IO (FilePath, IO, readFile, writeFile)+import System.FilePath ((<.>), takeBaseName)+import System.IO (FilePath, IO, readFile', writeFile) import System.IO.Error (catchIOError, isDoesNotExistError, ioError)+import System.IO.Unsafe (unsafePerformIO) import Text.Read (Read, read) import Text.Show (Show, show) @@ -89,23 +86,27 @@ import qualified Data.Map.Strict as Map import qualified Data.Set as Set import qualified Options.Applicative as OptParse+import qualified System.Environment import qualified Test.Tasty.Options as Tasty import qualified Test.Tasty.Runners as Tasty  ---------------------------------------------------------------------------------newtype RerunLogFile = RerunLogFile FilePath-  deriving (Typeable)+data RerunLogFile+  = DefaultRerunLogFile+  | CustomRerunLogFile FilePath  instance Tasty.IsOption RerunLogFile where   optionName = return "rerun-log-file"-  optionHelp = return "Location of the log file (default: .tasty-rerun-log)"-  defaultValue = RerunLogFile ".tasty-rerun-log"-  parseValue = Just . RerunLogFile+  optionHelp = return+    ( "Location of the log file (default: " +++      show (unsafePerformIO getDefaultLogfileName) ++ ")"+    )+  defaultValue = DefaultRerunLogFile+  parseValue = Just . CustomRerunLogFile   optionCLParser = Tasty.mkOptionCLParser (OptParse.metavar "FILE")  -------------------------------------------------------------------------------- newtype UpdateLog = UpdateLog Bool-  deriving (Typeable)  instance Tasty.IsOption UpdateLog where   optionName = return "rerun-update"@@ -127,7 +128,6 @@  -------------------------------------------------------------------------------- newtype FilterOption = FilterOption (Set.Set Filter)-  deriving (Typeable)  instance Tasty.IsOption FilterOption where   optionName = return "rerun-filter"@@ -143,7 +143,6 @@  -------------------------------------------------------------------------------- newtype AllOnSuccess = AllOnSuccess Bool-  deriving (Typeable)  instance Tasty.IsOption AllOnSuccess where   optionName = return "rerun-all-on-success"@@ -154,7 +153,6 @@  -------------------------------------------------------------------------------- newtype Rerun = Rerun { unRerun :: Bool }-  deriving (Typeable)  instance Tasty.IsOption Rerun where   optionName = return "rerun"@@ -207,8 +205,11 @@ rerunningTests ingredients =   Tasty.TestManager (rerunOptions ++ Tasty.ingredientsOptions ingredients) $     \options testTree -> Just $ do-      let RerunLogFile stateFile = Tasty.lookupOption options-          (UpdateLog updateLog, AllOnSuccess allOnSuccess, FilterOption filter)+      stateFile <- case Tasty.lookupOption options of+        DefaultRerunLogFile -> getDefaultLogfileName+        CustomRerunLogFile stateFile -> return stateFile++      let (UpdateLog updateLog, AllOnSuccess allOnSuccess, FilterOption filter)             | unRerun (Tasty.lookupOption options) = rerunMeaning             | otherwise = (Tasty.lookupOption options, Tasty.lookupOption options, Tasty.lookupOption options) @@ -289,7 +290,7 @@    tryLoadStateFrom :: FilePath -> IO (Maybe (Map.Map [String] TestResult))   tryLoadStateFrom filePath = do-    fileContents <- (Just <$> readFile filePath)+    fileContents <- (Just <$> readFile' filePath)                       `catchIOError` (\e -> if isDoesNotExistError e                                               then return Nothing                                               else ioError e)@@ -326,16 +327,31 @@      in Tasty.trivialFold       { Tasty.foldSingle = foldSingle-#if MIN_VERSION_tasty(1,5,0)       , Tasty.foldGroup = const (\name -> foldGroup name . mconcat)-#elif MIN_VERSION_tasty(1,4,0)-      , Tasty.foldGroup = const foldGroup-#else-      , Tasty.foldGroup = foldGroup-#endif       }      where     lookupStatus i = STM.readTVar $       fromMaybe (error "Attempted to lookup test by index outside bounds")                 (IntMap.lookup i statusMap)++-- | Get the default log file name.+-- Whether a package-wide or a per-component log file name is returned depends+-- on the possibility to determine the path to the test executable reliably; See+-- 'System.Environment.executablePath'.+getDefaultLogfileName :: IO FilePath+getDefaultLogfileName =+  logfileName <$>+    fromMaybe (return Nothing) System.Environment.executablePath++-- | Returns the default log file name.+-- The argument passed should be the file path of the test executable, if that+-- path is available. If @Nothing@ is passed, then a package-wide log file name+-- is returned, which may lead to problems; See+-- https://github.com/ocharles/tasty-rerun/issues/22 .+logfileName+  :: Maybe FilePath -- ^ The file path of the test executable.+  -> String -- ^ The Tasty Rerun log file name.+logfileName Nothing = ".tasty-rerun-log"+logfileName (Just executablePath) =+    logfileName Nothing <.> takeBaseName executablePath
tasty-rerun.cabal view
@@ -1,53 +1,50 @@-name:                tasty-rerun-version:             1.1.19-homepage:            http://github.com/ocharles/tasty-rerun-license:             BSD3-license-file:        LICENSE-author:              Oliver Charles-maintainer:          ollie@ocharles.org.uk-copyright:           Oliver Charles (c) 2014,-                     Andrew Lelechenko (c) 2019-category:            Testing-build-type:          Simple-cabal-version:       >=1.10-extra-source-files:-  Changelog.md-  README.md+cabal-version:   2.2+name:            tasty-rerun+version:         1.1.20+license:         BSD-3-Clause+license-file:    LICENSE+copyright:+    Oliver Charles (c) 2014,+    Andrew Lelechenko (c) 2019 -synopsis:-  Rerun only tests which failed in a previous test run+maintainer:      ollie@ocharles.org.uk+author:          Oliver Charles+tested-with:+    ghc ==9.12.1 ghc ==9.10.1 ghc ==9.8.4 ghc ==9.6.6 ghc ==9.4.8 +homepage:        http://github.com/ocharles/tasty-rerun+synopsis:        Rerun only tests which failed in a previous test run description:-  This ingredient-  for the <https://hackage.haskell.org/package/tasty tasty> testing framework-  allows filtering a test tree depending-  on the outcome of the previous run.-  This may be useful in many scenarios,-  especially when a test suite grows large.+    This ingredient+    for the <https://hackage.haskell.org/package/tasty tasty> testing framework+    allows filtering a test tree depending+    on the outcome of the previous run.+    This may be useful in many scenarios,+    especially when a test suite grows large. -tested-with:-  GHC==9.8.1, GHC==9.6.2, GHC==9.4.5, GHC==9.2.8, GHC==9.0.2, GHC==8.10.7,-  GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3,-  GHC==7.8.4, GHC==7.6.3+category:        Testing+build-type:      Simple+extra-doc-files:+    Changelog.md+    README.md  source-repository head-  type: git-  location: https://github.com/ocharles/tasty-rerun+    type:     git+    location: https://github.com/ocharles/tasty-rerun  library-  exposed-modules:     Test.Tasty.Ingredients.Rerun-  build-depends:-    base >=4.6 && <4.19,-    containers >= 0.5.0.0 && < 0.7,-    mtl >= 2.1.2 && < 2.4,-    optparse-applicative >= 0.6 && < 0.19,-    split >= 0.1 && < 0.3,-    stm >= 2.4.2 && < 2.6,-    tagged >= 0.7 && <0.9,-    tasty >=1.2 && <1.6,-    transformers >= 0.3.0.0 && < 0.7-  hs-source-dirs:      src-  default-language:    Haskell2010-  ghc-options: -Wall-  if impl(ghc >= 8.0)-    ghc-options:    -Wcompat+    exposed-modules:  Test.Tasty.Ingredients.Rerun+    hs-source-dirs:   src+    default-language: GHC2021+    ghc-options:      -Wall -Wcompat+    build-depends:+        base >=4.17 && <4.22,+        containers >=0.5.0.0 && <0.9,+        filepath <1.6,+        mtl >=2.1.2 && <2.4,+        optparse-applicative >=0.6 && <0.19,+        split >=0.1 && <0.3,+        stm >=2.4.2 && <2.6,+        tagged >=0.7 && <0.9,+        tasty >=1.5 && <1.6,+        transformers >=0.3.0.0 && <0.7