Skip to content

Commit 78e7657

Browse files
committed
Use cabal-doctest
1 parent 6e9c324 commit 78e7657

17 files changed

+64
-19
lines changed

Setup.hs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
1+
{-# LANGUAGE CPP #-}
2+
{-# OPTIONS_GHC -Wall #-}
13
module Main (main) where
24

5+
#ifndef MIN_VERSION_cabal_doctest
6+
#define MIN_VERSION_cabal_doctest(x,y,z) 0
7+
#endif
8+
9+
#if MIN_VERSION_cabal_doctest(1,0,0)
10+
11+
import Distribution.Extra.Doctest ( defaultMainAutoconfWithDoctests )
12+
main :: IO ()
13+
main = defaultMainAutoconfWithDoctests "doctests"
14+
#else
15+
16+
#ifdef MIN_VERSION_Cabal
17+
-- If the macro is defined, we have new cabal-install,
18+
-- but for some reason we don't have cabal-doctest in package-db
19+
--
20+
-- Probably we are running cabal sdist, when otherwise using new-build
21+
-- workflow
22+
import Warning ()
23+
#endif
24+
325
import Distribution.Simple
426

527
main :: IO ()
628
main = defaultMainWithHooks autoconfUserHooks
29+
30+
#endif

Warning.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Warning
2+
{-# WARNING ["You are configuring this package without cabal-doctest installed.",
3+
"The doctests test-suite will not work as a result.",
4+
"To fix this, install cabal-doctest before configuring."] #-}
5+
() where

cabal-doctest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 2634d8b5676182b9b83bfc83edba409845871dd9

network.cabal

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ description:
2626
That is, get the module from either network < 2.6 or from
2727
network-uri >= 2.6.
2828
category: Network
29-
build-type: Configure
29+
build-type: Custom
3030
cabal-version: >=1.8
3131
extra-tmp-files:
3232
config.log config.status autom4te.cache network.buildinfo
@@ -43,6 +43,12 @@ homepage: https://github.com/haskell/network
4343
bug-reports: https://github.com/haskell/network/issues
4444
tested-with: GHC == 7.0.4, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1, GHC == 7.10.2, GHC == 8.0.1
4545

46+
custom-setup
47+
setup-depends:
48+
base >= 4 && <5,
49+
Cabal,
50+
cabal-doctest >= 1.0.2 && <1.1
51+
4652
library
4753
exposed-modules:
4854
Network
@@ -75,6 +81,7 @@ library
7581
extensions:
7682
CPP, DeriveDataTypeable, ForeignFunctionInterface, TypeSynonymInstances
7783
include-dirs: include
84+
hs-source-dirs: src
7885
includes: HsNet.h
7986
install-includes: HsNet.h HsNetworkConfig.h
8087
c-sources: cbits/HsNet.c
@@ -108,11 +115,13 @@ test-suite regression
108115
-- Some of the bugs only occur in the threaded RTS
109116
ghc-options: -Wall -threaded
110117

111-
test-suite doctest
118+
test-suite doctests
112119
hs-source-dirs: tests
113120
main-is: doctests.hs
114121
type: exitcode-stdio-1.0
115122

123+
x-doctest-options: -fobject-code -DCALLCONV=ccall
124+
116125
build-depends:
117126
base < 5,
118127
doctest >= 0.10.1
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Network/Socket/Types.hsc renamed to src/Network/Socket/Types.hsc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DeriveDataTypeable #-}
23
{-# LANGUAGE FlexibleInstances #-}
34
{-# LANGUAGE ForeignFunctionInterface #-}

tests/doctests.hs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1+
-----------------------------------------------------------------------------
2+
-- |
3+
-- Module : Main (doctests)
4+
-- Copyright : (C) 2012-14 Edward Kmett
5+
-- License : BSD-style (see the file LICENSE)
6+
-- Maintainer : Edward Kmett <[email protected]>
7+
-- Stability : provisional
8+
-- Portability : portable
9+
--
10+
-- This module provides doctests for a project based on the actual versions
11+
-- of the packages it was built with. It requires a corresponding Setup.lhs
12+
-- to be added to the project
13+
-----------------------------------------------------------------------------
14+
module Main where
15+
16+
import Build_doctests (flags, pkgs, module_sources)
17+
import Data.Foldable (traverse_)
118
import Test.DocTest
219

320
main :: IO ()
4-
main = doctest [
5-
"-i"
6-
, "-idist/build"
7-
, "-i."
8-
, "-idist/build/autogen"
9-
, "-Idist/build/autogen"
10-
, "-Idist/build"
11-
, "-Iinclude"
12-
, "-optP-include"
13-
, "-optPdist/build/autogen/cabal_macros.h"
14-
, "-DCALLCONV=ccall"
15-
, "-XCPP"
16-
, "-XDeriveDataTypeable"
17-
, "-package-db dist/package.conf.inplace"
18-
, "-package network"
19-
, "Network"
20-
]
21+
main = do
22+
traverse_ putStrLn args
23+
doctest args
24+
where
25+
args = flags ++ pkgs ++ module_sources

0 commit comments

Comments
 (0)