1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE ConstraintKinds #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
4module Helper (
5  module Test.Hspec
6, module Test.Mockery.Directory
7, module Control.Monad
8, module Control.Applicative
9, withTempDirectory
10, module System.FilePath
11, withCurrentDirectory
12, yaml
13) where
14
15import           Test.Hspec
16import           Test.Mockery.Directory
17import           Data.String
18import           Control.Monad
19import           Control.Applicative
20import           System.Directory (getCurrentDirectory, setCurrentDirectory, canonicalizePath)
21import           Control.Exception
22import qualified System.IO.Temp as Temp
23import           System.FilePath
24
25import           Data.Yaml.TH (yamlQQ)
26import           Language.Haskell.TH.Quote (QuasiQuoter)
27
28import           Hpack.Config
29
30instance IsString Cond where
31  fromString = CondExpression
32
33withCurrentDirectory :: FilePath -> IO a -> IO a
34withCurrentDirectory dir action = do
35  bracket getCurrentDirectory setCurrentDirectory $ \ _ -> do
36    setCurrentDirectory dir
37    action
38
39withTempDirectory :: (FilePath -> IO a) -> IO a
40withTempDirectory action = Temp.withSystemTempDirectory "hspec" $ \dir -> do
41  canonicalizePath dir >>= action
42
43yaml :: Language.Haskell.TH.Quote.QuasiQuoter
44yaml = yamlQQ
45