Skip to content

Commit e42e922

Browse files
committed
Support for tasty-discover
1 parent a7dcda2 commit e42e922

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

components/hedgehog-test/Effectful/Zoo/Hedgehog/Test/PropertySpec.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
module Effectful.Zoo.Hedgehog.Test.PropertySpec where
44

5+
import Effectful.Zoo.Hedgehog
56
import Effectful.Zoo.Hedgehog.Effect.Run
67
import HaskellWorks.Prelude
7-
import Hedgehog hiding (property, forAll)
88
import Hedgehog qualified as H
99
import Hedgehog.Gen qualified as G
1010
import Hedgehog.Range qualified as R
1111

12-
property_spec :: H.PropertyT IO ()
13-
property_spec = property do
12+
tasty_property_spec :: PropertyT IO ()
13+
tasty_property_spec = property do
1414
a <- forAll $ G.int (R.linear 0 100)
1515
True === True
1616
a === a
1717
H.success
1818

19-
test_spec :: H.TestT IO ()
20-
test_spec = unit do
19+
tasty_unit_spec :: TestT IO ()
20+
tasty_unit_spec = unit do
2121
True === True
2222
True === True
2323
H.success

components/hedgehog-test/Main.hs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
1-
module Main where
2-
3-
import Effectful.Zoo.Hedgehog.Api.Tasty
4-
import Effectful.Zoo.Hedgehog.Test.PropertySpec
5-
import Test.Tasty (TestTree, defaultMain, testGroup)
6-
import HaskellWorks.Prelude
7-
8-
tests :: TestTree
9-
tests =
10-
testGroup "all"
11-
[ toTestTree "Simple property spec" property_spec
12-
, toTestTree "Simple test spec" test_spec
13-
]
14-
15-
main :: IO ()
16-
main =
17-
defaultMain tests
1+
{-# OPTIONS_GHC -F -pgmF tasty-discover #-}

components/hedgehog/Effectful/Zoo/Hedgehog/Api.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ import Effectful.Zoo.Hedgehog.Api.Assert
1313
import Effectful.Zoo.Hedgehog.Api.Failure
1414
import Effectful.Zoo.Hedgehog.Api.Hedgehog
1515
import Effectful.Zoo.Hedgehog.Api.Journal
16+
import Effectful.Zoo.Hedgehog.Api.Tasty.Orphans ()
1617
import Hedgehog
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{-# OPTIONS_GHC -fno-warn-orphans #-}
2+
3+
module Effectful.Zoo.Hedgehog.Api.Tasty.Orphans where
4+
5+
import Data.Monoid
6+
import HaskellWorks.Prelude
7+
import Hedgehog (PropertyT, TestT)
8+
import Hedgehog qualified as H
9+
import Test.Tasty.Discover
10+
import Test.Tasty.Discover.TastyInfo
11+
import Test.Tasty.Hedgehog
12+
13+
instance Tasty (PropertyT IO ()) where
14+
tasty info = pure . testProperty testName . H.property
15+
where testName = fromMaybe "" $ getLast info.name
16+
17+
instance Tasty (TestT IO ()) where
18+
tasty info = tasty info . H.test

effectful-zoo.cabal

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ common resourcet { build-depends: resourcet >=
5858
common resourcet-effectful { build-depends: resourcet-effectful >= 1.0.1 && < 2 }
5959
common stm { build-depends: stm >= 2.5.1 && < 3 }
6060
common tasty { build-depends: tasty >= 1.5 && < 2 }
61+
common tasty-discover { build-depends: tasty-discover >= 5 && < 6 }
6162
common tasty-hedgehog { build-depends: tasty-hedgehog >= 1.1.0.0 && < 1.5 }
6263
common temporary { build-depends: temporary >= 1.3 && < 2 }
6364
common testcontainers { build-depends: testcontainers >= 0.5 && < 0.6 }
@@ -300,6 +301,7 @@ library hedgehog
300301
lifted-base,
301302
resourcet,
302303
stm,
304+
tasty-discover,
303305
tasty-hedgehog,
304306
tasty,
305307
text,
@@ -327,6 +329,7 @@ library hedgehog
327329
Effectful.Zoo.Hedgehog.Api.Range
328330
Effectful.Zoo.Hedgehog.Api.Stack
329331
Effectful.Zoo.Hedgehog.Api.Tasty
332+
Effectful.Zoo.Hedgehog.Api.Tasty.Orphans
330333
Effectful.Zoo.Hedgehog.Api.Workspace
331334
Effectful.Zoo.Hedgehog.Data
332335
Effectful.Zoo.Hedgehog.Data.PackagePath
@@ -372,14 +375,16 @@ library testcontainers-localstack
372375
hs-source-dirs: components/testcontainers-localstack
373376

374377
test-suite effectful-zoo-test
375-
import: project-config,
378+
import: base, project-config,
376379
effectful-zoo-hedgehog,
377380
hedgehog,
378381
hw-prelude,
379382
tasty,
383+
tasty-discover,
380384
type: exitcode-stdio-1.0
381385
main-is: Main.hs
382386
other-modules: Effectful.Zoo.Hedgehog.Test.PropertySpec
387+
build-tool-depends: tasty-discover:tasty-discover
383388
hs-source-dirs: components/hedgehog-test
384389
ghc-options: -threaded
385390
-rtsopts

0 commit comments

Comments
 (0)