packages feed

sandwich 0.1.3.2 → 0.1.4.0

raw patch · 4 files changed

+31/−3 lines, 4 filesdep +Win32

Dependencies added: Win32

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # Changelog for sandwich +## Unreleased++## 0.1.4.0++* Windows improvements (fix "invalid argument (invalid character)", fix console unicode output)+* Add Alternative (ExampleT context m) instance+ ## 0.1.3.2  * Prevent spurious messages in IOExceptions from withFile
sandwich.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           sandwich-version:        0.1.3.2+version:        0.1.4.0 synopsis:       Yet another test framework for Haskell description:    Please see the <https://codedownio.github.io/sandwich documentation>. category:       Testing@@ -132,6 +132,9 @@         brick       , unix       , vty+  if os(windows)+    build-depends:+        Win32   if !os(windows)     exposed-modules:         Test.Sandwich.Formatters.TerminalUI
src/Test/Sandwich.hs view
@@ -1,8 +1,9 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE RankNTypes #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeOperators #-}  module Test.Sandwich (   -- | Sandwich is a test framework for Haskell. See the <https://codedownio.github.io/sandwich/docs/ documentation> for details and usage examples.@@ -79,6 +80,7 @@ import Data.Maybe import Data.String.Interpolate import qualified Data.Text as T+import GHC.IO.Encoding import Options.Applicative import qualified Options.Applicative as OA import System.Environment@@ -107,7 +109,11 @@ import Test.Sandwich.Types.Spec import Test.Sandwich.Types.TestTimer +#ifdef mingw32_HOST_OS+import System.Win32.Console+#endif + -- | Run the spec with the given 'Options'. runSandwich :: Options -> CoreSpec -> IO () runSandwich options spec = void $ runSandwich' Nothing options spec@@ -172,6 +178,15 @@ runSandwich' :: Maybe (CommandLineOptions ()) -> Options -> CoreSpec -> IO (ExitReason, Int) runSandwich' maybeCommandLineOptions options spec' = do   baseContext <- baseContextFromOptions options++  -- To prevent weird errors saving files like "commitAndReleaseBuffer: invalid argument (invalid character)",+  -- especially on Windows+  -- See https://gitlab.haskell.org/ghc/ghc/issues/8118+  setLocaleEncoding utf8+#ifdef mingw32_HOST_OS+  -- Fix Windows console output. Makes sandwich-hedgehog unicode print properly+  setConsoleOutputCP 65001+#endif    -- Wrap the spec in a finalizer for the test timer, when one is present   let spec = case baseContextTestTimer baseContext of
src/Test/Sandwich/Types/Spec.hs view
@@ -17,6 +17,7 @@  module Test.Sandwich.Types.Spec where +import Control.Applicative import Control.Exception.Safe import Control.Monad.Base import Control.Monad.Except@@ -47,6 +48,8 @@ newtype ExampleT context m a = ExampleT { unExampleT :: ReaderT context (LoggingT m) a }   deriving (Functor, Applicative, Monad, MonadIO, MonadReader context, MonadLogger, MonadLoggerIO, MonadThrow, MonadCatch, MonadMask) type ExampleM context = ExampleT context IO++deriving instance (Applicative m, Alternative (LoggingT m)) => Alternative (ExampleT context m)  instance (MonadIO m, MonadUnliftIO m) => MonadUnliftIO (ExampleT context m) where   withRunInIO inner = ExampleT $ withRunInIO $ \run -> inner (run . unExampleT)