tasty-inspection-testing 0.2 → 0.2.1
raw patch · 5 files changed
+45/−36 lines, 5 filesdep ~basedep ~ghcdep ~inspection-testingPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, ghc, inspection-testing, tasty, template-haskell
API changes (from Hackage documentation)
Files
- README.md +3/−1
- changelog.md +4/−0
- src/Test/Tasty/Inspection.hs +6/−6
- src/Test/Tasty/Inspection/Plugin.hs +25/−22
- tasty-inspection-testing.cabal +7/−7
README.md view
@@ -29,4 +29,6 @@ * https://hackage.haskell.org/package/linear-base-0.2.0/src/test/Test/Data/V.hs * https://hackage.haskell.org/package/text-2.0/src/tests/Tests/Properties/LowLevel.hs * https://hackage.haskell.org/package/text-1.2.5.0/src/tests/Tests/Inspection/Strict.hs-* https://github.com/konn/sized/blob/676c2b81e55e708e7938acdf8c4d7db68db1c1cb/test/opt-test.hs+* https://hackage.haskell.org/package/sized-1.0.0.1/src/test/opt-test.hs+* https://hackage.haskell.org/package/vector-0.13.0.0/src/tests-inspect/Inspect/DerivingVia.hs+* https://hackage.haskell.org/package/infinite-list-0.1/src/test/Fusion.hs
changelog.md view
@@ -1,3 +1,7 @@+# 0.2.1++* Skip inspection tests if executed under ghci.+ # 0.2 * Support `inspection-testing-0.5`.
src/Test/Tasty/Inspection.hs view
@@ -7,9 +7,9 @@ -- Integrate @inspection-testing@ into @tasty@ test suites. -- -{-# LANGUAGE CPP #-}-{-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TemplateHaskellQuotes #-} module Test.Tasty.Inspection ( inspectTest@@ -74,7 +74,7 @@ -- > main :: IO () -- > main = defaultMain $(inspectTest $ 'lhs === 'rhs) ----- This is not the same function as 'Test.Inspection.inspectTest':+-- This is not the same function as @Test.Inspection.@'Test.Inspection.inspectTest': -- both return 'Q' 'Exp', but this one represents 'TestTree' -- instead of 'Test.Inspection.Result'. --@@ -83,7 +83,7 @@ -- -- > inspectTest (obl { testName = Just "foo" }) ----- To invert an obligation apply 'Test.Tasty.ExpectedFailure.expectFail'.+-- To invert an obligation apply @<https://hackage.haskell.org/package/tasty-expected-failure/docs/Test-Tasty-ExpectedFailure.html#v:expectFail Test.Tasty.ExpectedFailure.expectFail>@. -- inspectTest :: Obligation -> Q Exp inspectTest obl = do@@ -93,7 +93,7 @@ nameS <- genName name <- newUniqueName nameS annExpr <- liftData obl- addTopDecls $+ addTopDecls [ SigD name (ConT ''CheckResult) , ValD (VarP name) (NormalB (VarE 'didNotRunPluginError)) [] , PragmaD (InlineP name NoInline FunLike AllPhases)
src/Test/Tasty/Inspection/Plugin.hs view
@@ -4,11 +4,11 @@ -- Licence: MIT -- Maintainer: andrew.lelechenko@gmail.com ---{-# LANGUAGE CPP #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE MultiWayIf #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TupleSections #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE TemplateHaskellQuotes #-}+{-# LANGUAGE TupleSections #-} module Test.Tasty.Inspection.Plugin (plugin) where @@ -26,14 +26,16 @@ import GHC.Types.TyThing #endif -#if !MIN_VERSION_ghc(9,3,0)-import Control.Monad (when)-#endif- import Test.Inspection (Obligation(..)) import qualified Test.Inspection.Plugin as P (checkProperty, CheckResult(..)) import Test.Tasty.Inspection.Internal (CheckResult(..)) +#if MIN_VERSION_ghc(9,6,0)+import GHC.Driver.Backend (backendForcesOptimization0)+#elif MIN_VERSION_ghc(9,2,0)+import GHC.Driver.Backend (Backend(Interpreter))+#endif+ -- | The plugin for inspection testing. -- You normally do not need to touch it yourself, -- 'Test.Tasty.Inspection.inspectTest' will enable it automatically.@@ -79,7 +81,7 @@ fromTHName thn = thNameToGhcName thn >>= \case Nothing -> do errorMsg $ text "Could not resolve TH name" <+> text (show thn)- liftIO $ exitFailure -- kill the compiler. Is there a nicer way?+ liftIO exitFailure -- kill the compiler. Is there a nicer way? Just n -> pure n dcExpr :: TH.Name -> CoreM CoreExpr@@ -96,20 +98,21 @@ App <$> dcExpr 'ResSuccessWithMessage <*> mkStringExpr (showSDoc dflags sdoc) resultToExpr (P.ResFailure sdoc) = do dflags <- getDynFlags- App <$> dcExpr 'ResFailure <*> mkStringExpr (showSDoc dflags sdoc)+ if ghciDetected dflags+ then App <$> dcExpr 'ResSuccessWithMessage <*> mkStringExpr "Skipped because ghci forces -O0"+ else App <$> dcExpr 'ResFailure <*> mkStringExpr (showSDoc dflags sdoc) -proofPass :: ModGuts -> CoreM ModGuts-proofPass guts = do-#if !MIN_VERSION_ghc(9,3,0)- dflags <- getDynFlags- when (optLevel dflags < 1) $ warnMsg-#if MIN_VERSION_ghc(8,9,0)- NoReason-#endif- $ fsep $ map text- $ words "Test.Inspection: Compilation without -O detected. Expect optimizations to fail."+ghciDetected :: DynFlags -> Bool+#if MIN_VERSION_ghc(9,6,0)+ghciDetected = backendForcesOptimization0 . backend+#elif MIN_VERSION_ghc(9,2,0)+ghciDetected = (== Interpreter) . backend+#else+ghciDetected = (< 1) . optLevel #endif- uncurry (foldM checkObligation) (extractObligations guts)++proofPass :: ModGuts -> CoreM ModGuts+proofPass = uncurry (foldM checkObligation) . extractObligations partitionMaybe :: (a -> Maybe b) -> [a] -> ([a], [b]) partitionMaybe f = foldr go ([], [])
tasty-inspection-testing.cabal view
@@ -1,5 +1,5 @@ name: tasty-inspection-testing-version: 0.2+version: 0.2.1 cabal-version: 1.18 build-type: Simple license: MIT@@ -13,11 +13,11 @@ synopsis: Inspection testing support for tasty description: Integrate @inspection-testing@ into @tasty@ test suites. -extra-source-files:+extra-doc-files: changelog.md README.md -tested-with: GHC==9.2.2, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2+tested-with: GHC==9.8.1, GHC==9.6.4, GHC==9.4.8, GHC==9.2.8, GHC==9.0.2, GHC==8.10.7, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2 source-repository head type: git@@ -27,11 +27,11 @@ exposed-modules: Test.Tasty.Inspection Test.Tasty.Inspection.Plugin other-modules: Test.Tasty.Inspection.Internal- build-depends: base < 4.18,- ghc,+ build-depends: base < 4.21,+ ghc < 9.11, inspection-testing >= 0.5 && < 0.6,- tasty,- template-haskell+ tasty < 1.6,+ template-haskell < 2.23 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall -Wcompat