feat[tests]: Use tasty for hierarchical tests

This commit is contained in:
vegowotenks 2025-08-14 10:45:08 +02:00
parent 0d8470a87f
commit 766528677f
4 changed files with 25 additions and 9 deletions

View file

@ -22,6 +22,7 @@ default-extensions:
- DerivingStrategies - DerivingStrategies
- ImportQualifiedPost - ImportQualifiedPost
- NoImplicitPrelude - NoImplicitPrelude
- OverloadedStrings
- StandaloneKindSignatures - StandaloneKindSignatures
- RoleAnnotations - RoleAnnotations
@ -60,3 +61,5 @@ tests:
- -with-rtsopts=-N - -with-rtsopts=-N
dependencies: dependencies:
- scalie - scalie
- tasty
- tasty-quickcheck

View file

@ -33,6 +33,7 @@ library
DerivingStrategies DerivingStrategies
ImportQualifiedPost ImportQualifiedPost
NoImplicitPrelude NoImplicitPrelude
OverloadedStrings
StandaloneKindSignatures StandaloneKindSignatures
RoleAnnotations RoleAnnotations
ghc-options: -Weverything -Wno-unsafe ghc-options: -Weverything -Wno-unsafe
@ -54,6 +55,7 @@ executable scalie-exe
DerivingStrategies DerivingStrategies
ImportQualifiedPost ImportQualifiedPost
NoImplicitPrelude NoImplicitPrelude
OverloadedStrings
StandaloneKindSignatures StandaloneKindSignatures
RoleAnnotations RoleAnnotations
ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N
@ -79,6 +81,7 @@ test-suite scalie-test
DerivingStrategies DerivingStrategies
ImportQualifiedPost ImportQualifiedPost
NoImplicitPrelude NoImplicitPrelude
OverloadedStrings
StandaloneKindSignatures StandaloneKindSignatures
RoleAnnotations RoleAnnotations
ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N ghc-options: -Weverything -Wno-unsafe -threaded -rtsopts -with-rtsopts=-N
@ -87,6 +90,8 @@ test-suite scalie-test
, base , base
, containers , containers
, scalie , scalie
, tasty
, tasty-quickcheck
, text , text
, vector , vector
default-language: Haskell2010 default-language: Haskell2010

View file

@ -1,9 +1,12 @@
{-# LANGUAGE Unsafe #-} -- unsafe: Uses functions imported from unsafe modules {-# LANGUAGE Unsafe #-} -- unsafe: Uses functions imported from unsafe modules
import System.IO (IO) import System.IO (IO)
import Control.Applicative (pure)
import Test.Data.Map.Implicit qualified import Test.Data.Map.Implicit qualified
import Test.Tasty qualified as Tasty
import Data.Function (($))
main :: IO () main :: IO ()
main = do main = Tasty.defaultMain $ Tasty.testGroup "all"
_ <- Test.Data.Map.Implicit.runTests [ Tasty.testGroup "Properties"
pure () [ Test.Data.Map.Implicit.testGroup
]
]

View file

@ -2,7 +2,7 @@
{-# LANGUAGE TemplateHaskell #-} -- for 'quickCheckAll' {-# LANGUAGE TemplateHaskell #-} -- for 'quickCheckAll'
{-# OPTIONS_GHC -Wno-all-missed-specialisations #-} -- a lot of warnings for unspecialized 'read' and 'show', which I cannot specialize {-# OPTIONS_GHC -Wno-all-missed-specialisations #-} -- a lot of warnings for unspecialized 'read' and 'show', which I cannot specialize
-- I wouldn't know how at least, they're not my datatypes, I cannot use the hint and add an 'INLINABLE' pragma -- I wouldn't know how at least, they're not my datatypes, I cannot use the hint and add an 'INLINABLE' pragma
module Test.Data.Map.Implicit (prop_readShowIdentityRoundtrip, prop_readShowMaybeRoundtrip, runTests) where module Test.Data.Map.Implicit (testGroup) where
import Test.QuickCheck.Roundtrip (roundtrips) import Test.QuickCheck.Roundtrip (roundtrips)
import Text.Show (show) import Text.Show (show)
import Text.Read (read) import Text.Read (read)
@ -10,10 +10,12 @@ import Data.Map.Implicit (ImplicitMap)
import Data.Bool (Bool) import Data.Bool (Bool)
import Language.Scalie.Ast.Definition (Definition) import Language.Scalie.Ast.Definition (Definition)
import Data.Functor.Identity (Identity) import Data.Functor.Identity (Identity)
import Test.QuickCheck.All (quickCheckAll) import Test.QuickCheck (Property, allProperties)
import System.IO (IO) import Data.String (String)
import Control.Applicative (pure) import Control.Applicative (pure)
import Data.Maybe (Maybe) import Data.Maybe (Maybe)
import Test.Tasty.QuickCheck qualified as Tasty.QuickCheck
import Test.Tasty (TestTree)
-- | This is testworthy since I have somehow hand-hacked the read/show de/serialization of 'ImplicitMap' -- | This is testworthy since I have somehow hand-hacked the read/show de/serialization of 'ImplicitMap'
@ -24,5 +26,8 @@ prop_readShowMaybeRoundtrip :: ImplicitMap (Definition Maybe) -> Bool
prop_readShowMaybeRoundtrip = roundtrips read show prop_readShowMaybeRoundtrip = roundtrips read show
pure [] pure []
runTests :: IO Bool allTests :: [(String, Property)]
runTests = $quickCheckAll allTests = $allProperties
testGroup :: TestTree
testGroup = Tasty.QuickCheck.testProperties "Data.Map.Implicit" allTests