Skip to content

Commit

Permalink
Merge pull request #46 from haskell-works/newhoggy/support-record-dot…
Browse files Browse the repository at this point in the history
…-syntax

Support record dot syntax
  • Loading branch information
newhoggy authored Jan 13, 2025
2 parents 52b31b5 + fd4ac99 commit 6b5b513
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Tasty/Discover/Internal/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data Config = Config
, noModuleSuffix :: Bool -- ^ <<<DEPRECATED>>>: 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
Expand Down
11 changes: 9 additions & 2 deletions src/Test/Tasty/Discover/Internal/Driver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -130,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
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Tasty/Discover/Internal/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Tasty/Discover/TastyInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 22 additions & 10 deletions tasty-discover.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6b5b513

Please sign in to comment.