Skip to content
Closed
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ install:
fi
- travis_retry cabal update -v
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- cabal install cabal-doctest
- cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
- sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt

Expand Down
26 changes: 26 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -Wall #-}
module Main (main) where

#ifndef MIN_VERSION_cabal_doctest
#define MIN_VERSION_cabal_doctest(x,y,z) 0
#endif

#if MIN_VERSION_cabal_doctest(1,0,0)

import Distribution.Extra.Doctest ( defaultMainAutoconfWithDoctests )
main :: IO ()
main = defaultMainAutoconfWithDoctests "doctests"
#else

#ifdef MIN_VERSION_Cabal
-- If the macro is defined, we have new cabal-install,
-- but for some reason we don't have cabal-doctest in package-db
--
-- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
#warning You are configuring this package without cabal-doctest installed. \
The doctests test-suite will not work as a result. \
To fix this, install cabal-doctest before configuring.
#endif

import Distribution.Simple

main :: IO ()
main = defaultMainWithHooks autoconfUserHooks

#endif
22 changes: 18 additions & 4 deletions network.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ description:
That is, get the module from either network < 2.6 or from
network-uri >= 2.6.
category: Network
build-type: Configure
cabal-version: >=1.8
build-type: Custom
cabal-version: >=1.10
extra-tmp-files:
config.log config.status autom4te.cache network.buildinfo
include/HsNetworkConfig.h
Expand All @@ -43,7 +43,14 @@ homepage: https://github.com/haskell/network
bug-reports: https://github.com/haskell/network/issues
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

custom-setup
setup-depends:
base >= 4 && <5,
Cabal,
cabal-doctest >= 1.0.2 && <1.1

library
default-language: Haskell98
exposed-modules:
Network
Network.BSD
Expand Down Expand Up @@ -72,15 +79,17 @@ library
build-depends:
unix >= 2

extensions:
default-extensions:
CPP, DeriveDataTypeable, ForeignFunctionInterface, TypeSynonymInstances
include-dirs: include
hs-source-dirs: src
includes: HsNet.h
install-includes: HsNet.h HsNetworkConfig.h
c-sources: cbits/HsNet.c
ghc-options: -Wall -fwarn-tabs

test-suite simple
default-language: Haskell98
hs-source-dirs: tests
main-is: Simple.hs
type: exitcode-stdio-1.0
Expand All @@ -94,6 +103,7 @@ test-suite simple
test-framework-hunit

test-suite regression
default-language: Haskell98
hs-source-dirs: tests
main-is: Regression.hs
type: exitcode-stdio-1.0
Expand All @@ -108,13 +118,17 @@ test-suite regression
-- Some of the bugs only occur in the threaded RTS
ghc-options: -Wall -threaded

test-suite doctest
test-suite doctests
default-language: Haskell98
hs-source-dirs: tests
main-is: doctests.hs
type: exitcode-stdio-1.0

x-doctest-options: -fobject-code -DCALLCONV=ccall

build-depends:
base < 5,
network,
doctest >= 0.10.1

ghc-options: -Wall
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions Network/Socket.hsc → src/Network/Socket.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ import Network.Socket.Types

import Prelude -- Silence AMP warnings

-- $setup
--
-- It is not clear why we need to import the module.
-- doctests fails with "Not in scope" errors.
--
-- >>> import Network.Socket

-- | Either a host name e.g., @\"haskell.org\"@ or a numeric host
-- address string consisting of a dotted decimal IPv4 address or an
-- IPv6 address e.g., @\"192.168.0.1\"@.
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Network/Socket/Types.hsc → src/Network/Socket/Types.hsc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ForeignFunctionInterface #-}
Expand Down
4 changes: 3 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
resolver: lts-6.2
resolver: nightly-2017-04-01
packages:
- '.'
extra-deps:
- cabal-doctest-1.0.2
ghc-options:
"*": -DCALLCONV=ccall
nix:
Expand Down
39 changes: 22 additions & 17 deletions tests/doctests.hs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <[email protected]>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where

import Build_doctests (flags, pkgs, module_sources)
import Data.Foldable (traverse_)
import Test.DocTest

main :: IO ()
main = doctest [
"-i"
, "-idist/build"
, "-i."
, "-idist/build/autogen"
, "-Idist/build/autogen"
, "-Idist/build"
, "-Iinclude"
, "-optP-include"
, "-optPdist/build/autogen/cabal_macros.h"
, "-DCALLCONV=ccall"
, "-XCPP"
, "-XDeriveDataTypeable"
, "-package-db dist/package.conf.inplace"
, "-package network"
, "Network"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously we tested only Network module.

]
main = do
traverse_ putStrLn args
doctest args
where
args = flags ++ pkgs ++ module_sources