diff --git a/hedgehog/src/Hedgehog/Internal/Report.hs b/hedgehog/src/Hedgehog/Internal/Report.hs index ca44ef7e..d3b8285d 100644 --- a/hedgehog/src/Hedgehog/Internal/Report.hs +++ b/hedgehog/src/Hedgehog/Internal/Report.hs @@ -1,4 +1,5 @@ {-# OPTIONS_HADDOCK not-home #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFoldable #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveTraversable #-} @@ -63,6 +64,9 @@ import System.Console.ANSI (ColorIntensity(..), Color(..)) import System.Console.ANSI (ConsoleLayer(..), ConsoleIntensity(..)) import System.Console.ANSI (SGR(..), setSGRCode) import System.Directory (makeRelativeToCurrentDirectory) +#if mingw32_HOST_OS +import System.IO (hSetEncoding, stdout, stderr, utf8) +#endif import Text.PrettyPrint.Annotated.WL (Doc, (<+>)) import qualified Text.PrettyPrint.Annotated.WL as WL @@ -781,7 +785,7 @@ ppSummary summary = ] renderDoc :: MonadIO m => Maybe UseColor -> Doc Markup -> m String -renderDoc mcolor doc = do +renderDoc mcolor doc = liftIO $ do let dull = SetColor Foreground Dull @@ -885,6 +889,10 @@ renderDoc mcolor doc = do DisableColor -> WL.display +#if mingw32_HOST_OS + hSetEncoding stdout utf8 + hSetEncoding stderr utf8 +#endif pure . display . WL.renderSmart 100 $ diff --git a/hedgehog/src/Hedgehog/Internal/Runner.hs b/hedgehog/src/Hedgehog/Internal/Runner.hs index 174bf468..6c71f42b 100644 --- a/hedgehog/src/Hedgehog/Internal/Runner.hs +++ b/hedgehog/src/Hedgehog/Internal/Runner.hs @@ -1,5 +1,6 @@ {-# OPTIONS_HADDOCK not-home #-} {-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DoAndIfThenElse #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} @@ -45,6 +46,9 @@ import Hedgehog.Range (Size) import Language.Haskell.TH.Lift (deriveLift) +#if mingw32_HOST_OS +import System.IO (hSetEncoding, stdout, stderr, utf8) +#endif -- | Configuration for a property test run. -- @@ -265,6 +269,10 @@ checkGroup config (Group group props) = -- our tests will saturate all the capabilities they're given. updateNumCapabilities (n + 2) +#if mingw32_HOST_OS + hSetEncoding stdout utf8 + hSetEncoding stderr utf8 +#endif putStrLn $ "━━━ " ++ unGroupName group ++ " ━━━" verbosity <- resolveVerbosity (runnerVerbosity config)