[commit: haddock] ghc-head, ghc-head1, headdock-library-1.4.5, ie_avails, master, pr/cabal-desc, v2.18, wip/revert-ttg-2017-11-20, wip/ttg-2017-10-13, wip/ttg-2017-10-31, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13: Fix test failures on Windows (#564) (58edf9f)

git at git.haskell.org git at git.haskell.org
Mon Nov 20 21:08:53 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branches: ghc-head,ghc-head1,headdock-library-1.4.5,ie_avails,master,pr/cabal-desc,v2.18,wip/revert-ttg-2017-11-20,wip/ttg-2017-10-13,wip/ttg-2017-10-31,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13
Link       : http://git.haskell.org/haddock.git/commitdiff/58edf9f5757daadeeaa7879785c48363fa154996

>---------------------------------------------------------------

commit 58edf9f5757daadeeaa7879785c48363fa154996
Author: Yuji Yamamoto <whosekiteneverfly at gmail.com>
Date:   Tue Jul 4 05:37:58 2017 +0900

    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


>---------------------------------------------------------------

58edf9f5757daadeeaa7879785c48363fa154996
 .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(-)

diff --git a/.gitignore b/.gitignore
index 5d82bc9..5410ef4 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 ef928e7..56dd184 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 50616c7..988636e 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 a947fea..58408aa 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 59a98fd..d19ae58 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 5989410..8d2a492 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
     }
 
 



More information about the ghc-commits mailing list