diff options
author | alexbiehl <alex.biehl@gmail.com> | 2017-08-21 20:05:42 +0200 |
---|---|---|
committer | alexbiehl <alex.biehl@gmail.com> | 2017-08-21 20:05:42 +0200 |
commit | 7a71af839bd71992a36d97650004c73bf11fa436 (patch) | |
tree | e64afbc9df5c97fde6ac6433e42f28df8a4acf49 /haddock-test/src/Test/Haddock/Config.hs | |
parent | c8a01b83be52e45d3890db173ffe7b09ccd4f351 (diff) | |
parent | 740458ac4d2acf197f2ef8dc94a66f9b160b9c3c (diff) |
Merge remote-tracking branch 'origin/master' into ghc-head
Diffstat (limited to 'haddock-test/src/Test/Haddock/Config.hs')
-rw-r--r-- | haddock-test/src/Test/Haddock/Config.hs | 27 |
1 files changed, 21 insertions, 6 deletions
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 |