diff --git a/templates/haskell/core/tests/doctests.hs b/templates/haskell/core/tests/doctests.hs index d5109bf..084b6ae 100644 --- a/templates/haskell/core/tests/doctests.hs +++ b/templates/haskell/core/tests/doctests.hs @@ -1,12 +1,28 @@ {-# LANGUAGE Unsafe #-} +-- | +-- Copyright: 2017-2020 Oleg Grenrus, 2020- Max Ulidtko +-- License: BSD-3-Clause +-- +-- Test-suite driver, adapted from +-- [cabal-doctest](https://hackage.haskell.org/package/cabal-doctest). module Main (main) where +import safe "base" Control.Category ((.)) +import safe "base" Data.Foldable (fold) import safe "base" Data.Function (($)) +import safe "base" Data.Functor (fmap) import safe "base" Data.Semigroup ((<>)) -import safe "base" System.IO (IO) +import safe "base" Data.Traversable (for) +import safe "base" System.IO (IO, print, putStrLn) import "doctest" Test.DocTest (doctest) -import "this" Build_doctests (flags, module_sources, pkgs) +import "this" Build_doctests (Component (Component), components) +-- | The doctest entry point. +-- +-- @since 0.0.1 main :: IO () -main = doctest $ flags <> pkgs <> module_sources +main = fmap fold . for components $ \(Component name flags pkgs sources) -> do + print name + putStrLn "----------------------------------------" + doctest $ flags <> pkgs <> sources diff --git a/templates/haskell/core/{{project.name}}.cabal b/templates/haskell/core/{{project.name}}.cabal index 84cf8fc..e5a78a9 100644 --- a/templates/haskell/core/{{project.name}}.cabal +++ b/templates/haskell/core/{{project.name}}.cabal @@ -238,6 +238,10 @@ test-suite doctests -- to ensure it gets built before this test-suite, even though the package -- appears to be unused. -Wno-unused-packages + -- NB: Adjust this to contain any components that may have doctests (including + -- executables). + x-doctest-components: + lib -- TODO: The sections below here are necessary because we don’t have control -- over the generated `Build_doctests.hs` file. So we have to silence -- all of its warnings one way or another.