module Test.HSpec.JUnit
  {-# DEPRECATED "Use Test.Hspec.JUnit instead" #-}
  ( junitFormat
  , runJUnitSpec
  , configWith
  ) where

import Prelude

import Data.Text (pack)
import Test.Hspec.Core.Format
import Test.Hspec.Core.Runner
import Test.Hspec.Core.Spec (Spec)
import Test.Hspec.JUnit hiding (junitFormat)
import qualified Test.Hspec.JUnit as JUnit

runJUnitSpec :: Spec -> (FilePath, String) -> Config -> IO Summary
runJUnitSpec :: Spec -> (FilePath, FilePath) -> Config -> IO Summary
runJUnitSpec Spec
spec (FilePath
path, FilePath
name) Config
config =
  Spec
spec Spec -> Config -> IO Summary
`runSpec` FilePath -> FilePath -> Config -> Config
configWith FilePath
filePath FilePath
name Config
config
  where filePath :: FilePath
filePath = FilePath
path FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"/" FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
name FilePath -> FilePath -> FilePath
forall a. Semigroup a => a -> a -> a
<> FilePath
"/test_results.xml"

configWith :: FilePath -> String -> Config -> Config
configWith :: FilePath -> FilePath -> Config -> Config
configWith FilePath
filePath =
  JUnitConfig -> Config -> Config
configWithJUnit
    (JUnitConfig -> Config -> Config)
-> (FilePath -> JUnitConfig) -> FilePath -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> JUnitConfig -> JUnitConfig
setJUnitConfigOutputFile FilePath
filePath
    (JUnitConfig -> JUnitConfig)
-> (FilePath -> JUnitConfig) -> FilePath -> JUnitConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> JUnitConfig
defaultJUnitConfig
    (Text -> JUnitConfig)
-> (FilePath -> Text) -> FilePath -> JUnitConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Text
pack

junitFormat :: FilePath -> String -> FormatConfig -> IO Format
junitFormat :: FilePath -> FilePath -> FormatConfig -> IO Format
junitFormat FilePath
filePath =
  JUnitConfig -> FormatConfig -> IO Format
JUnit.junitFormat
    (JUnitConfig -> FormatConfig -> IO Format)
-> (FilePath -> JUnitConfig)
-> FilePath
-> FormatConfig
-> IO Format
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> JUnitConfig -> JUnitConfig
setJUnitConfigOutputFile FilePath
filePath
    (JUnitConfig -> JUnitConfig)
-> (FilePath -> JUnitConfig) -> FilePath -> JUnitConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> JUnitConfig
defaultJUnitConfig
    (Text -> JUnitConfig)
-> (FilePath -> Text) -> FilePath -> JUnitConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Text
pack