From e3568da479b6297e48b8b83ee067174717fdbe22 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 14 Mar 2017 14:23:35 -0700 Subject: Fix haddock-test to work with latest version of Cabal. Signed-off-by: Edward Z. Yang (cherry picked from commit bf3c4d72a0fda38561376eac7eda216158783267) --- haddock-test/src/Test/Haddock/Config.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haddock-test') diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs index dea101d8..e1e920f2 100644 --- a/haddock-test/src/Test/Haddock/Config.hs +++ b/haddock-test/src/Test/Haddock/Config.hs @@ -237,7 +237,7 @@ baseDependencies ghcPath = do exitFailure (ifArg:_) -> pure ifArg ifaces pkgIndex name = do - pkg <- join $ snd <$> lookupPackageName pkgIndex (PackageName name) + pkg <- join $ snd <$> lookupPackageName pkgIndex (mkPackageName name) iface <$> haddockInterfaces pkg <*> haddockHTMLs pkg iface file html = "--read-interface=" ++ html ++ "," ++ file -- cgit v1.2.3 From 02a633476f68c9a8efe579abfd4745a08d145f89 Mon Sep 17 00:00:00 2001 From: alexbiehl Date: Tue, 11 Apr 2017 19:35:58 +0200 Subject: Allow base-4.10 for haddock-test --- haddock-test/haddock-test.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haddock-test') diff --git a/haddock-test/haddock-test.cabal b/haddock-test/haddock-test.cabal index 7cb15d7d..ef928e78 100644 --- a/haddock-test/haddock-test.cabal +++ b/haddock-test/haddock-test.cabal @@ -16,7 +16,7 @@ library default-language: Haskell2010 ghc-options: -Wall hs-source-dirs: src - build-depends: base >= 4.3 && < 4.10, bytestring, directory, process, filepath, Cabal, xml, xhtml, syb + build-depends: base >= 4.3 && < 4.11, bytestring, directory, process, filepath, Cabal, xml, xhtml, syb exposed-modules: Test.Haddock -- cgit v1.2.3 From 70885ce16e1b0b9bf19fe0efb85a48daa0e5c281 Mon Sep 17 00:00:00 2001 From: alexbiehl Date: Tue, 18 Apr 2017 16:45:32 +0200 Subject: Travis: Use ghc-8.2.1 on master --- .travis.yml | 84 +++++++++++++++++++++++++++------ haddock-api/haddock-api.cabal | 5 +- haddock-api/src/Haddock.hs | 25 ++++++---- haddock-library/haddock-library.cabal | 5 +- haddock-test/src/Test/Haddock/Config.hs | 17 +++++-- haddock.cabal | 53 ++++++++++++--------- 6 files changed, 136 insertions(+), 53 deletions(-) (limited to 'haddock-test') 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 -- cgit v1.2.3 From 58edf9f5757daadeeaa7879785c48363fa154996 Mon Sep 17 00:00:00 2001 From: Yuji Yamamoto Date: Tue, 4 Jul 2017 05:37:58 +0900 Subject: Fix test failures on Windows (#564) * Ignore .stack-work * Fix for windows: use nul instead of /dev/null * Fix for windows: canonicalize line separator * Also normalize osx line endings --- .gitignore | 2 ++ haddock-test/haddock-test.cabal | 2 +- haddock-test/src/Test/Haddock/Config.hs | 10 +++++++++- haddock-test/src/Test/Haddock/Utils.hs | 7 +++++++ hoogle-test/Main.hs | 4 +++- latex-test/Main.hs | 4 +++- 6 files changed, 25 insertions(+), 4 deletions(-) (limited to 'haddock-test') diff --git a/.gitignore b/.gitignore index 5d82bc96..5410ef42 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ TAGS .cabal-sandbox cabal.sandbox.config + +.stack-work/ diff --git a/haddock-test/haddock-test.cabal b/haddock-test/haddock-test.cabal index ef928e78..56dd1845 100644 --- a/haddock-test/haddock-test.cabal +++ b/haddock-test/haddock-test.cabal @@ -21,8 +21,8 @@ library exposed-modules: Test.Haddock Test.Haddock.Config + Test.Haddock.Utils Test.Haddock.Xhtml other-modules: Test.Haddock.Process - Test.Haddock.Utils diff --git a/haddock-test/src/Test/Haddock/Config.hs b/haddock-test/src/Test/Haddock/Config.hs index 50616c7f..988636e4 100644 --- a/haddock-test/src/Test/Haddock/Config.hs +++ b/haddock-test/src/Test/Haddock/Config.hs @@ -193,7 +193,7 @@ loadConfig ccfg dcfg flags files = do , baseDependencies ghcPath ] - let cfgHaddockStdOut = fromMaybe "/dev/null" (flagsHaddockStdOut flags) + let cfgHaddockStdOut = fromMaybe defaultStdOut (flagsHaddockStdOut flags) cfgDiffTool <- if FlagNoDiff `elem` flags then pure Nothing @@ -256,6 +256,14 @@ defaultDiffTool = isAvailable = liftM isJust . findProgramLocation silent +defaultStdOut :: FilePath +#ifdef mingw32_HOST_OS +defaultStdOut = "nul" +#else +defaultStdOut = "/dev/null" +#endif + + processFileArgs :: DirConfig -> [String] -> IO [TestPackage] processFileArgs dcfg [] = processFileArgs' dcfg . filter isValidEntry =<< getDirectoryContents srcDir diff --git a/haddock-test/src/Test/Haddock/Utils.hs b/haddock-test/src/Test/Haddock/Utils.hs index a947fea1..58408aaf 100644 --- a/haddock-test/src/Test/Haddock/Utils.hs +++ b/haddock-test/src/Test/Haddock/Utils.hs @@ -48,3 +48,10 @@ copyFile' :: FilePath -> FilePath -> IO () copyFile' old new = do createDirectoryIfMissing True $ takeDirectory new copyFile old new + + +crlfToLf :: String -> String +crlfToLf "" = "" +crlfToLf ('\r' : '\n' : rest) = '\n' : crlfToLf rest +crlfToLf ('\r' : rest) = '\n' : crlfToLf rest +crlfToLf (other : rest) = other : crlfToLf rest diff --git a/hoogle-test/Main.hs b/hoogle-test/Main.hs index 59a98fd0..d19ae585 100644 --- a/hoogle-test/Main.hs +++ b/hoogle-test/Main.hs @@ -1,10 +1,12 @@ {-# LANGUAGE CPP #-} +import Data.Function import System.Environment import System.FilePath import Test.Haddock +import Test.Haddock.Utils checkConfig :: CheckConfig String @@ -12,7 +14,7 @@ checkConfig = CheckConfig { ccfgRead = Just , ccfgClean = \_ -> id , ccfgDump = id - , ccfgEqual = (==) + , ccfgEqual = (==) `on` crlfToLf } diff --git a/latex-test/Main.hs b/latex-test/Main.hs index 5989410b..8d2a4922 100755 --- a/latex-test/Main.hs +++ b/latex-test/Main.hs @@ -1,10 +1,12 @@ {-# LANGUAGE CPP #-} +import Data.Function import System.Environment import System.FilePath import Test.Haddock +import Test.Haddock.Utils checkConfig :: CheckConfig String @@ -12,7 +14,7 @@ checkConfig = CheckConfig { ccfgRead = Just , ccfgClean = \_ -> id , ccfgDump = id - , ccfgEqual = (==) + , ccfgEqual = (==) `on` crlfToLf } -- cgit v1.2.3