packages feed

cabal-doctest 1 → 1.0.1

raw patch · 4 files changed

+65/−12 lines, 4 filesdep ~CabalPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: Cabal

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,3 +1,11 @@+# 1.0.1 -- 2017-05-05++* Add support for `x-doctest-options` cabal-file field++* Proper support for GHC-8.2.1 & Cabal-2.0.0.0++* Add support to `default-extensions` in library.+ # 1  -- 2017-01-31  * First version. Released on an unsuspecting world.
README.md view
@@ -8,6 +8,8 @@ Example Usage ============= +See [https://github.com/phadej/cabal-doctest/tree/master/example] for an example package.+ To use this library in your `Setup.hs`, you should specify a `custom-setup` section in your `.cabal` file. For example: @@ -15,9 +17,13 @@ custom-setup  setup-depends:    base >= 4 && <5,+   Cabal,    cabal-doctest >= 1 && <1.1 ``` +/Note:/ `Cabal` dependency is needed because of+[Cabal/GH-4288](https://github.com/haskell/cabal/issues/4288) bug.+ You'll also need to specify `build-type: Custom` at the top of the `.cabal` file. Now put this into your `Setup.hs` file: @@ -38,7 +44,7 @@  import Build_doctests (flags, pkgs, module_sources) import Data.Foldable (traverse_)-import Test.Doctest (doctest)+import Test.DocTest (doctest)  main :: IO () main = do@@ -59,9 +65,17 @@   you have to use `explicit-setup-deps` setting in your `stack.yaml`.   ([stack/GH-2094](https://github.com/commercialhaskell/stack/issues/2094)) -* There is [an issue in the Cabal issue tracker](https://github.com/haskell/cabal/issues/2327 Cabal/2327)+* There is [an issue in the Cabal issue tracker](https://github.com/haskell/cabal/issues/2327)   about adding `cabal doctest` command. After that command is implemented,   this library will be deprecated.++* If your library contains `cbits`, you might need to depend on the library+  itself in `doctests` test-suite. We aren't sure whether this a bug or not.+  See [#5 issue](https://github.com/phadej/cabal-doctest/issues/5) for longer+  explanation.++* You can use `x-doctest-options` field in `test-suite doctests` to+  pass additional flags to the `doctest`.  Copyright =========
cabal-doctest.cabal view
@@ -1,5 +1,5 @@ name:                cabal-doctest-version:             1+version:             1.0.1 synopsis:            A Setup.hs helper for doctests running description:   Currently (beginning of 2017), there isn't @cabal doctest@@@ -9,7 +9,7 @@   See <https://github.com/haskell/cabal/issues/2327 Cabal/2327> for the progress   of @cabal doctest@, i.e. whether this library is obsolete. -homepage:            https://github.com/phadej/cabal-doctests+homepage:            https://github.com/phadej/cabal-doctest license:             BSD3 license-file:        LICENSE author:              Oleg Grenrus <oleg.grenrus@iki.fi>@@ -27,7 +27,7 @@   GHC==7.8.4,   GHC==7.10.3,   GHC==8.0.2,-  GHC==8.1.*+  GHC==8.2.1  source-repository head   type:     git
src/Distribution/Extra/Doctest.hs view
@@ -5,11 +5,11 @@ -- -- @ -- module Main where--- +-- -- import Build_doctests (flags, pkgs, module_sources) -- import Data.Foldable (traverse_) -- import Test.Doctest (doctest)--- +-- -- main :: IO () -- main = do --     traverse_ putStrLn args -- optionally print arguments@@ -18,7 +18,7 @@ --     args = flags ++ pkgs ++ module_sources -- @ ----- To use this library in the @Setup.hs@, you should specify a @custom-setup@ +-- To use this library in the @Setup.hs@, you should specify a @custom-setup@ -- section in the cabal file, for example: -- -- @@@ -29,7 +29,7 @@ -- @ -- -- /Note:/ you don't need to depend on @Cabal@  if you use only--- 'defaultMainWithDoctests' in the @Setup.hs".+-- 'defaultMainWithDoctests' in the @Setup.hs@. -- module Distribution.Extra.Doctest (     defaultMainWithDoctests,@@ -76,6 +76,10 @@ import Distribution.Simple.BuildPaths        (autogenComponentModulesDir) #endif+#if MIN_VERSION_Cabal(2,0,0)+import Distribution.Types.MungedPackageId+       (MungedPackageId)+#endif  #if MIN_VERSION_directory(1,2,2) import System.Directory@@ -162,12 +166,20 @@     iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ libAutogenDir : hsSourceDirs libBI     includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI +    -- default-extensions+    let extensionArgs = map (("-X"++) . display) $ defaultExtensions libBI+     -- CPP includes, i.e. include cabal_macros.h     let cppFlags = map ("-optP"++) $             [ "-include", libAutogenDir ++ "/cabal_macros.h" ]             ++ cppOptions libBI      withTestLBI pkg lbi $ \suite suitecfg -> when (testName suite == fromString testSuiteName) $ do+      let testBI = testBuildInfo suite+      -- TODO: `words` is not proper parser (no support for quotes)+      let additionalFlags = maybe [] words+            $ lookup "x-doctest-options"+            $ customFieldsBI testBI        -- get and create autogen dir #if MIN_VERSION_Cabal(1,25,0)@@ -186,7 +198,14 @@         , "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)         , ""         , "flags :: [String]"-        , "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)+        , "flags = " ++ show (concat+          [ iArgs+          , includeArgs+          , dbFlags+          , cppFlags+          , extensionArgs+          , additionalFlags+          ])         , ""         , "module_sources :: [String]"         , "module_sources = " ++ show (map display module_sources)@@ -202,7 +221,13 @@     formatOne (installedPkgId, pkgId)       -- The problem is how different cabal executables handle package databases       -- when doctests depend on the library-      | packageId pkg == pkgId = "-package=" ++ display pkgId+      --+      -- If the pkgId is current package, we don't output the full package-id+      -- but only the name+      --+      -- Because of MungedPackageId we compare display version of identifiers+      -- not the identifiers themfselves.+      | display (packageId pkg) == display pkgId = "-package=" ++ display pkgId       | otherwise              = "-package-id=" ++ display installedPkgId      -- From Distribution.Simple.Program.GHC@@ -242,5 +267,11 @@        isSpecific (SpecificPackageDB _) = True        isSpecific _                     = False -testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]+-- | In compat settings it's better to omit the type-signature+testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo+#if MIN_VERSION_Cabal(2,0,0)+         -> [(InstalledPackageId, MungedPackageId)]+#else+         -> [(InstalledPackageId, PackageId)]+#endif testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys