diff options
Diffstat (limited to 'haddock-test')
-rw-r--r-- | haddock-test/haddock-test.cabal | 4 | ||||
-rw-r--r-- | haddock-test/src/Test/Haddock/Config.hs | 27 | ||||
-rw-r--r-- | haddock-test/src/Test/Haddock/Utils.hs | 7 |
3 files changed, 30 insertions, 8 deletions
diff --git a/haddock-test/haddock-test.cabal b/haddock-test/haddock-test.cabal index 7cb15d7d..56dd1845 100644 --- a/haddock-test/haddock-test.cabal +++ b/haddock-test/haddock-test.cabal @@ -16,13 +16,13 @@ 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 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 e1e920f2..988636e4 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"] @@ -186,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 @@ -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 { .. } @@ -249,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 |