aboutsummaryrefslogtreecommitdiff
path: root/haddock-test/src/Test
diff options
context:
space:
mode:
authorŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-24 23:09:20 +0200
committerŁukasz Hanuszczak <lukasz.hanuszczak@gmail.com>2015-08-24 23:09:20 +0200
commit136c48c5fe074ac8a2755c4705d555de24e22a3a (patch)
treed218525bf8d05d0fa6197c141d2e8eda1830bc7f /haddock-test/src/Test
parent27d5cba94e827e10c9f5b02b162f6b13cd8cbea1 (diff)
Fix bug with accepting to non-existing directory.
Diffstat (limited to 'haddock-test/src/Test')
-rw-r--r--haddock-test/src/Test/Haddock.hs2
-rw-r--r--haddock-test/src/Test/Haddock/Utils.hs7
2 files changed, 8 insertions, 1 deletions
diff --git a/haddock-test/src/Test/Haddock.hs b/haddock-test/src/Test/Haddock.hs
index 87c16739..e8a0ac8e 100644
--- a/haddock-test/src/Test/Haddock.hs
+++ b/haddock-test/src/Test/Haddock.hs
@@ -132,7 +132,7 @@ diffFile cfg diff file = do
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)
+ copyFile' (outFile dcfg file) (refFile dcfg file)
pure Accepted
maybeAcceptFile _ _ result = pure result
diff --git a/haddock-test/src/Test/Haddock/Utils.hs b/haddock-test/src/Test/Haddock/Utils.hs
index 4f97fa72..a947fea1 100644
--- a/haddock-test/src/Test/Haddock/Utils.hs
+++ b/haddock-test/src/Test/Haddock/Utils.hs
@@ -41,3 +41,10 @@ createEmptyDirectory :: FilePath -> IO ()
createEmptyDirectory path = do
whenM (doesDirectoryExist path) $ removeDirectoryRecursive path
createDirectory path
+
+
+-- | Just like 'copyFile' but output directory path is not required to exist.
+copyFile' :: FilePath -> FilePath -> IO ()
+copyFile' old new = do
+ createDirectoryIfMissing True $ takeDirectory new
+ copyFile old new