Skip to content

Commit

Permalink
updated doctest to use exact dependencies. removed upper bounds, new …
Browse files Browse the repository at this point in the history
…build system, updated notification style
  • Loading branch information
ekmett committed Jan 6, 2013
1 parent 9555300 commit 5c4b6a2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 23 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
dist
TAGS
tags
docs
wiki
TAGS
tags
wip
.DS_Store
.*.swp
.*.swo
*.o
*.hi
*~
*#
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: haskell
# Use this when hackage is down.
# before_install:
# - mkdir -p ~/.cabal
# - cp config ~/.cabal/config
# - cabal update
notifications:
irc: "irc.freenode.org#haskell-lens"
irc:
channels:
- "irc.freenode.org#haskell-lens"
skip_join: true
template:
- "\x0313machines\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"
45 changes: 41 additions & 4 deletions Setup.lhs
Original file line number Diff line number Diff line change
@@ -1,7 +1,44 @@
#!/usr/bin/runhaskell
> module Main (main) where
\begin{code}
{-# OPTIONS_GHC -Wall #-}
module Main (main) where

> import Distribution.Simple
import Data.List ( nub )
import Data.Version ( showVersion )
import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
import Distribution.Simple.BuildPaths ( autogenModulesDir )
import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )
import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
import Distribution.Verbosity ( Verbosity )
import System.FilePath ( (</>) )

> main :: IO ()
> main = defaultMain
main :: IO ()
main = defaultMainWithHooks simpleUserHooks
{ buildHook = \pkg lbi hooks flags -> do
generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
buildHook simpleUserHooks pkg lbi hooks flags
}

generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
generateBuildModule verbosity pkg lbi = do
let dir = autogenModulesDir lbi
createDirectoryIfMissingVerbose verbosity True dir
withLibLBI pkg lbi $ \_ libcfg -> do
withTestLBI pkg lbi $ \suite suitecfg -> do
rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
[ "module Build_" ++ testName suite ++ " where"
, "deps :: [String]"
, "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
]
where
formatdeps = map (formatone . snd)
formatone p = case packageName p of
PackageName n -> n ++ "-" ++ showVersion (packageVersion p)

testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys

\end{code}
15 changes: 8 additions & 7 deletions machines.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: machines
category: Control, Enumerator
version: 0.2.1.3
version: 0.2.2
license: BSD3
cabal-version: >= 1.10
license-file: LICENSE
Expand All @@ -12,7 +12,7 @@ bug-reports: http://github.com/ekmett/machines/issues
copyright: Copyright (C) 2012 Edward A. Kmett
synopsis: Networked stream transducers
description: Networked stream transducers
build-type: Simple
build-type: Custom
tested-with: GHC == 7.4.1
extra-source-files:
.travis.yml
Expand All @@ -30,12 +30,12 @@ source-repository head
library
build-depends:
base == 4.*,
comonad == 3.0.*,
comonad >= 3,
containers >= 0.3 && < 0.6,
free >= 3.1.1 && < 3.4,
pointed == 3.0.*,
profunctors >= 3.0 && < 3.2,
semigroups >= 0.8.3 && < 0.9,
free >= 3.1.1,
pointed >= 3,
profunctors >= 3,
semigroups >= 0.8.3,
transformers == 0.3.*,
mtl >= 2.1.1 && < 2.2

Expand Down Expand Up @@ -67,6 +67,7 @@ library
test-suite doctests
type: exitcode-stdio-1.0
main-is: doctests.hs
default-language: Haskell2010
build-depends:
base == 4.*,
directory >= 1.0 && < 1.3,
Expand Down
10 changes: 6 additions & 4 deletions tests/doctests.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
module Main where

import Test.DocTest
import System.Directory
import System.FilePath
import Build_doctests (deps)
import Control.Applicative
import Control.Monad
import Data.List
import System.Directory
import System.FilePath
import Test.DocTest

main :: IO ()
main = getSources >>= \sources -> doctest $
"-isrc"
: "-idist/build/autogen"
: "-optP-include"
: "-optPdist/build/autogen/cabal_macros.h"
: sources
: "-hide-all-packages"
: map ("-package="++) deps ++ sources

getSources :: IO [FilePath]
getSources = filter (isSuffixOf ".hs") <$> go "src"
Expand Down

0 comments on commit 5c4b6a2

Please sign in to comment.