cabal-doctest 1.0.11 → 1.0.12
raw patch · 4 files changed
+37/−16 lines, 4 filesdep ~CabalPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
+ Distribution.Extra.Doctest: type TestSuiteName = String
- Distribution.Extra.Doctest: addDoctestsUserHook :: String -> UserHooks -> UserHooks
+ Distribution.Extra.Doctest: addDoctestsUserHook :: TestSuiteName -> UserHooks -> UserHooks
- Distribution.Extra.Doctest: defaultMainAutoconfWithDoctests :: String -> IO ()
+ Distribution.Extra.Doctest: defaultMainAutoconfWithDoctests :: TestSuiteName -> IO ()
- Distribution.Extra.Doctest: defaultMainWithDoctests :: String -> IO ()
+ Distribution.Extra.Doctest: defaultMainWithDoctests :: TestSuiteName -> IO ()
- Distribution.Extra.Doctest: doctestsUserHooks :: String -> UserHooks
+ Distribution.Extra.Doctest: doctestsUserHooks :: TestSuiteName -> UserHooks
- Distribution.Extra.Doctest: generateBuildModule :: String -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
+ Distribution.Extra.Doctest: generateBuildModule :: TestSuiteName -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
Files
- README.md +6/−4
- cabal-doctest.cabal +4/−4
- changelog.md +8/−0
- src/Distribution/Extra/Doctest.hs +19/−8
README.md view
@@ -86,10 +86,12 @@ main = defaultMainWithDoctests "doctests" ``` - Assuming your test-suite is called `doctests`, this `Setup` will generate a `Build_doctests`- module during package build. If your test-suite goes by name `foo`,- `defaultMainWithDoctests "foo"` creates a `Build_foo` module.+ This `Setup` will generate a `Build_doctests` module during package build. + Note that the module name `Build_doctests` is a fixed constant, and it is+ not related to the `"doctests"` argument. That argument identifies which+ `test-suite` (among those defined in your .cabal file) will run the doctest.+ 4. Use the generated module in a testsuite, simply like so: ```haskell@@ -152,7 +154,7 @@ ``` There is also a more explicit approach: if you have an executable named `foo`, then-`Build_doctest` will contain `flags_exe_foo`, `pkgs_exe_foo`, and `module_sources_exe_foo`.+`Build_doctests` will contain `flags_exe_foo`, `pkgs_exe_foo`, and `module_sources_exe_foo`. If the name has hyphens in it (e.g., `my-exe`), `cabal-doctest` will convert them to underscores (e.g., you'd get `flags_my_exe`, `pkgs_my_exe`, `module_sources_my_exe`). Internal library `bar` values will have a `_lib_bar` suffix.
cabal-doctest.cabal view
@@ -1,5 +1,5 @@ name: cabal-doctest-version: 1.0.11+version: 1.0.12 -- x-revision: 0 synopsis: A Setup.hs helper for running doctests description:@@ -21,9 +21,9 @@ README.md tested-with:- GHC == 9.10.1- GHC == 9.8.2- GHC == 9.6.5+ GHC == 9.10.3+ GHC == 9.8.4+ GHC == 9.6.7 GHC == 9.4.8 GHC == 9.2.8 GHC == 9.0.2
changelog.md view
@@ -1,3 +1,11 @@+# 1.0.12 -- 2025-11-19++* Fix documentation mistake regarding `Build_doctests` module name. [cabal-doctest#90][]+* Clarify function signatures through a meaningful alias onto `String`.+* Refresh CI & `tested-with` GHC versions.++[cabal-doctest#90]: https://github.com/ulidtko/cabal-doctest/issues/90+ # 1.0.11 -- 2024-11-22 * Support Cabal 3.14.0.0. [cabal-doctest#85][].
src/Distribution/Extra/Doctest.hs view
@@ -8,8 +8,7 @@ -- | See cabal-doctest README for full-fledged recipes & caveats. ----- The provided 'generateBuildModule' generates a @Build_{suffix}@ module, with--- caller-chosen @suffix@ that is usually @"doctests"@ -- module @Build_doctests@.+-- The provided 'generateBuildModule' generates a module named @Build_doctests@. -- -- That module exports just enough compiler flags, so that doctest could be simply --@@ -42,6 +41,7 @@ -- from @setup-depends@: 'defaultMainWithDoctests' and 'defaultMainAutoconfWithDoctests'. -- module Distribution.Extra.Doctest (+ TestSuiteName, defaultMainWithDoctests, defaultMainAutoconfWithDoctests, addDoctestsUserHook,@@ -221,6 +221,10 @@ -- Mains ------------------------------------------------------------------------------- +-- | This type is a 'String' which identifies a test-suite in your cabal-file;+-- the one you'll be running doctest from.+type TestSuiteName = String+ -- | A default @Setup.hs@ main with doctests: -- -- @@@ -230,8 +234,15 @@ -- main :: IO () -- main = defaultMainWithDoctests "doctests" -- @+--+-- The argument @"doctests"@ identifies a test-suite in your cabal-file; the+-- one you'll run doctest from. If you have @test-suite my-test@, you should+-- invoke @defaultMainWithDoctests "my-test"@ in Setup.hs.+--+-- This argument does not change the generated module name imported from the+-- test-driver's @Main@ -- that one always remains @import Build_doctests@. defaultMainWithDoctests- :: String -- ^ doctests test-suite name+ :: TestSuiteName -> IO () defaultMainWithDoctests = defaultMainWithHooks . doctestsUserHooks @@ -239,14 +250,14 @@ -- -- @since 1.0.2 defaultMainAutoconfWithDoctests- :: String -- ^ doctests test-suite name+ :: TestSuiteName -> IO () defaultMainAutoconfWithDoctests n = defaultMainWithHooks (addDoctestsUserHook n autoconfUserHooks) -- | 'simpleUserHooks' with 'generateBuildModule' already wired-in. doctestsUserHooks- :: String -- ^ doctests test-suite name+ :: TestSuiteName -> UserHooks doctestsUserHooks testsuiteName = addDoctestsUserHook testsuiteName simpleUserHooks@@ -256,7 +267,7 @@ -- This is exported for advanced custom Setup-s. -- -- @since 1.0.2-addDoctestsUserHook :: String -> UserHooks -> UserHooks+addDoctestsUserHook :: TestSuiteName -> UserHooks -> UserHooks addDoctestsUserHook testsuiteName uh = uh { buildHook = \pkg lbi hooks flags -> do generateBuildModule testsuiteName flags pkg lbi@@ -319,7 +330,7 @@ -- } -- @ generateBuildModule- :: String -- ^ doctests test-suite name+ :: TestSuiteName -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () generateBuildModule testSuiteName flags pkg lbi = do let verbosity = fromFlag (buildVerbosity flags)@@ -598,7 +609,7 @@ testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys amendGPD- :: String -- ^ doctests test-suite name+ :: TestSuiteName -> GenericPackageDescription -> GenericPackageDescription #if !(MIN_VERSION_Cabal(2,0,0))