doctest 0.25.0 → 0.25.0.1
raw patch · 6 files changed
+36/−4 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.markdown +4/−0
- doctest.cabal +1/−1
- src/Cabal/ReplOptions.hs +4/−0
- src/GhcUtil.hs +3/−1
- src/Options.hs +18/−2
- test/OptionsSpec.hs +6/−0
CHANGES.markdown view
@@ -1,3 +1,7 @@+Changes in 0.25.0.1+ - Discard `--interactive` from response files. This fixes a critical bug+ introduced with `0.25.0` (see #487).+ Changes in 0.25.0 - Full GHC 9.14 compatibility / `-unit`-support
doctest.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: doctest-version: 0.25.0+version: 0.25.0.1 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)
src/Cabal/ReplOptions.hs view
@@ -32,6 +32,7 @@ , Option "libdir" Nothing (Argument "DIR") "installation directory for libraries" , Option "libsubdir" Nothing (Argument "DIR") "subdirectory of libdir in which libs are installed" , Option "dynlibdir" Nothing (Argument "DIR") "installation directory for dynamic libraries"+ , Option "bytecodelibdir" Nothing (Argument "DIR") "installation directory for bytecode libraries" , Option "libexecdir" Nothing (Argument "DIR") "installation directory for program executables" , Option "libexecsubdir" Nothing (Argument "DIR") "subdirectory of libexecdir in which private executables are installed" , Option "datadir" Nothing (Argument "DIR") "installation directory for read-only data"@@ -50,6 +51,8 @@ , Option "disable-shared" Nothing NoArgument "Disable Shared library" , Option "enable-static" Nothing NoArgument "Enable Static library" , Option "disable-static" Nothing NoArgument "Disable Static library"+ , Option "enable-library-bytecode" Nothing NoArgument "Enable Bytecode library"+ , Option "disable-library-bytecode" Nothing NoArgument "Disable Bytecode library" , Option "enable-executable-dynamic" Nothing NoArgument "Enable Executable dynamic linking" , Option "disable-executable-dynamic" Nothing NoArgument "Disable Executable dynamic linking" , Option "enable-executable-static" Nothing NoArgument "Enable Executable fully static linking"@@ -184,6 +187,7 @@ , 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 "project-file-parser" Nothing (Argument "PARSER") "Set the parser to use for the project file" , 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"
src/GhcUtil.hs view
@@ -27,6 +27,8 @@ import GHC.ResponseFile (expandResponse) import System.Exit (exitFailure) +import Options (discardInteractiveFlag)+ -- Catch GHC source errors, print them and exit. handleSrcErrors :: Ghc a -> Ghc a handleSrcErrors action' = flip handleSourceError action' $ \err -> do@@ -36,7 +38,7 @@ -- | Run a GHC action in Haddock mode withGhc :: [String] -> ([String] -> Ghc a) -> IO a withGhc flags action = runGhc (Just libdir) $ do- liftIO (expandUnits flags) >>= handleDynamicFlags >>= handleSrcErrors . action+ liftIO (expandUnits flags) >>= handleDynamicFlags . discardInteractiveFlag >>= handleSrcErrors . action expandUnits :: [String] -> IO [String] expandUnits = \ case
src/Options.hs view
@@ -1,10 +1,12 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} module Options ( Result(..) , Run(..) , Config(..) , defaultConfig , parseOptions+, discardInteractiveFlag #ifdef TEST , defaultRun , usage@@ -71,7 +73,7 @@ , preserveIt = False , failFast = False , verbose = False-, repl = (ghc, ["--interactive"])+, repl = (ghc, [interactiveFlag]) } nonInteractiveGhcOptions :: [String]@@ -118,17 +120,31 @@ parseOptions :: [String] -> Result Run parseOptions args | on "--info" = Output info- | on "--interactive" = runRunOptionsParser (discard "--interactive" args) defaultRun $ do+ | on interactiveFlag = runRunOptionsParser (discardInteractiveFlag args) defaultRun $ do commonRunOptions | on `any` nonInteractiveGhcOptions = ProxyToGhc args | on "--help" = Output usage | on "--version" = Output versionInfo+ | any isResponseFile args = runRunOptionsParser args defaultRun $ do+ commonRunOptions | otherwise = runRunOptionsParser args defaultRun {runMagicMode = True} $ do commonRunOptions parseFlag "--no-magic" (setMagicMode False) parseOptGhc where+ on :: String -> Bool on option = option `elem` args++ isResponseFile :: String -> Bool+ isResponseFile = \ case+ '@' : _ -> True+ _ -> False++interactiveFlag :: String+interactiveFlag = "--interactive"++discardInteractiveFlag :: [String] -> [String]+discardInteractiveFlag = discard interactiveFlag type RunOptionsParser = RWS () (Endo Run) [String] ()
test/OptionsSpec.hs view
@@ -50,6 +50,12 @@ it "accepts --fast" $ do fastMode . runConfig <$> parseOptions ("--fast" : options) `shouldBe` Result True + context "with a response file" $ do+ let options = ["--foo", "@args.rsp", "--bar"]++ it "disables magic mode" $ do+ runMagicMode <$> parseOptions options `shouldBe` Result False+ describe "--no-magic" $ do context "without --no-magic" $ do it "enables magic mode" $ do