@@ -3,19 +3,17 @@
3module TestSuite.Util
3module TestSuite.Util
4 ( fromAssertions
4 ( fromAssertions
5 , newTestStore
5 , newTestStore
8 , newTestProvider
6 , newTestProvider
9 , testCompiler
7 , testCompiler
10 , testCompilerDone
8 , testCompilerDone
11− , withTestConfiguration
9+ , testConfiguration
15--------------------------------------------------------------------------------
14--------------------------------------------------------------------------------
16import Data.Monoid (mempty)
15import Data.Monoid (mempty)
17import qualified Data.Set as S
16import qualified Data.Set as S
18−import System.Directory (removeDirectoryRecursive)
19import Test.Framework
17import Test.Framework
20import Test.Framework.Providers.HUnit
18import Test.Framework.Providers.HUnit
21import Test.HUnit hiding (Test)
19import Test.HUnit hiding (Test)
@@ -30,6 +28,7 @@ import qualified Hakyll.Core.Logger as Logger
30import Hakyll.Core.Provider
28import Hakyll.Core.Provider
31import Hakyll.Core.Store (Store)
29import Hakyll.Core.Store (Store)
32import qualified Hakyll.Core.Store as Store
30import qualified Hakyll.Core.Store as Store
31+import Hakyll.Core.Util.File
35--------------------------------------------------------------------------------
34--------------------------------------------------------------------------------
@@ -42,26 +41,13 @@ fromAssertions name =
43--------------------------------------------------------------------------------
42--------------------------------------------------------------------------------
44newTestStore :: IO Store
43newTestStore :: IO Store
45−newTestStore = Store.new True "_teststore"
44+newTestStore = Store.new True $ storeDirectory testConfiguration
48−--------------------------------------------------------------------------------
49−cleanTestStore :: IO ()
50−cleanTestStore = removeDirectoryRecursive "_teststore"
53−--------------------------------------------------------------------------------
54−withTestStore :: (Store -> IO a) -> IO a
56− store <- newTestStore
62--------------------------------------------------------------------------------
47--------------------------------------------------------------------------------
63newTestProvider :: Store -> IO Provider
48newTestProvider :: Store -> IO Provider
64−newTestProvider store = newProvider store (const False) "tests/data"
49+newTestProvider store = newProvider store (const False) $
50+ providerDirectory testConfiguration
67--------------------------------------------------------------------------------
53--------------------------------------------------------------------------------
@@ -70,7 +56,8 @@ testCompiler :: Store -> Provider -> Identifier -> Compiler a
70testCompiler store provider underlying compiler = do
56testCompiler store provider underlying compiler = do
71 logger <- Logger.new Logger.Error
57 logger <- Logger.new Logger.Error
72 let read' = CompilerRead
58 let read' = CompilerRead
59+ { compilerConfig = testConfiguration
73− { compilerUnderlying = underlying
60+ , compilerUnderlying = underlying
74 , compilerProvider = provider
61 , compilerProvider = provider
75 , compilerUniverse = S.empty
62 , compilerUniverse = S.empty
76 , compilerRoutes = mempty
63 , compilerRoutes = mempty
@@ -99,15 +86,18 @@ testCompilerDone store provider underlying compiler = do
101--------------------------------------------------------------------------------
88--------------------------------------------------------------------------------
102−withTestConfiguration :: (Configuration -> IO a) -> IO a
89+testConfiguration :: Configuration
103−withTestConfiguration f = do
105− removeDirectoryRecursive $ destinationDirectory config
106− removeDirectoryRecursive $ storeDirectory config
109− config = defaultConfiguration
90+testConfiguration = defaultConfiguration
110− { destinationDirectory = "_testsite"
91+ { destinationDirectory = "_testsite"
111− , storeDirectory = "_teststore"
92+ , storeDirectory = "_teststore"
93+ , tmpDirectory = "_testtmp"
112− , providerDirectory = "tests/data"
94+ , providerDirectory = "tests/data"
98+--------------------------------------------------------------------------------
101+ removeDirectory $ destinationDirectory testConfiguration
102+ removeDirectory $ storeDirectory testConfiguration
103+ removeDirectory $ tmpDirectory testConfiguration