Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid testProperty deprecation warnings with tasty-hedgehog-1.2 #198

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion what4/test/ExprBuilderSMTLib2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ProbeSolvers
import Test.Tasty
import Test.Tasty.Checklist as TC
import Test.Tasty.ExpectedFailure
import Test.Tasty.Hedgehog
import Test.Tasty.Hedgehog.Alt
import Test.Tasty.HUnit

import Control.Exception (bracket, try, finally, SomeException)
Expand Down
2 changes: 1 addition & 1 deletion what4/test/ExprsTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.Hedgehog
import Test.Tasty.Hedgehog.Alt
import What4.Concrete
import What4.Expr
import What4.Interface
Expand Down
2 changes: 1 addition & 1 deletion what4/test/HH/VerifyBindings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Test.Tasty
import Test.Tasty.Hedgehog
import Test.Tasty.Hedgehog.Alt
import qualified Test.Verification as V


Expand Down
2 changes: 1 addition & 1 deletion what4/test/IteExprs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Hedgehog
import qualified Hedgehog.Internal.Gen as IGen
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.Hedgehog
import Test.Tasty.Hedgehog.Alt
import What4.Concrete
import What4.Expr
import What4.Interface
Expand Down
29 changes: 29 additions & 0 deletions what4/test/hedgehog/Test/Tasty/Hedgehog/Alt.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- | Like "Test.Tasty.Hedgehog", but instead exposing an alternative
-- implementation of 'testProperty' that does not induce deprecation warnings.
module Test.Tasty.Hedgehog.Alt
( module TTH
, testProperty
) where

import Data.String (IsString(fromString))
import Hedgehog (Property)
import Test.Tasty (TestName, TestTree)
import Test.Tasty.Hedgehog as TTH hiding (testProperty)

-- | Create a 'T.TestTree' from a Hedgehog 'Property'.
--
-- Note that @tasty-hedgehog@'s version of 'testProperty' has been deprecated
-- in favor of 'testPropertyNamed', whose second argument is intended to
-- represent the name of a top-level 'Property' value to run in the event that
-- the test fails. See https://github.com/qfpl/tasty-hedgehog/pull/42.
--
-- That being said, @what4@ currently does not define any of the properties
-- that it tests as top-level values, and it would be a pretty significant
-- undertaking to migrate all of the properties to top-level values. In the
-- meantime, we avoid incurring deprecation warnings by defining our own
-- version of 'testProperty'. The downside to this workaround is that if a
-- property fails, the error message it will produce will likely suggest
-- running ill-formed Haskell code, so users will have to use context clues to
-- determine how to /actually/ reproduce the error.
testProperty :: TestName -> Property -> TestTree
testProperty name = testPropertyNamed name (fromString name)
4 changes: 3 additions & 1 deletion what4/what4.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ common testdefs-quickcheck

common testdefs-hedgehog
import: testdefs
hs-source-dirs: test/hedgehog
build-depends: hedgehog >= 1.0.2
, tasty-hedgehog
, tasty-hedgehog >= 1.2
other-modules: Test.Tasty.Hedgehog.Alt

common testdefs-hunit
import: testdefs
Expand Down