From cf22686d11bf9923926f3380793e64d2ff4141fc Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Wed, 19 Aug 2015 13:04:54 +0200 Subject: Re-implement test acceptance functionality. --- haddock-test/src/Test/Haddock.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'haddock-test/src') diff --git a/haddock-test/src/Test/Haddock.hs b/haddock-test/src/Test/Haddock.hs index 18ae38ca..41e15978 100644 --- a/haddock-test/src/Test/Haddock.hs +++ b/haddock-test/src/Test/Haddock.hs @@ -27,6 +27,8 @@ data CheckResult | Pass | NoRef | Error String + | Accepted + deriving Eq runAndCheck :: Config c -> IO () @@ -43,12 +45,13 @@ checkFiles cfg@(Config { .. }) = do failed <- liftM catMaybes . forM files $ \file -> do putStr $ "Checking \"" ++ file ++ "\"... " - status <- checkFile cfg file + status <- maybeAcceptFile cfg file =<< checkFile cfg file case status of Fail -> putStrLn "FAIL" >> (return $ Just file) Pass -> putStrLn "PASS" >> (return Nothing) NoRef -> putStrLn "PASS [no .ref]" >> (return Nothing) Error msg -> putStrLn ("ERROR (" ++ msg ++ ")") >> return Nothing + Accepted -> putStrLn "ACCEPTED" >> return Nothing if null failed then do @@ -127,6 +130,14 @@ diffFile cfg diff file = do refFile' = outFile dcfg file <.> "ref" <.> "dump" +maybeAcceptFile :: Config c -> FilePath -> CheckResult -> IO CheckResult +maybeAcceptFile cfg@(Config { cfgDirConfig = dcfg }) file result + | cfgAccept cfg && result `elem` [NoRef, Fail] = do + copyFile (outFile dcfg file) (refFile dcfg file) + pure Accepted +maybeAcceptFile _ _ result = pure result + + outDir :: DirConfig -> TestPackage -> FilePath outDir dcfg tpkg = dcfgOutDir dcfg tpkgName tpkg -- cgit v1.2.3