packages feed

doctest-parallel 0.2.3 → 0.2.4

raw patch · 5 files changed

+80/−21 lines, 5 filesdep ~Cabaldep ~ghcPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: Cabal, ghc

API changes (from Hackage documentation)

Files

CHANGES.markdown view
@@ -1,3 +1,6 @@+# 0.2.4+  * Add support for GHC 9.4 ([#43](https://github.com/martijnbastiaan/doctest-parallel/pull/43))+ # 0.2.3   * Conditionals in Cabal files are now solved ([#35](https://github.com/martijnbastiaan/doctest-parallel/pull/37)). Thanks to @philderbeast for the report and contributions.   * Unexpected outputs in `$setup` blocks are no longer ignored ([#39](https://github.com/martijnbastiaan/doctest-parallel/pull/39))
cabal.project view
@@ -2,3 +2,8 @@   ./  write-ghc-environment-files: always+++allow-newer:+    *:base+  , *:ghc-bignum
doctest-parallel.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.0  name:           doctest-parallel-version:        0.2.3+version:        0.2.4 synopsis:       Test interactive Haskell examples description:    The doctest program checks examples in source code comments.  It is modeled                 after doctest for Python (<https://docs.python.org/3/library/doctest.html>).@@ -24,6 +24,7 @@   , GHC == 8.10.7   , GHC == 9.0.1   , GHC == 9.2.1+  , GHC == 9.4.1 extra-source-files:     example/example.cabal     example/src/Example.hs@@ -87,7 +88,7 @@   other-modules:       Paths_doctest_parallel   build-depends:-      Cabal >= 3.4+      Cabal >= 3.4 && < 3.9     , Glob     , base >=4.10 && <5     , base-compat >=0.7.0@@ -98,7 +99,7 @@     , exceptions     , extra     , filepath-    , ghc >=8.2 && <9.3+    , ghc >=8.2 && <9.5     , ghc-paths >=0.1.0.9     , pretty     , process
src/Test/DocTest/Helpers.hs view
@@ -32,7 +32,6 @@   , packageDescription, condSubLibraries, includeDirs, autogenModules, ConfVar )  import Distribution.Compiler (CompilerFlavor(GHC))-import Distribution.PackageDescription.Parsec (readGenericPackageDescription) import Distribution.Pretty (prettyShow) import Distribution.System (buildArch, buildOS) import Distribution.Types.Condition (Condition(..))@@ -41,6 +40,12 @@ import Distribution.Types.Version (Version, mkVersion') import Distribution.Types.VersionRange (withinRange) import Distribution.Verbosity (silent)++#if MIN_VERSION_Cabal(3,8,0)+import Distribution.Simple.PackageDescription (readGenericPackageDescription)+#else+import Distribution.PackageDescription.Parsec (readGenericPackageDescription)+#endif  #if MIN_VERSION_Cabal(3,6,0) import Distribution.Utils.Path (SourceDir, PackageDir, SymbolicPath)
src/Test/DocTest/Internal/Extract.hs view
@@ -87,9 +87,9 @@       , ""       , "    " ++ msg       , ""-      , "This is most likely a bug in doctest."+      , "This is most likely a bug in doctest-parallel."       , ""-      , "Please report it here: https://github.com/sol/doctest/issues/new"+      , "Please report it here: https://github.com/martijnbastiaan/doctest-parallel/issues/new"       ]     where       msg = case fromException e of@@ -183,11 +183,7 @@       _ <- setSessionDynFlags (GHC.ms_hspp_opts modsum)       hsc_env <- getSession -# if __GLASGOW_HASKELL__ >= 903-      hsc_env' <- liftIO (initializePlugins hsc_env Nothing)-      setSession hsc_env'-      return $ modsum-# elif __GLASGOW_HASKELL__ >= 901+# if __GLASGOW_HASKELL__ >= 901       hsc_env' <- liftIO (initializePlugins hsc_env)       setSession hsc_env'       return $ modsum@@ -244,28 +240,44 @@ -- | Extract all docstrings from given module. docStringsFromModule :: ParsedModule -> [(Maybe String, Located String)] docStringsFromModule mod =+#if __GLASGOW_HASKELL__ < 904   map (fmap (toLocated . fmap unpackHDS)) docs+#else+  map (fmap (toLocated . fmap renderHsDocString)) docs+#endif  where-  source   = (unLoc . pm_parsed_source) mod+  source = (unLoc . pm_parsed_source) mod    -- we use dlist-style concatenation here-  docs     = header ++ exports ++ decls+  docs :: [(Maybe String, LHsDocString)]+  docs = header ++ exports ++ decls    -- We process header, exports and declarations separately instead of   -- traversing the whole source in a generic way, to ensure that we get   -- everything in source order.+  header :: [(Maybe String, LHsDocString)]+#if __GLASGOW_HASKELL__ < 904   header  = [(Nothing, x) | Just x <- [hsmodHaddockModHeader source]]+#else+  header = [(Nothing, hsDocString <$> x) | Just x <- [hsmodHaddockModHeader source]]+#endif++  exports :: [(Maybe String, LHsDocString)]   exports = [ (Nothing, L (locA loc) doc) #if __GLASGOW_HASKELL__ < 710             | L loc (IEDoc doc) <- concat (hsmodExports source) #elif __GLASGOW_HASKELL__ < 805             | L loc (IEDoc doc) <- maybe [] unLoc (hsmodExports source)-#else+#elif __GLASGOW_HASKELL__ < 904             | L loc (IEDoc _ doc) <- maybe [] unLoc (hsmodExports source)+#else+            | L loc (IEDoc _ (unLoc . fmap hsDocString -> doc)) <- maybe [] unLoc (hsmodExports source) #endif             ]-  decls   = extractDocStrings (hsmodDecls source) +  decls :: [(Maybe String, LHsDocString)]+  decls   = extractDocStrings (Right (hsmodDecls source))+ type Selector b a = a -> ([b], Bool)  type DocSelector a = Selector (Maybe String, LHsDocString) a@@ -275,6 +287,12 @@ select :: a -> ([a], Bool) select x = ([x], False) +#if __GLASGOW_HASKELL__ >= 904+-- | Don't collect any values+noSelect :: ([a], Bool)+noSelect = ([], False)+#endif+ -- | Extract module annotations from given value. extractModuleAnns :: Data a => a -> [Located String] extractModuleAnns = everythingBut (++) (([], False) `mkQ` fromLHsDecl)@@ -303,7 +321,11 @@   HsLit (HsString _ s) -> Just (toLocated (L loc (unpackFS s)))   _ -> Nothing #else+#if __GLASGOW_HASKELL__ < 904   HsPar _ (L l e) -> extractLit (locA l) e+#else+  HsPar _ _ (L l e) _ -> extractLit (locA l) e+#endif #if __GLASGOW_HASKELL__ < 807   ExprWithTySig _ (L l e) -> extractLit l e #else@@ -315,11 +337,18 @@ #endif  -- | Extract all docstrings from given value.-extractDocStrings :: Data a => a -> [(Maybe String, LHsDocString)]-extractDocStrings = everythingBut (++) (([], False) `mkQ` fromLHsDecl-  `extQ` fromLDocDecl-  `extQ` fromLHsDocString-  )+extractDocStrings :: Either (HsDecl GhcPs) [LHsDecl GhcPs] -> [(Maybe String, LHsDocString)]+extractDocStrings =+  everythingBut+    (++)+    (        ([], False)+      `mkQ`  fromLHsDecl+      `extQ` fromLDocDecl+      `extQ` fromLHsDocString+#if __GLASGOW_HASKELL__ >= 904+      `extQ` fromHsType+#endif+    )   where     fromLHsDecl :: DocSelector (LHsDecl GhcPs)     fromLHsDecl (L loc decl) = case decl of@@ -334,7 +363,7 @@ #endif            -> select (fromDocDecl (locA loc) x) -      _ -> (extractDocStrings decl, True)+      _ -> (extractDocStrings (Left decl), True)       fromLDocDecl :: DocSelector@@ -348,10 +377,26 @@     fromLHsDocString :: DocSelector LHsDocString     fromLHsDocString x = select (Nothing, x) +#if __GLASGOW_HASKELL__ >= 904+    fromHsType :: DocSelector (HsType GhcPs)+    fromHsType x = case x of+      HsDocTy _ _ (L loc hsDoc) -> select (Nothing, L loc (hsDocString hsDoc))+      _ -> noSelect+#endif++#if __GLASGOW_HASKELL__ < 904     fromDocDecl :: SrcSpan -> DocDecl -> (Maybe String, LHsDocString)+#else+    fromDocDecl :: SrcSpan -> DocDecl GhcPs -> (Maybe String, LHsDocString)+#endif     fromDocDecl loc x = case x of+#if __GLASGOW_HASKELL__ < 904       DocCommentNamed name doc -> (Just name, L loc doc)       _                        -> (Nothing, L loc $ docDeclDoc x)+#else+      DocCommentNamed name doc -> (Just name, hsDocString <$> doc)+      _                        -> (Nothing, L loc $ hsDocString $ unLoc $ docDeclDoc x)+#endif  #if __GLASGOW_HASKELL__ < 805 -- | Convert a docstring to a plain string.