doctest 0.23.0 → 0.25.0
raw patch · 14 files changed
Files
- CHANGES.markdown +15/−0
- LICENSE +1/−1
- doctest.cabal +9/−9
- src/Cabal.hs +1/−1
- src/Cabal/Options.hs +1/−1
- src/Cabal/ReplOptions.hs +11/−7
- src/Extract.hs +14/−34
- src/GhcUtil.hs +13/−18
- src/Imports.hs +0/−6
- src/Interpreter.hs +0/−2
- src/Run.hs +12/−1
- src/Runner.hs +1/−6
- test/Language/Haskell/GhciWrapperSpec.hs +5/−6
- test/RunSpec.hs +42/−19
CHANGES.markdown view
@@ -1,3 +1,18 @@+Changes in 0.25.0+ - Full GHC 9.14 compatibility / `-unit`-support++Changes in 0.24.3+ - Allow building with GHC 9.14 (#478)++Changes in 0.24.2+ - Use `GHC.ResponseFile.expandResponse`++Changes in 0.24.1+ - Interpret GHC response files++Changes in 0.24.0+ - cabal-doctest: Add support for cabal-install 3.14.*+ Changes in 0.23.0 - Add `--fail-fast`
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009-2024 Simon Hengel <sol@typeful.net>+Copyright (c) 2009-2026 Simon Hengel <sol@typeful.net> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
doctest.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.37.0.+-- This file has been generated from package.yaml by hpack version 0.39.1. -- -- see: https://github.com/sol/hpack name: doctest-version: 0.23.0+version: 0.25.0 synopsis: Test interactive Haskell examples description: `doctest` is a tool that checks [examples](https://www.haskell.org/haddock/doc/html/ch03s08.html#idm140354810775744) and [properties](https://www.haskell.org/haddock/doc/html/ch03s08.html#idm140354810771856)@@ -18,7 +18,7 @@ homepage: https://github.com/sol/doctest#readme license: MIT license-file: LICENSE-copyright: (c) 2009-2024 Simon Hengel+copyright: (c) 2009-2026 Simon Hengel author: Simon Hengel <sol@typeful.net> maintainer: Simon Hengel <sol@typeful.net> build-type: Simple@@ -154,14 +154,14 @@ Util Paths_doctest build-depends:- base >=4.7 && <5+ base >=4.12 && <5 , code-page >=0.1 , containers , deepseq , directory , exceptions , filepath- , ghc >=8.0 && <9.12+ , ghc >=8.6 && <9.16 , ghc-paths >=0.1.0.9 , process , syb >=0.3@@ -184,7 +184,7 @@ NoImplicitPrelude ghc-options: -Wall -threaded build-depends:- base >=4.7 && <5+ base >=4.12 && <5 , doctest default-language: Haskell2010 if impl(ghc >= 9.0)@@ -207,7 +207,7 @@ DeriveFunctor NoImplicitPrelude build-depends:- base >=4.7 && <5+ base >=4.12 && <5 , doctest default-language: Haskell2010 if impl(ghc >= 9.0)@@ -279,14 +279,14 @@ build-depends: HUnit , QuickCheck >=2.13.1- , base >=4.7 && <5+ , base >=4.12 && <5 , code-page >=0.1 , containers , deepseq , directory , exceptions , filepath- , ghc >=8.0 && <9.12+ , ghc >=8.6 && <9.16 , ghc-paths >=0.1.0.9 , hspec >=2.3.0 , hspec-core >=2.3.0
src/Cabal.hs view
@@ -66,7 +66,7 @@ withSystemTempDirectory "cabal-doctest" $ \ dir -> do repl ["--keep-temp-files", "--repl-multi-file", dir] files <- filter (isSuffixOf "-inplace") <$> listDirectory dir- options <- concat <$> mapM (fmap lines . readFile . combine dir) files+ let options = concatMap (\ file -> ["-unit", '@' : dir </> file]) files call doctest ("--no-magic" : options) writeFileAtomically :: FilePath -> String -> IO ()
src/Cabal/Options.hs view
@@ -31,7 +31,7 @@ , "--no-transitive-deps" , "--enable-multi-repl" , "--disable-multi-repl"- , "--keep-temp-files"+ , "--with-repl" ] rejectUnsupportedOptions :: [String] -> IO ()
src/Cabal/ReplOptions.hs view
@@ -21,10 +21,10 @@ Option "help" (Just 'h') NoArgument "Show this help text" , Option "verbose" (Just 'v') (OptionalArgument "n") "Control verbosity (n is 0--3, default verbosity level is 1)" , Option "builddir" Nothing (Argument "DIR") "The directory where Cabal puts generated build files (default dist)"+ , Option "keep-temp-files" Nothing NoArgument "Keep temporary files." , Option "ghc" (Just 'g') NoArgument "compile with GHC" , Option "ghcjs" Nothing NoArgument "compile with GHCJS" , Option "uhc" Nothing NoArgument "compile with UHC"- , Option "haskell-suite" Nothing NoArgument "compile with a haskell-suite compiler" , Option "with-compiler" (Just 'w') (Argument "PATH") "give the path to a particular compiler" , Option "with-hc-pkg" Nothing (Argument "PATH") "give the path to the package tool" , Option "prefix" Nothing (Argument "DIR") "bake this prefix in preparation of installation"@@ -56,6 +56,8 @@ , Option "disable-executable-static" Nothing NoArgument "Disable Executable fully static linking" , Option "enable-profiling" Nothing NoArgument "Enable Executable and library profiling" , Option "disable-profiling" Nothing NoArgument "Disable Executable and library profiling"+ , Option "enable-profiling-shared" Nothing NoArgument "Enable Build profiling shared libraries"+ , Option "disable-profiling-shared" Nothing NoArgument "Disable Build profiling shared libraries" , Option "enable-executable-profiling" Nothing NoArgument "Enable Executable profiling (DEPRECATED)" , Option "disable-executable-profiling" Nothing NoArgument "Disable Executable profiling (DEPRECATED)" , Option "profiling-detail" Nothing (Argument "level") "Profiling detail level for executable and library (default, none, exported-functions, toplevel-functions, all-functions, late)."@@ -104,6 +106,7 @@ , Option "disable-response-files" Nothing NoArgument "enable workaround for old versions of programs like \"ar\" that do not support @file arguments" , Option "allow-depending-on-private-libs" Nothing NoArgument "Allow depending on private libraries. If set, the library visibility check MUST be done externally." , Option "coverage-for" Nothing (Argument "UNITID") "A list of unit-ids of libraries to include in the Haskell Program Coverage report."+ , Option "ignore-build-tools" Nothing NoArgument "Ignore build tool dependencies. If set, declared build tools needn't be found for compilation to proceed." , Option "cabal-lib-version" Nothing (Argument "VERSION") "Select which version of the Cabal lib to use to build packages (useful for testing)." , Option "enable-append" Nothing NoArgument "Enable appending the new config to the old config file" , Option "disable-append" Nothing NoArgument "Disable appending the new config to the old config file"@@ -165,27 +168,28 @@ , Option "haddock-hscolour-css" Nothing (Argument "PATH") "Use PATH as the HsColour stylesheet" , Option "haddock-contents-location" Nothing (Argument "URL") "Bake URL in as the location for the contents page" , Option "haddock-base-url" Nothing (Argument "URL") "Base URL for static files."- , Option "haddock-lib" Nothing (Argument "DIR") "location of Haddocks static / auxiliary files"+ , Option "haddock-resources-dir" Nothing (Argument "DIR") "location of Haddocks static / auxiliary files" , Option "haddock-output-dir" Nothing (Argument "DIR") "Generate haddock documentation into this directory. This flag is provided as a technology preview and is subject to change in the next releases."+ , Option "haddock-use-unicode" Nothing NoArgument "Pass --use-unicode option to haddock" , Option "test-log" Nothing (Argument "TEMPLATE") "Log all test suite results to file (name template can use $pkgid, $compiler, $os, $arch, $test-suite, $result)" , Option "test-machine-log" Nothing (Argument "TEMPLATE") "Produce a machine-readable log file (name template can use $pkgid, $compiler, $os, $arch, $result)" , Option "test-show-details" Nothing (Argument "FILTER") "'always': always show results of individual test cases. 'never': never show results of individual test cases. 'failures': show results of failing test cases. 'streaming': show results of test cases in real time.'direct': send results of test cases in real time; no log file." , Option "test-keep-tix-files" Nothing NoArgument "keep .tix files for HPC between test runs" , Option "test-wrapper" Nothing (Argument "FILE") "Run test through a wrapper." , Option "test-fail-when-no-test-suites" Nothing NoArgument "Exit with failure when no test suites are found."- , Option "test-options" Nothing (Argument "TEMPLATES") "give extra options to test executables (name templates can use $pkgid, $compiler, $os, $arch, $test-suite)"- , Option "test-option" Nothing (Argument "TEMPLATE") "give extra option to test executables (no need to quote options containing spaces, name template can use $pkgid, $compiler, $os, $arch, $test-suite)"- , Option "benchmark-options" Nothing (Argument "TEMPLATES") "give extra options to benchmark executables (name templates can use $pkgid, $compiler, $os, $arch, $benchmark)"- , Option "benchmark-option" Nothing (Argument "TEMPLATE") "give extra option to benchmark executables (no need to quote options containing spaces, name template can use $pkgid, $compiler, $os, $arch, $benchmark)"+ , Option "test-options" Nothing (Argument "TEMPLATES") "give extra options to test executables (split on spaces, use \"\" to prevent splitting; name templates can use $pkgid, $compiler, $os, $arch, $test-suite)"+ , Option "test-option" Nothing (Argument "TEMPLATE") "give extra option to test executables (passed directly as a single argument; name template can use $pkgid, $compiler, $os, $arch, $test-suite)"+ , Option "benchmark-options" Nothing (Argument "TEMPLATES") "give extra options to benchmark executables (split on spaces, use \"\" to prevent splitting; name templates can use $pkgid, $compiler, $os, $arch, $benchmark)"+ , Option "benchmark-option" Nothing (Argument "TEMPLATE") "give extra option to benchmark executables (passed directly as a single argument; name template can use $pkgid, $compiler, $os, $arch, $benchmark)" , Option "project-dir" Nothing (Argument "DIR") "Set the path of the project directory" , Option "project-file" Nothing (Argument "FILE") "Set the path of the cabal.project file (relative to the project directory when relative)" , Option "ignore-project" (Just 'z') NoArgument "Ignore local project configuration (unless --project-dir or --project-file is also set)" , Option "repl-no-load" Nothing NoArgument "Disable loading of project modules at REPL startup." , Option "repl-options" Nothing (Argument "FLAG") "Use the option(s) for the repl" , Option "repl-multi-file" Nothing (Argument "DIR") "Write repl options to this directory rather than starting repl mode"+ , Option "with-repl" Nothing (Argument "PATH") "Give the path to a program to use for REPL" , Option "build-depends" (Just 'b') (Argument "DEPENDENCIES") "Include additional packages in the environment presented to GHCi." , Option "no-transitive-deps" Nothing NoArgument "Don't automatically include transitive dependencies of requested packages." , Option "enable-multi-repl" Nothing NoArgument "Enable multi-component repl sessions" , Option "disable-multi-repl" Nothing NoArgument "Disable multi-component repl sessions"- , Option "keep-temp-files" Nothing NoArgument "Keep temporary files" ]
src/Extract.hs view
@@ -29,10 +29,6 @@ import System.Directory import System.FilePath -#if __GLASGOW_HASKELL__ < 805-import FastString (unpackFS)-#endif- import System.Posix.Internals (c_getpid) import GhcUtil (withGhc)@@ -41,13 +37,11 @@ import Util (convertDosLineEndings) import PackageDBs (getPackageDBArgs) -#if __GLASGOW_HASKELL__ >= 806 #if __GLASGOW_HASKELL__ < 900 import DynamicLoading (initializePlugins) #else import GHC.Runtime.Loader (initializePlugins) #endif-#endif #if __GLASGOW_HASKELL__ >= 901 import GHC.Unit.Module.Graph@@ -55,7 +49,9 @@ -- | A wrapper around `SomeException`, to allow for a custom `Show` instance. newtype ExtractError = ExtractError SomeException+#if __GLASGOW_HASKELL__ < 912 deriving Typeable+#endif instance Show ExtractError where show (ExtractError e) =@@ -85,15 +81,6 @@ instance NFData a => NFData (Module a) where rnf (Module name setup content) = name `deepseq` setup `deepseq` content `deepseq` () -#if __GLASGOW_HASKELL__ < 803-type GhcPs = RdrName-#endif--#if __GLASGOW_HASKELL__ < 805-addQuoteInclude :: [String] -> [String] -> [String]-addQuoteInclude includes new = new ++ includes-#endif- -- | Parse a list of modules. parse :: [String] -> IO [ParsedModule] parse args = withGhc args $ \modules_ -> withTempOutputDir $ do@@ -108,7 +95,11 @@ Nothing) mods <- depanal [] False - let sortedMods = flattenSCCs+ let sortedMods =+#if __GLASGOW_HASKELL__ >= 914+ mapMaybe maybeModSummaryFromModuleNodeInfo $+#endif+ flattenSCCs #if __GLASGOW_HASKELL__ >= 901 $ filterToposortToModules #endif@@ -154,7 +145,6 @@ , includePaths = addQuoteInclude (includePaths d) [f] } -#if __GLASGOW_HASKELL__ >= 806 -- Since GHC 8.6, plugins are initialized on a per module basis loadModPlugins modsum = do _ <- setSessionDynFlags (GHC.ms_hspp_opts modsum)@@ -168,9 +158,6 @@ dynflags' <- liftIO (initializePlugins hsc_env (GHC.ms_hspp_opts modsum)) return $ modsum { ms_hspp_opts = dynflags' } # endif-#else- loadModPlugins = return-#endif -- | Extract all docstrings from given list of files/modules. --@@ -208,6 +195,13 @@ (setup, docs) = partition isSetup (docStringsFromModule m) name = (moduleNameString . GHC.moduleName . ms_mod . pm_mod_summary) m +#if __GLASGOW_HASKELL__ >= 914+maybeModSummaryFromModuleNodeInfo :: ModuleNodeInfo -> Maybe ModSummary+maybeModSummaryFromModuleNodeInfo i = case i of+ ModuleNodeCompile summary -> Just summary+ ModuleNodeFixed _ _ -> Nothing+#endif+ #if __GLASGOW_HASKELL__ >= 904 unpackHDS :: HsDocString -> String unpackHDS = renderHsDocString@@ -239,11 +233,7 @@ #else exports = [ (Nothing, L (locA loc) doc) #endif-#if __GLASGOW_HASKELL__ < 805- | L loc (IEDoc doc) <- maybe [] unLoc (hsmodExports source)-#else | L loc (IEDoc _ doc) <- maybe [] unLoc (hsmodExports source)-#endif ] decls :: [(Maybe String, LHsDocString)] decls = extractDocStrings (hsmodDecls source)@@ -281,11 +271,7 @@ -- Top-level documentation has to be treated separately, because it has -- no location information attached. The location information is -- attached to HsDecl instead.-#if __GLASGOW_HASKELL__ < 805- DocD x-#else DocD _ x-#endif -> select (fromDocDecl (locA loc) x) _ -> (extractDocStrings decl, True)@@ -311,12 +297,6 @@ -- | Collect given value and descend into subtree. select :: a -> ([a], Bool) select x = ([x], False)-#endif--#if __GLASGOW_HASKELL__ < 805--- | Convert a docstring to a plain string.-unpackHDS :: HsDocString -> String-unpackHDS (HsDocString s) = unpackFS s #endif #if __GLASGOW_HASKELL__ < 901
src/GhcUtil.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-}-module GhcUtil (withGhc) where+{-# LANGUAGE LambdaCase #-}+module GhcUtil (withGhc, expandUnits) where import Imports @@ -23,12 +24,9 @@ import GHC.Utils.Monad (liftIO) #endif +import GHC.ResponseFile (expandResponse) import System.Exit (exitFailure) -#if __GLASGOW_HASKELL__ < 801-import StaticFlags (discardStaticFlags)-#endif- -- Catch GHC source errors, print them and exit. handleSrcErrors :: Ghc a -> Ghc a handleSrcErrors action' = flip handleSourceError action' $ \err -> do@@ -37,20 +35,17 @@ -- | Run a GHC action in Haddock mode withGhc :: [String] -> ([String] -> Ghc a) -> IO a-withGhc flags action = do- flags_ <- handleStaticFlags flags-- runGhc (Just libdir) $ do- handleDynamicFlags flags_ >>= handleSrcErrors . action+withGhc flags action = runGhc (Just libdir) $ do+ liftIO (expandUnits flags) >>= handleDynamicFlags >>= handleSrcErrors . action -handleStaticFlags :: [String] -> IO [Located String]-#if __GLASGOW_HASKELL__ < 801-handleStaticFlags flags = return $ map noLoc $ discardStaticFlags flags-#else-handleStaticFlags flags = return $ map noLoc $ flags-#endif+expandUnits :: [String] -> IO [String]+expandUnits = \ case+ [] -> return []+ "-unit" : file@('@' : _) : args -> (++) <$> expandResponse [file] <*> expandUnits args+ file@('@' : _) : args -> (++) <$> expandResponse [file] <*> expandUnits args+ x : xs -> (:) x <$> expandUnits xs -handleDynamicFlags :: GhcMonad m => [Located String] -> m [String]+handleDynamicFlags :: GhcMonad m => [String] -> m [String] handleDynamicFlags flags = do #if __GLASGOW_HASKELL__ >= 901 logger <- getLogger@@ -58,7 +53,7 @@ #else let parseDynamicFlags' = parseDynamicFlags #endif- (dynflags, locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= (`parseDynamicFlags'` flags)+ (dynflags, locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= (`parseDynamicFlags'` map noLoc flags) _ <- setSessionDynFlags dynflags -- We basically do the same thing as `ghc/Main.hs` to distinguish
src/Imports.hs view
@@ -14,13 +14,7 @@ import System.Exit import System.Process -#if __GLASGOW_HASKELL__ >= 804 import Data.Functor as Imports ((<&>))-#else-infixl 1 <&>-(<&>) :: Functor f => f a -> (a -> b) -> f b-(<&>) = flip fmap-#endif pass :: Monad m => m () pass = return ()
src/Interpreter.hs view
@@ -46,10 +46,8 @@ let args = flags ++ [ xTemplateHaskell-#if __GLASGOW_HASKELL__ >= 802 , "-fdiagnostics-color=never" , "-fno-diagnostics-show-caret"-#endif #if __GLASGOW_HASKELL__ >= 810 && __GLASGOW_HASKELL__ < 904 , "-Wno-unused-packages" #endif
src/Run.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} module Run ( doctest , doctestWithRepl@@ -37,6 +38,10 @@ import GHC.Utils.Panic #endif +#if __GLASGOW_HASKELL__ < 904+import GhcUtil (expandUnits)+#endif+ import PackageDBs import Parse import Options hiding (Result(..))@@ -62,7 +67,13 @@ doctest = doctestWithRepl (repl defaultConfig) doctestWithRepl :: (String, [String]) -> [String] -> IO ()-doctestWithRepl repl args0 = case parseOptions args0 of+#if __GLASGOW_HASKELL__ < 904+-- GHC versions prior to 9.4.1 don't support response files. For that reason+-- we want to expand early, so that GHCi gets expanded args.+doctestWithRepl repl = expandUnits >=> parseOptions >>> \ case+#else+doctestWithRepl repl = parseOptions >>> \ case+#endif Options.ProxyToGhc args -> exec Interpreter.ghc args Options.Output s -> putStr s Options.Result (Run warnings magicMode config) -> do
src/Runner.hs view
@@ -61,13 +61,8 @@ -- | Sum up summaries. instance Monoid Summary where mempty = Summary 0 0 0 0-#if __GLASGOW_HASKELL__ < 804- mappend-#else instance Semigroup Summary where- (<>)-#endif- (Summary x1 x2 x3 x4) (Summary y1 y2 y3 y4) = Summary (x1 + y1) (x2 + y2) (x3 + y3) (x4 + y4)+ Summary x1 x2 x3 x4 <> Summary y1 y2 y3 y4 = Summary (x1 + y1) (x2 + y2) (x3 + y3) (x4 + y4) withLineBuffering :: Handle -> IO c -> IO c withLineBuffering h action = bracket (hGetBuffering h) (hSetBuffering h) $ \ _ -> do
test/Language/Haskell/GhciWrapperSpec.hs view
@@ -78,20 +78,19 @@ it "shows exceptions" $ withInterpreter $ \ghci -> do ghci "import Control.Exception" `shouldReturn` ""+#if __GLASGOW_HASKELL__ >= 912+ ghci "throwIO DivideByZero" `shouldReturn` "*** Exception: divide by zero\n\nHasCallStack backtrace:\n throwIO, called at <interactive>:25:1 in interactive:Ghci22\n\n"+#else ghci "throwIO DivideByZero" `shouldReturn` "*** Exception: divide by zero\n"+#endif it "shows exceptions (ExitCode)" $ withInterpreter $ \ghci -> do ghci "import System.Exit" `shouldReturn` "" ghci "exitWith $ ExitFailure 10" `shouldReturn` "*** Exception: ExitFailure 10\n" it "gives an error message for identifiers that are not in scope" $ withInterpreter $ \ghci -> do-#if __GLASGOW_HASKELL__ >= 800 ghci "foo" >>= (`shouldSatisfy` isInfixOf "Variable not in scope: foo")-#elif __GLASGOW_HASKELL__ >= 707- ghci "foo" >>= (`shouldSatisfy` isSuffixOf "Not in scope: \8216foo\8217\n")-#else- ghci "foo" >>= (`shouldSatisfy` isSuffixOf "Not in scope: `foo'\n")-#endif+ context "when configVerbose is True" $ do it "prints prompt" $ do withInterpreterConfig defaultConfig{configVerbose = True} [] $ \ghci -> do
test/RunSpec.hs view
@@ -9,8 +9,8 @@ import qualified Control.Exception as E import System.FilePath import System.Directory (getCurrentDirectory, setCurrentDirectory)+import System.IO.Temp (withSystemTempDirectory) import Data.List (isPrefixOf, sort)-import Data.Char import System.IO.Silently import System.IO (stderr)@@ -35,6 +35,17 @@ removeLoadedPackageEnvironment = id #endif +verboseFibOutput :: String+verboseFibOutput = unlines [+ "### Started execution at test/integration/testSimple/Fib.hs:5."+ , "### example:"+ , "fib 10"+ , "### Successful!"+ , ""+ , "# Final summary:"+ , "Examples: 1 Tried: 1 Errors: 0 Failures: 0"+ ]+ spec :: Spec spec = do describe "doctest" $ do@@ -70,17 +81,18 @@ , "Try `doctest --help' for more information." ] + it "interprets GHC response files" $ do+ withSystemTempDirectory "hspec" $ \ dir -> do+ let file = dir </> "response-file"+ writeFile file $ unlines [+ "test/integration/testSimple/Fib.hs"+ ]+ (r, ()) <- hCapture [stderr] $ doctest ["--verbose", '@':file]+ removeLoadedPackageEnvironment r `shouldBe` verboseFibOutput+ it "prints verbose description of a specification" $ do (r, ()) <- hCapture [stderr] $ doctest ["--verbose", "test/integration/testSimple/Fib.hs"]- removeLoadedPackageEnvironment r `shouldBe` unlines [- "### Started execution at test/integration/testSimple/Fib.hs:5."- , "### example:"- , "fib 10"- , "### Successful!"- , ""- , "# Final summary:"- , "Examples: 1 Tried: 1 Errors: 0 Failures: 0"- ]+ removeLoadedPackageEnvironment r `shouldBe` verboseFibOutput it "prints verbose description of a property" $ do (r, ()) <- hCapture [stderr] $ doctest ["--verbose", "test/integration/property-bool/Foo.hs"]@@ -118,15 +130,33 @@ describe "doctestWithResult" $ do context "on parse error" $ do let+ action :: IO Result action = withCurrentDirectory "test/integration/parse-error" $ do- doctestWithResult defaultConfig { ghcOptions = ["Foo.hs"] }+ doctestWithResult defaultConfig {+ ghcOptions = [+ "Foo.hs" + -- This is necessary due to:+ --+ -- https://gitlab.haskell.org/ghc/ghc/-/commit/88f38b03025386f0f1e8f5861eed67d80495168a+ --+ -- It will be fixed by:+ --+ -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/15995+ --+ , "-fdiagnostics-color=never"+#if __GLASGOW_HASKELL__ >= 910+ , "-fprint-error-index-links=never"+#endif+ ]+ }+ it "aborts with (ExitFailure 1)" $ do hSilence [stderr] action `shouldThrow` (== ExitFailure 1) it "prints a useful error message" $ do (r, _) <- hCapture [stderr] (E.try action :: IO (Either ExitCode Summary))- stripAnsiColors (removeLoadedPackageEnvironment r) `shouldBe` unlines (+ removeLoadedPackageEnvironment r `shouldBe` unlines ( #if __GLASGOW_HASKELL__ < 910 "" : #endif@@ -155,10 +185,3 @@ let x = "foo bar baz bin" res <- expandDirs x res `shouldBe` [x]--stripAnsiColors :: String -> String-stripAnsiColors xs = case xs of- '\ESC' : '[' : ';' : ys | 'm' : zs <- dropWhile isNumber ys -> stripAnsiColors zs- '\ESC' : '[' : ys | 'm' : zs <- dropWhile isNumber ys -> stripAnsiColors zs- y : ys -> y : stripAnsiColors ys- [] -> []