packages feed

doctest 0.24.0 → 0.24.1

raw patch · 4 files changed

+34/−11 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGES.markdown view
@@ -1,3 +1,6 @@+Changes in 0.24.1+  - Interpret GHC response files+ Changes in 0.24.0   - cabal-doctest: Add support for cabal-install 3.14.* 
doctest.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           doctest-version:        0.24.0+version:        0.24.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/Run.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} module Run (   doctest , doctestWithRepl@@ -62,7 +63,7 @@ doctest = doctestWithRepl (repl defaultConfig)  doctestWithRepl :: (String, [String]) -> [String] -> IO ()-doctestWithRepl repl args0 = case parseOptions args0 of+doctestWithRepl repl = interpretResponseFile >=> \ args0 -> case parseOptions args0 of   Options.ProxyToGhc args -> exec Interpreter.ghc args   Options.Output s -> putStr s   Options.Result (Run warnings magicMode config) -> do@@ -82,6 +83,11 @@         addDistArgs <- getAddDistArgs         return (addDistArgs $ packageDBArgs ++ expandedArgs)     doctestWith config{repl, ghcOptions = opts}++interpretResponseFile :: [String] -> IO [String]+interpretResponseFile = \ case+  ['@':name] -> lines <$> readFile name+  args -> return args  -- | Expand a reference to a directory to all .hs and .lhs files within it. expandDirs :: String -> IO [String]
test/RunSpec.hs view
@@ -9,6 +9,7 @@ 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 @@ -35,6 +36,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 +82,19 @@         , "Try `doctest --help' for more information."         ] +    it "interprets GHC response files" $ do+      withSystemTempDirectory "hspec" $ \ dir -> do+        let file = dir </> "response-file"+        writeFile file $ unlines [+            "--verbose"+          , "test/integration/testSimple/Fib.hs"+          ]+        (r, ()) <- hCapture [stderr] $ doctest ['@':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"]