[commit: haddock] 2.17.3.1-spanfix, alexbiehl-patch-1, ghc-8.0, ghc-8.0-facebook, ghc-head, ghc-head1, haddock-quick, headdock-library-1.4.5, ie_avails, issue-303, issue-475, master, pr-filter-maps, pr/cabal-desc, travis, v2.17, v2.17.3, v2.18, wip-located-module-as, wip/D2418, wip/T11080-open-data-kinds, wip/T11430, wip/T12105, wip/T12105-2, wip/T12942, wip/T13163, wip/T3384, wip/embelleshed-rdr, wip/new-tree-one-param, wip/rae, wip/remove-frames, wip/remove-frames1, 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: Setup skeleton of framework for running tests. (cf8f244)

git at git.haskell.org git at git.haskell.org
Mon Nov 20 20:52:44 UTC 2017


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

On branches: 2.17.3.1-spanfix,alexbiehl-patch-1,ghc-8.0,ghc-8.0-facebook,ghc-head,ghc-head1,haddock-quick,headdock-library-1.4.5,ie_avails,issue-303,issue-475,master,pr-filter-maps,pr/cabal-desc,travis,v2.17,v2.17.3,v2.18,wip-located-module-as,wip/D2418,wip/T11080-open-data-kinds,wip/T11430,wip/T12105,wip/T12105-2,wip/T12942,wip/T13163,wip/T3384,wip/embelleshed-rdr,wip/new-tree-one-param,wip/rae,wip/remove-frames,wip/remove-frames1,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/cf8f24440d50de82dff9277bc9376cbdcc75e91b

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

commit cf8f24440d50de82dff9277bc9376cbdcc75e91b
Author: Ɓukasz Hanuszczak <lukasz.hanuszczak at gmail.com>
Date:   Tue Aug 4 16:49:47 2015 +0200

    Setup skeleton of framework for running tests.


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

cf8f24440d50de82dff9277bc9376cbdcc75e91b
 html-test/run.hs | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/html-test/run.hs b/html-test/run.hs
index 5678a87..b3ca478 100755
--- a/html-test/run.hs
+++ b/html-test/run.hs
@@ -47,6 +47,12 @@ data Config = Config
     }
 
 
+data CheckResult
+    = Fail
+    | Pass
+    | NoRef
+
+
 main :: IO ()
 main = do
     cfg <- uncurry loadConfig =<< checkOpt =<< getArgs
@@ -55,14 +61,29 @@ main = do
 
 
 checkOutput :: Config -> IO ()
-checkOutput _ = return () -- TODO.
+checkOutput (Config { .. }) = do
+    putStrLn "Diffing output files..."
+    failFiles <- forM cfgFiles $ \file -> do
+        putStr $ "Checking " ++ takeBaseName file ++ "... "
+
+        status <- checkFile file
+        case status of
+            Fail -> putStrLn "FAIL" >> (return $ Just file)
+            Pass -> putStrLn "PASS" >> (return Nothing)
+            NoRef -> putStrLn "PASS [no .ref]" >> (return Nothing)
+
+    return () -- TODO: Print diff for failed cases.
 
 
 runHaddock :: Config -> IO ()
 runHaddock (Config { .. }) = do
+    putStrLn "Running Haddock process..."
+
+    devNull <- openFile "/dev/null" WriteMode
     handle <- runProcess' cfgHaddockPath $ processConfig
         { pcArgs = cfgHaddockArgs ++ cfgFiles
         , pcEnv = Just $ cfgEnv
+        , pcStdOut = Just $ devNull
         }
     waitForSuccess "Failed to run Haddock on specified test files" handle
 
@@ -109,6 +130,23 @@ loadConfig flags files = do
     return $ Config { .. }
 
 
+checkFile :: FilePath -> IO CheckResult
+checkFile file = do
+    hasRef <- doesFileExist refFile
+    if hasRef
+    then do
+        out <- readFile outFile
+        ref <- readFile refFile
+        return $ if haddockEq out ref
+            then Pass
+            else Fail
+    else return NoRef
+  where
+    outFile = outDir </> mdl <.> "html"
+    refFile = refDir </> mdl <.> "html"
+    mdl = takeBaseName $ file
+
+
 printVersions :: Environment -> FilePath -> IO ()
 printVersions env haddockPath = do
     handle <- runProcess' haddockPath $ processConfig
@@ -229,3 +267,7 @@ waitForSuccess msg handle = do
 
 mlast :: [a] -> Maybe a
 mlast = listToMaybe . reverse
+
+
+haddockEq :: String -> String -> Bool
+haddockEq _ _ = True -- TODO.



More information about the ghc-commits mailing list