aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml84
-rw-r--r--haddock-api/haddock-api.cabal5
-rw-r--r--haddock-api/src/Haddock.hs25
-rw-r--r--haddock-library/haddock-library.cabal5
-rw-r--r--haddock-test/src/Test/Haddock/Config.hs17
-rw-r--r--haddock.cabal53
6 files changed, 136 insertions, 53 deletions
diff --git a/.travis.yml b/.travis.yml
index 405f8753..c1f8f504 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,26 +1,80 @@
+# This Travis job script has been generated by a script via
+#
+# make_travis_yml_2.hs 'haddock.cabal'
+#
+# For more information, see https://github.com/hvr/multi-ghc-travis
+#
+language: c
sudo: false
+git:
+ submodules: false # whether to recursively clone submodules
+
+cache:
+ directories:
+ - $HOME/.cabal/packages
+ - $HOME/.cabal/store
+
+before_cache:
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
+ # remove files that are regenerated by 'cabal update'
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
+
matrix:
include:
- - env: CABALVER=head GHCVER=head
- addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
+ - compiler: "ghc-8.2.1"
+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
+ - compiler: "ghc-head"
+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}
allow_failures:
- - env: CABALVER=head GHCVER=head
+ - compiler: "ghc-head"
before_install:
- - export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
+ - HC=${CC}
+ - unset CC
+ - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
+ - PKGNAME='haddock'
+
+install:
- cabal --version
- - cabal update
- - cd haddock-library
- - cabal install --only-dependencies --enable-tests
-# - cabal install doctest
- # --ghc-options=-Werror
- - cabal configure --enable-tests && cabal build && cabal test
-# - doctest -isrc -i$(echo vendor/attoparsec-*) -optP-include -optPdist/build/autogen/cabal_macros.h src/Documentation/Haddock/Parser.hs
- - cabal install
- - cd ..
- - (cd haddock-api/ && cabal install --only-dependencies --enable-tests && cabal configure --enable-tests && cabal build && cabal test && cabal install)
+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
+ - BENCH=${BENCH---enable-benchmarks}
+ - TEST=${TEST---enable-tests}
+ - travis_retry cabal update -v
+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
+ - rm -fv cabal.project.local
+ - rm -f cabal.project.freeze
+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
+# Here starts the actual work to be performed for the package under test;
+# any command which exits with a non-zero exit code causes the build to fail.
script:
- - cabal configure --enable-tests && cabal build && cabal test
+ - if [ -f configure.ac ]; then autoreconf -i; fi
+ - rm -rf dist/
+ - cabal sdist # test that a source-distribution can be generated
+ - cd dist/
+ - SRCTAR=(${PKGNAME}-*.tar.gz)
+ - SRC_BASENAME="${SRCTAR/%.tar.gz}"
+ - tar -xvf "./$SRC_BASENAME.tar.gz"
+ - cd "$SRC_BASENAME/"
+## from here on, CWD is inside the extracted source-tarball
+ - rm -fv cabal.project.local
+ # this builds all libraries and executables (without tests/benchmarks)
+ - rm -f cabal.project.freeze
+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
+ # this builds all libraries and executables (including tests/benchmarks)
+ # - rm -rf ./dist-newstyle
+
+ # build & run tests
+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
+
+# EOF
diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal
index f98a8202..921e16eb 100644
--- a/haddock-api/haddock-api.cabal
+++ b/haddock-api/haddock-api.cabal
@@ -12,7 +12,7 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
-cabal-version: >= 1.10
+cabal-version: >= 2.0
stability: experimental
data-dir:
@@ -120,6 +120,9 @@ test-suite spec
, hspec
, QuickCheck == 2.*
+ build-tool-depends:
+ hspec-discover:hspec-discover
+
source-repository head
type: git
location: https://github.com/haskell/haddock.git
diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs
index 6af0874a..dec85b79 100644
--- a/haddock-api/src/Haddock.hs
+++ b/haddock-api/src/Haddock.hs
@@ -426,15 +426,22 @@ getHaddockLibDir flags =
#ifdef IN_GHC_TREE
getInTreeDir
#else
- d <- getDataDir -- provided by Cabal
- doesDirectoryExist d >>= \exists -> case exists of
- True -> return d
- False -> do
- -- If directory does not exist then we are probably invoking from
- -- ./dist/build/haddock/haddock so we use ./resources as a fallback.
- doesDirectoryExist "resources" >>= \exists_ -> case exists_ of
- True -> return "resources"
- False -> die ("Haddock's resource directory (" ++ d ++ ") does not exist!\n")
+ -- if data directory does not exist we are probably
+ -- invoking from either ./haddock-api or ./
+ let res_dirs = [ getDataDir -- provided by Cabal
+ , pure "resources"
+ , pure "haddock-api/resources"
+ ]
+
+ check get_path = do
+ p <- get_path
+ exists <- doesDirectoryExist p
+ pure $ if exists then Just p else Nothing
+
+ dirs <- mapM check res_dirs
+ case [p | Just p <- dirs] of
+ (p : _) -> return p
+ _ -> die "Haddock's resource directory does not exist!\n"
#endif
fs -> return (last fs)
diff --git a/haddock-library/haddock-library.cabal b/haddock-library/haddock-library.cabal
index 463569a3..b7a20758 100644
--- a/haddock-library/haddock-library.cabal
+++ b/haddock-library/haddock-library.cabal
@@ -14,7 +14,7 @@ homepage: http://www.haskell.org/haddock/
bug-reports: https://github.com/haskell/haddock/issues
category: Documentation
build-type: Simple
-cabal-version: >= 1.10
+cabal-version: >= 2.0
stability: experimental
library
@@ -78,6 +78,9 @@ test-suite spec
, hspec
, QuickCheck == 2.*
+ build-tool-depends:
+ hspec-discover:hspec-discover
+
source-repository head
type: git
subdir: haddock-library
diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs
index e1e920f2..50616c7f 100644
--- a/haddock-test/src/Test/Haddock/Config.hs
+++ b/haddock-test/src/Test/Haddock/Config.hs
@@ -165,11 +165,18 @@ loadConfig ccfg dcfg flags files = do
cfgEnv <- (:) ("haddock_datadir", dcfgResDir dcfg) <$> getEnvironment
systemHaddockPath <- List.lookup "HADDOCK_PATH" <$> getEnvironment
- cfgHaddockPath <- case flagsHaddockPath flags <|> systemHaddockPath of
+ haddockOnPath <- findExecutable "haddock"
+
+ let haddock_path = msum [ flagsHaddockPath flags
+ , systemHaddockPath
+ , haddockOnPath
+ ]
+
+ cfgHaddockPath <- case haddock_path of
Just path -> pure path
- Nothing -> do
- hPutStrLn stderr $ "Haddock executable not specified"
- exitFailure
+ Nothing -> do
+ hPutStrLn stderr "Haddock executable not found"
+ exitFailure
ghcPath <- init <$> rawSystemStdout normal cfgHaddockPath
["--print-ghc-path"]
@@ -195,7 +202,7 @@ loadConfig ccfg dcfg flags files = do
let cfgAccept = FlagAccept `elem` flags
let cfgCheckConfig = ccfg
- let cfgDirConfig = dcfg
+ let cfgDirConfig = dcfg
return $ Config { .. }
diff --git a/haddock.cabal b/haddock.cabal
index a79f8c78..fa8a3531 100644
--- a/haddock.cabal
+++ b/haddock.cabal
@@ -12,9 +12,10 @@ bug-reports: https://github.com/haskell/haddock/issues
copyright: (c) Simon Marlow, David Waern
category: Documentation
build-type: Simple
-cabal-version: >= 1.10
+cabal-version: >= 2.0
stability: experimental
-
+tested-with: GHC==8.2.*, GHC==8.3
+
extra-source-files:
CHANGES
README.md
@@ -130,32 +131,40 @@ test-suite driver-test
test-suite html-test
type: exitcode-stdio-1.0
- default-language: Haskell2010
- main-is: Main.hs
- hs-source-dirs: html-test
- build-depends: base, filepath, haddock-test == 0.0.1
+ -- This tells cabal that this test depends on the executable
+ -- component 'haddock' from this very same package, as well
+ -- as adding the build-folder where the `haddock`
+ -- executable can be found in front of $PATH
+ build-tool-depends: haddock:haddock
+ default-language: Haskell2010
+ main-is: Main.hs
+ hs-source-dirs: html-test
+ build-depends: base, filepath, haddock-test == 0.0.1
test-suite hypsrc-test
- type: exitcode-stdio-1.0
- default-language: Haskell2010
- main-is: Main.hs
- hs-source-dirs: hypsrc-test
- build-depends: base, filepath, haddock-test == 0.0.1
- ghc-options: -Wall -fwarn-tabs
+ type: exitcode-stdio-1.0
+ build-tool-depends: haddock:haddock
+ default-language: Haskell2010
+ main-is: Main.hs
+ hs-source-dirs: hypsrc-test
+ build-depends: base, filepath, haddock-test == 0.0.1
+ ghc-options: -Wall -fwarn-tabs
test-suite latex-test
- type: exitcode-stdio-1.0
- default-language: Haskell2010
- main-is: Main.hs
- hs-source-dirs: latex-test
- build-depends: base, filepath, haddock-test == 0.0.1
+ type: exitcode-stdio-1.0
+ build-tool-depends: haddock:haddock
+ default-language: Haskell2010
+ main-is: Main.hs
+ hs-source-dirs: latex-test
+ build-depends: base, filepath, haddock-test == 0.0.1
test-suite hoogle-test
- type: exitcode-stdio-1.0
- default-language: Haskell2010
- main-is: Main.hs
- hs-source-dirs: hoogle-test
- build-depends: base, filepath, haddock-test == 0.0.1
+ type: exitcode-stdio-1.0
+ build-tool-depends: haddock:haddock
+ default-language: Haskell2010
+ main-is: Main.hs
+ hs-source-dirs: hoogle-test
+ build-depends: base, filepath, haddock-test == 0.0.1
source-repository head
type: git