Hello community,

here is the log from the commit of package ghc-cabal-doctest for 
openSUSE:Factory checked in at 2017-06-04 01:57:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-cabal-doctest (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-cabal-doctest.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-cabal-doctest"

Sun Jun  4 01:57:02 2017 rev:2 rq:499689 version:1.0.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-cabal-doctest/ghc-cabal-doctest.changes      
2017-02-11 01:42:59.529694740 +0100
+++ /work/SRC/openSUSE:Factory/.ghc-cabal-doctest.new/ghc-cabal-doctest.changes 
2017-06-04 01:57:03.823640475 +0200
@@ -1,0 +2,10 @@
+Mon May 22 08:08:53 UTC 2017 - [email protected]
+
+- Update to version 1.0.2 with cabal2obs.
+
+-------------------------------------------------------------------
+Thu May 18 09:52:24 UTC 2017 - [email protected]
+
+- Update to version 1.0.1 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  cabal-doctest-1.tar.gz

New:
----
  cabal-doctest-1.0.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-cabal-doctest.spec ++++++
--- /var/tmp/diff_new_pack.GcOSpl/_old  2017-06-04 01:57:04.311571542 +0200
+++ /var/tmp/diff_new_pack.GcOSpl/_new  2017-06-04 01:57:04.311571542 +0200
@@ -18,7 +18,7 @@
 
 %global pkg_name cabal-doctest
 Name:           ghc-%{pkg_name}
-Version:        1
+Version:        1.0.2
 Release:        0
 Summary:        A Setup.hs helper for doctests running
 License:        BSD-3-Clause

++++++ cabal-doctest-1.tar.gz -> cabal-doctest-1.0.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cabal-doctest-1/ChangeLog.md 
new/cabal-doctest-1.0.2/ChangeLog.md
--- old/cabal-doctest-1/ChangeLog.md    2017-01-31 18:30:27.000000000 +0100
+++ new/cabal-doctest-1.0.2/ChangeLog.md        2017-05-16 15:13:14.000000000 
+0200
@@ -1,3 +1,20 @@
+# 1.0.2 -- 2017-05-16
+
+* Add `defaultMainAutoconfWithDoctests` and `addDoctestsUserHook`.
+
+* Add support for `.hsc` and other preprocessed files
+  ([#8](https://github.com/phadej/cabal-doctest/issues/8))
+
+* Add support for `x-doctest-source-dirs` and `x-doctest-modules`.
+
+# 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.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cabal-doctest-1/README.md 
new/cabal-doctest-1.0.2/README.md
--- old/cabal-doctest-1/README.md       2017-01-31 18:30:27.000000000 +0100
+++ new/cabal-doctest-1.0.2/README.md   2017-05-16 15:13:14.000000000 +0200
@@ -1,12 +1,17 @@
 cabal-doctest
--------------
+=============
 
 
[![Hackage](https://img.shields.io/hackage/v/cabal-doctest.svg)](https://hackage.haskell.org/package/cabal-doctest)
 [![Build 
Status](https://travis-ci.org/phadej/cabal-doctest.svg?branch=master)](https://travis-ci.org/phadej/cabal-doctest)
 
 A `Setup.hs` helper for running `doctests`.
 
 Example Usage
-=============
+-------------
+
+See [https://github.com/phadej/cabal-doctest/tree/master/example] for an
+example package. (Note that the example requires `Cabal-1.24` or later, but
+you can relax this bound safely, although running doctests won't be supported
+on versions of `Cabal` older than 1.24.)
 
 To use this library in your `Setup.hs`, you should specify a `custom-setup`
 section in your `.cabal` file. For example:
@@ -15,9 +20,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 +47,7 @@
 
 import Build_doctests (flags, pkgs, module_sources)
 import Data.Foldable (traverse_)
-import Test.Doctest (doctest)
+import Test.DocTest (doctest)
 
 main :: IO ()
 main = do
@@ -48,8 +57,30 @@
     args = flags ++ pkgs ++ module_sources
 ```
 
+Additional configuration
+------------------------
+
+The `cabal-doctest` based `Setup.hs` supports few extensions fields
+in `pkg.cabal` files to customise the `doctest` runner behaviour, without
+customising the default `doctest.hs`.
+
+```
+test-suite doctests:
+  if impl(ghc >= 8.0)
+    x-doctest-options: -fdiagnostics-color=never
+  x-doctest-source-dirs: test
+  x-doctest-modules: Servant.Utils.LinksSpec
+
+  ...
+ ```
+
+* `x-doctest-options` Additional arguments passed into `doctest` command.
+* `x-doctest-modules` Additional modules to `doctest`. May be useful if you
+  have `doctest` in test or executables (i.e not default library complonent).
+* `x-doctest-src-dirs` Additional source directories to look for the modules.
+
 Notes
-=====
+-----
 
 * `custom-setup` section is supported starting from `cabal-install-1.24`.
   For older `cabal-install's` you have to install custom setup dependencies
@@ -59,12 +90,27 @@
   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`.
+
+* For `build-type: Configure` packages, you can use
+  `defaultMainAutoconfWithDoctests` function to make custom `Setup.hs` script.
+
+* If you use the default `.` in `hs-source-dirs`, then running `doctests`
+  might fail with weird errors (ambigious module errors). Workaround is
+  to move sources under `src/` or some non-top-level directory.
+
 Copyright
-=========
+---------
 
 Copyright 2017 Oleg Grenrus.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cabal-doctest-1/cabal-doctest.cabal 
new/cabal-doctest-1.0.2/cabal-doctest.cabal
--- old/cabal-doctest-1/cabal-doctest.cabal     2017-01-31 18:30:27.000000000 
+0100
+++ new/cabal-doctest-1.0.2/cabal-doctest.cabal 2017-05-16 15:13:14.000000000 
+0200
@@ -1,5 +1,5 @@
 name:                cabal-doctest
-version:             1
+version:             1.0.2
 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 <[email protected]>
@@ -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
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cabal-doctest-1/src/Distribution/Extra/Doctest.hs 
new/cabal-doctest-1.0.2/src/Distribution/Extra/Doctest.hs
--- old/cabal-doctest-1/src/Distribution/Extra/Doctest.hs       2017-01-31 
18:30:27.000000000 +0100
+++ new/cabal-doctest-1.0.2/src/Distribution/Extra/Doctest.hs   2017-05-16 
15:13:14.000000000 +0200
@@ -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,10 +29,12 @@
 -- @
 --
 -- /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,
+    defaultMainAutoconfWithDoctests,
+    addDoctestsUserHook,
     doctestsUserHooks,
     generateBuildModule,
     ) where
@@ -55,7 +57,7 @@
 import Distribution.PackageDescription
        (BuildInfo (..), Library (..), PackageDescription (), TestSuite (..))
 import Distribution.Simple
-       (UserHooks (..), defaultMainWithHooks, simpleUserHooks)
+       (UserHooks (..), autoconfUserHooks, defaultMainWithHooks, 
simpleUserHooks)
 import Distribution.Simple.BuildPaths
        (autogenModulesDir)
 import Distribution.Simple.Compiler
@@ -76,6 +78,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
@@ -107,14 +113,30 @@
     -> IO ()
 defaultMainWithDoctests = defaultMainWithHooks . doctestsUserHooks
 
+-- | Like 'defaultMainWithDoctests', for 'build-type: Configure' packages.
+--
+-- @since 1.0.2
+defaultMainAutoconfWithDoctests
+    :: String  -- ^ doctests test-suite name
+    -> IO ()
+defaultMainAutoconfWithDoctests n =
+    defaultMainWithHooks (addDoctestsUserHook n autoconfUserHooks)
+
 -- | 'simpleUserHooks' with 'generateBuildModule' prepended to the 'buildHook'.
 doctestsUserHooks
     :: String  -- ^ doctests test-suite name
     -> UserHooks
-doctestsUserHooks testsuiteName = simpleUserHooks
+doctestsUserHooks testsuiteName =
+    addDoctestsUserHook testsuiteName simpleUserHooks
+
+-- |
+--
+-- @since 1.0.2
+addDoctestsUserHook :: String -> UserHooks -> UserHooks
+addDoctestsUserHook testsuiteName uh = uh
     { buildHook = \pkg lbi hooks flags -> do
        generateBuildModule testsuiteName flags pkg lbi
-       buildHook simpleUserHooks pkg lbi hooks flags
+       buildHook uh pkg lbi hooks flags
     }
 
 -- | Generate a build module for the test suite.
@@ -159,8 +181,16 @@
 #endif
 
     -- Lib sources and includes
-    iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ libAutogenDir : 
hsSourceDirs libBI
+    iArgs' <- mapM (fmap ("-i"++) . makeAbsolute)
+        $ libAutogenDir            -- autogenerated files
+        : (distPref ++ "/build")   -- preprocessed files (.hsc -> .hs); 
"build" is hardcoded in Cabal.
+        : hsSourceDirs libBI
     includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
+    -- We clear all includes, so the CWD isn't used.
+    let iArgs = "-i" : iArgs'
+
+    -- default-extensions
+    let extensionArgs = map (("-X"++) . display) $ defaultExtensions libBI
 
     -- CPP includes, i.e. include cabal_macros.h
     let cppFlags = map ("-optP"++) $
@@ -168,6 +198,22 @@
             ++ 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
+
+      let additionalModules = maybe [] words
+            $ lookup "x-doctest-modules"
+            $ customFieldsBI testBI
+
+      let additionalDirs' = maybe [] words
+            $ lookup "x-doctest-source-dirs"
+            $ customFieldsBI testBI
+      additionalDirs <- mapM (fmap ("-i" ++) . makeAbsolute) additionalDirs'
+
 
       -- get and create autogen dir
 #if MIN_VERSION_Cabal(1,25,0)
@@ -186,10 +232,18 @@
         , "pkgs = " ++ (show $ formatDeps $ testDeps libcfg suitecfg)
         , ""
         , "flags :: [String]"
-        , "flags = " ++ show (iArgs ++ includeArgs ++ dbFlags ++ cppFlags)
+        , "flags = " ++ show (concat
+          [ iArgs
+          , additionalDirs
+          , includeArgs
+          , dbFlags
+          , cppFlags
+          , extensionArgs
+          , additionalFlags
+          ])
         , ""
         , "module_sources :: [String]"
-        , "module_sources = " ++ show (map display module_sources)
+        , "module_sources = " ++ show (map display module_sources ++ 
additionalModules)
         ]
   where
     -- we do this check in Setup, as then doctests don't need to depend on 
Cabal
@@ -202,7 +256,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 +302,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


Reply via email to