doctest 0.9.5.1 → 0.9.6
raw patch · 3 files changed
+26/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- doctest.cabal +1/−1
- src/Interpreter.hs +18/−3
- src/Run.hs +7/−2
doctest.cabal view
@@ -1,5 +1,5 @@ name: doctest-version: 0.9.5.1+version: 0.9.6 synopsis: Test interactive Haskell examples description: The doctest program checks examples in source code comments. It is modeled after doctest for Python
src/Interpreter.hs view
@@ -4,6 +4,11 @@ , safeEval , withInterpreter , ghc+, interpreterSupported++-- exported for testing+, ghcInfo+, haveInterpreterKey ) where import System.IO@@ -11,6 +16,7 @@ import System.Exit import System.Directory (getPermissions, executable) import Control.Monad (when, unless)+import Control.Applicative import Control.Exception hiding (handle) import Data.Char import Data.List@@ -31,15 +37,24 @@ , process :: ProcessHandle } -newInterpreter :: [String] -> IO Interpreter-newInterpreter flags = do+haveInterpreterKey :: String+haveInterpreterKey = "Have interpreter" +ghcInfo :: IO [(String, String)]+ghcInfo = read <$> readProcess ghc ["--info"] []++interpreterSupported :: IO Bool+interpreterSupported = do -- in a perfect world this permission check should never fail, but I know of -- at least one case where it did.. x <- getPermissions ghc unless (executable x) $ do fail $ ghc ++ " is not executable!" + maybe False (== "YES") . lookup haveInterpreterKey <$> ghcInfo++newInterpreter :: [String] -> IO Interpreter+newInterpreter flags = do (Just stdin_, Just stdout_, Nothing, processHandle ) <- createProcess $ (proc ghc myFlags) {std_in = CreatePipe, std_out = CreatePipe, std_err = Inherit} setMode stdin_ setMode stdout_@@ -88,7 +103,7 @@ e <- waitForProcess $ process repl hClose $ hOut repl - when (e /= ExitSuccess) $ error $ "Interpreter exited with an error: " ++ show e + when (e /= ExitSuccess) $ error $ "Interpreter exited with an error: " ++ show e return () putExpression :: Interpreter -> String -> IO ()
src/Run.hs view
@@ -9,8 +9,8 @@ ) where import Data.List-import Control.Monad (when)-import System.Exit (exitFailure)+import Control.Monad (when, unless)+import System.Exit (exitFailure, exitSuccess) import System.IO import System.Environment (getEnvironment) @@ -52,6 +52,11 @@ let addPackageConf = case packageConf of Nothing -> id Just p -> \rest -> ghcPackageDbFlag : p : rest+ + i <- Interpreter.interpreterSupported+ unless i $ do+ hPutStrLn stderr "WARNING: GHC does not support --interactive, skipping tests"+ exitSuccess let (f, args_) = stripOptGhc args when f $ do