Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions templates/haskell/core/tests/doctests.hs
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions templates/haskell/core/{{project.name}}.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading