aboutsummaryrefslogtreecommitdiff
path: root/haddock-test/src/Test/Haddock.hs
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-17 12:54:48 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-22 23:40:27 +0200
commit5568091a53ee53f742b6fe9f11b3edd1664228b9 (patch)
tree69eea91bc519833eb479f342567e9667a289c34f /haddock-test/src/Test/Haddock.hs
parentc2d2c481da18310053396bb0d2a9d070335eb865 (diff)
Implement output accepting mechanism in test package.
Diffstat (limited to 'haddock-test/src/Test/Haddock.hs')
-rw-r--r--haddock-test/src/Test/Haddock.hs16
1 files changed, 15 insertions, 1 deletions
diff --git a/haddock-test/src/Test/Haddock.hs b/haddock-test/src/Test/Haddock.hs
index 78204840..a2c6609a 100644
--- a/haddock-test/src/Test/Haddock.hs
+++ b/haddock-test/src/Test/Haddock.hs
@@ -29,7 +29,11 @@ data CheckResult
runAndCheck :: Config c -> IO ()
-runAndCheck cfg = runHaddock cfg >> checkFiles cfg
+runAndCheck cfg = do
+ runHaddock cfg
+ if cfgAccept cfg
+ then acceptFiles cfg
+ else checkFiles cfg
checkFiles :: Config c -> IO ()
@@ -55,6 +59,16 @@ checkFiles cfg@(Config { .. }) = do
exitFailure
+acceptFiles :: Config c -> IO ()
+acceptFiles (Config { cfgFiles = files, cfgDirConfig = dcfg }) = do
+
+ forM_ files $ \file -> do
+ let mdl = takeBaseName file
+ putStr $ "Accepting " ++ mdl ++ "... "
+ copyFile (outFile dcfg mdl) (refFile dcfg mdl)
+ putStrLn "DONE"
+
+
maybeDiff :: Config c -> [String] -> IO ()
maybeDiff (Config { cfgDiffTool = Nothing }) _ = pure ()
maybeDiff cfg@(Config { cfgDiffTool = (Just diff) }) mdls = do