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