From de079a62d20668f8231496ac74d895fbfa01d9ea Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 13 Jan 2025 22:04:05 +1100 Subject: [PATCH 1/3] Explicit type signatures --- src/Test/Tasty/Discover/Internal/Driver.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Test/Tasty/Discover/Internal/Driver.hs b/src/Test/Tasty/Discover/Internal/Driver.hs index b6d64cf..a270eb2 100644 --- a/src/Test/Tasty/Discover/Internal/Driver.hs +++ b/src/Test/Tasty/Discover/Internal/Driver.hs @@ -106,9 +106,16 @@ findTests config = do -- | Extract the test names from discovered modules. extractTests :: FilePath -> String -> [Test] extractTests file = mkTestDeDuped . isKnownPrefix . parseTest - where mkTestDeDuped = map (mkTest file) . nub + where mkTestDeDuped :: [String] -> [Test] + mkTestDeDuped = map (mkTest file) . nub + + isKnownPrefix :: [String] -> [String] isKnownPrefix = filter (\g -> any (checkPrefix g) generators) + + checkPrefix :: String -> Generator -> Bool checkPrefix g = (`isPrefixOf` g) . generatorPrefix + + parseTest :: String -> [String] parseTest = map fst . concatMap lex . lines -- | Show the imports. From 62816c19f4d8ae8829f6637be8907ee93fc651cb Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 13 Jan 2025 22:18:41 +1100 Subject: [PATCH 2/3] Add support for overloaded dot syntax. Remove unused dependencies. Add dev build flag --- src/Test/Tasty/Discover/Internal/Config.hs | 2 +- src/Test/Tasty/Discover/Internal/Driver.hs | 2 +- src/Test/Tasty/Discover/Internal/Generator.hs | 2 +- src/Test/Tasty/Discover/TastyInfo.hs | 2 +- tasty-discover.cabal | 32 +++++++++++++------ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/Test/Tasty/Discover/Internal/Config.hs b/src/Test/Tasty/Discover/Internal/Config.hs index d53bb49..bdcc5ae 100644 --- a/src/Test/Tasty/Discover/Internal/Config.hs +++ b/src/Test/Tasty/Discover/Internal/Config.hs @@ -39,7 +39,7 @@ data Config = Config , noModuleSuffix :: Bool -- ^ <<>>: suffix and look in all modules. , debug :: Bool -- ^ Debug the generated module. , treeDisplay :: Bool -- ^ Tree display for the test results table. - } deriving (Show) + } deriving stock (Show) -- | The default configuration defaultConfig :: FilePath -> Config diff --git a/src/Test/Tasty/Discover/Internal/Driver.hs b/src/Test/Tasty/Discover/Internal/Driver.hs index a270eb2..e7c25e8 100644 --- a/src/Test/Tasty/Discover/Internal/Driver.hs +++ b/src/Test/Tasty/Discover/Internal/Driver.hs @@ -137,7 +137,7 @@ showTests config tests testNumVars = if treeDisplay config else zipWith const testNumVars tests newtype ModuleTree = ModuleTree (M.Map String (ModuleTree, [String])) - deriving (Eq, Show) + deriving stock (Eq, Show) showModuleTree :: ModuleTree -> [String] showModuleTree (ModuleTree mdls) = map showModule $ M.assocs mdls diff --git a/src/Test/Tasty/Discover/Internal/Generator.hs b/src/Test/Tasty/Discover/Internal/Generator.hs index a469a8d..31daa35 100644 --- a/src/Test/Tasty/Discover/Internal/Generator.hs +++ b/src/Test/Tasty/Discover/Internal/Generator.hs @@ -31,7 +31,7 @@ import System.FilePath (dropExtension, isPathSeparator) data Test = Test { testModule :: String -- ^ Module name. , testFunction :: String -- ^ Function name. - } deriving (Eq, Show, Ord) + } deriving stock (Eq, Show, Ord) -- | 'Test' constructor. mkTest :: FilePath -> String -> Test diff --git a/src/Test/Tasty/Discover/TastyInfo.hs b/src/Test/Tasty/Discover/TastyInfo.hs index 9f68a09..9f3bedc 100644 --- a/src/Test/Tasty/Discover/TastyInfo.hs +++ b/src/Test/Tasty/Discover/TastyInfo.hs @@ -7,7 +7,7 @@ import Data.Monoid data TastyInfo = TastyInfo { name :: Last String , description :: Last String - } deriving (Eq, Show) + } deriving stock (Eq, Show) instance Semigroup TastyInfo where a <> b = TastyInfo diff --git a/tasty-discover.cabal b/tasty-discover.cabal index 5a2077c..6c4cfcb 100644 --- a/tasty-discover.cabal +++ b/tasty-discover.cabal @@ -33,6 +33,11 @@ source-repository head type: git location: https://github.com/haskell-works/tasty-discover +flag dev + description: Enable development mode + manual: True + default: False + common base { build-depends: base >= 4.11 && < 5 } common bytestring { build-depends: bytestring >= 0.9 && < 1.0 } @@ -51,14 +56,27 @@ common tasty-hunit { build-depends: tasty-hunit >= common tasty-quickcheck { build-depends: tasty-quickcheck >= 0.10 && < 0.11 } common tasty-smallcheck { build-depends: tasty-smallcheck >= 0.8 && < 1.0 } +common project-config + default-extensions: DerivingStrategies + if (impl(ghc >= 9.2.1)) + OverloadedRecordDot + ghc-options: -Wall + -Widentities + -Wincomplete-uni-patterns + -Wmissing-deriving-strategies + -Wredundant-constraints + -Wunused-packages + default-language: GHC2021 + if (flag(dev)) + ghc-options: -Werror + common tasty-discover build-depends: tasty-discover library - import: base + import: base, project-config , Glob , containers - , directory , filepath , tasty exposed-modules: Test.Tasty.Discover @@ -74,10 +92,7 @@ library default-language: Haskell2010 executable tasty-discover - import: base - , Glob - , containers - , directory + import: base, project-config , filepath main-is: app/Main.hs autogen-modules: Paths_tasty_discover @@ -87,12 +102,9 @@ executable tasty-discover default-language: Haskell2010 test-suite tasty-discover-test - import: base - , Glob + import: base, project-config , bytestring , containers - , directory - , filepath , hedgehog , hspec , hspec-core From fd4ac994f8649f788c3b25d9a2154086e39fdb9e Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 14 Jan 2025 00:16:34 +1100 Subject: [PATCH 3/3] Exclude macOS builds for ghc-9.0.2 and earlier in CI --- .github/workflows/haskell.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index e65a47d..2991f58 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -20,9 +20,13 @@ jobs: ghc: ["9.8.1", "9.6.3", "9.4.8", "9.2.8", "9.0.2", "8.10.7"] os: [ubuntu-latest, macOS-latest, windows-latest] exclude: - - os: windows-latest - ghc: "9.4.2" - + - os: windows-latest + ghc: "9.4.2" + - os: macOS-latest + ghc: "9.0.2" + - os: macOS-latest + ghc: "8.10.7" + env: # Modify this value to "invalidate" the cabal cache. CABAL_CACHE_VERSION: "2024-01-05"