diff -Nru haskell-doctest-0.16.3/CHANGES haskell-doctest-0.18.2/CHANGES --- haskell-doctest-0.16.3/CHANGES 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/CHANGES 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -Changes in 0.16.3 - - Add a cursor to highlight the differing portion between the - expected and actual output. (#249) - - GHC 8.10 compatibility. (#247, #257) - -Changes in 0.16.2 - - Add doctest's necessary-for-operation options to GHC's command - line at the end, so that they over-ride anything provided by the - user. (#233) - - Allow GHC 8.8. - -Changes in 0.16.1 - - Fix loading plugins in doctests. (#224) - - Require QuickCheck 2.13.1 or newer. - - Remove dependency on `with-location` - -Changes in 0.16.0.1 - - Bump bounds to allow GHC 8.6. (#210) - -Changes in 0.16.0 - - Output format has changed to (hopefully) be more machine consumable. (#200) - -Changes in 0.15.0 - - Add `--verbose` for printing each test as it is run - -Changes in 0.14.1 - - Add test assets to source tarball (see #189) - -Changes in 0.14.0 - - GHC 8.4 compatibility. - -Changes in 0.13.0 - - Add `--preserve-it` for allowing the `it` variable to be preserved between examples - -Changes in 0.12.0 - - Preserve the 'it' variable between examples - -Changes in 0.11.4 - - Add `--fast`, which disables running `:reload` between example groups - -Changes in 0.11.3 - - Add `--info` - - Add `--no-magic` - -Changes in 0.11.2 - - Make `...` match zero lines - -Changes in 0.11.1 - - Fix an issue with Unicode output on Windows (see #149) - -Changes in 0.11.0 - - Support for GHC 8.0.1-rc2 - -Changes in 0.10.1 - - Automatically expand directories into contained Haskell source files (thanks @snoyberg) - - Add cabal_macros.h and autogen dir by default (thanks @snoyberg) - -Changes in 0.10.0 - - Support HASKELL_PACKAGE_SANDBOXES (thanks @snoyberg) - -Changes in 0.9.13 - - Add ellipsis as wildcard - -Changes in 0.9.12 - - Add support for GHC 7.10 - -Changes in 0.9.11 - - Defaults ambiguous type variables to Integer (#74) - -Changes in 0.9.10 - - Add support for the upcoming GHC 7.8 release - -Changes in 0.9.9 - - Add support for multi-line statements - -Changes in 0.9.8 - - Support for GHC HEAD (7.7) - -Changes in 0.9.7 - - Ignore trailing whitespace when matching example output - -Changes in 0.9.6 - - Fail gracefully if GHCi is not supported (#46) - -Changes in 0.9.5 - - Fix a GHC panic with GHC 7.6.1 (#41) - -Changes in 0.9.4 - - Respect HASKELL_PACKAGE_SANDBOX (#39) - - Print path to ghc on --version - -Changes in 0.9.3 - - Properly handle additional object files (#38) - -Changes in 0.9.2 - - Add support for QuickCheck properties - -Changes in 0.9.1 - - Fix an issue with GHC 7.6.1 and type families - -Changes in 0.9.0 - - Add support for setup code (see README). - - There is no distinction between example/interaction anymore. Each - expression is counted as an example in the summary. - -Changes in 0.8.0 - - Doctest now directly accepts arbitrary GHC options, prefixing GHC options - with --optghc is no longer necessary - -Changes in 0.7.0 - - Print source location for failing tests - - Output less clutter on failing examples - - Expose Doctest's functionality through a very simplistic API, which can be - used for cabal integration - -Changes in 0.6.1 - - Fix a parser bug with CR+LF line endings - -Changes in 0.6.0 - - Support for ghc-7.4 - - Doctest now comes with it's own parser and does not depend on Haddock - anymore - -Changes in 0.5.2 - - Proper handling of singular/plural when printing stats - - Improve handling of invalid command line options - -Changes in 0.5.1 - - Adapted for ghc-7.2 - -Changes in 0.5.0 - - Print number of interactions to stderr before running tests - - Exit with exitFailure on failed tests - - Improve documentation - - Give a useful error message if ghc is not executable diff -Nru haskell-doctest-0.16.3/CHANGES.markdown haskell-doctest-0.18.2/CHANGES.markdown --- haskell-doctest-0.16.3/CHANGES.markdown 1970-01-01 00:00:00.000000000 +0000 +++ haskell-doctest-0.18.2/CHANGES.markdown 2001-09-09 01:46:40.000000000 +0000 @@ -0,0 +1,150 @@ +Changes in 0.18.2 + - GHC 9.2 compatibility. (#305, thanks to Ryan Scott and Matthew Pickering) + +Changes in 0.18.1 + - GHC 9.0 compatibility. (#275) + +Changes in 0.18 + - Don't use unqualified references to `stderr` or `stdout` which may collide with definitions in user code. (#201) + - Remove support for cabal-install sandboxes. They have been obsoleted in practice by Nix-style builds in cabal-install (i.e., the `v2-*` commands) and stack. + +Changes in 0.17 + - #266: + - doctest now annotates its internal marker string as a `String`, to prevent misbehaviour in `OverloadedStrings` environments. This has a theoretical chance of breakage; if you're affected, please open an issue. + - `evalEcho` no longer preserves `it`. + +Changes in 0.16.3 + - Add a cursor to highlight the differing portion between the + expected and actual output. (#249) + - GHC 8.10 compatibility. (#247, #257) + +Changes in 0.16.2 + - Add doctest's necessary-for-operation options to GHC's command + line at the end, so that they over-ride anything provided by the + user. (#233) + - Allow GHC 8.8. + +Changes in 0.16.1 + - Fix loading plugins in doctests. (#224) + - Require QuickCheck 2.13.1 or newer. + - Remove dependency on `with-location` + +Changes in 0.16.0.1 + - Bump bounds to allow GHC 8.6. (#210) + +Changes in 0.16.0 + - Output format has changed to (hopefully) be more machine consumable. (#200) + +Changes in 0.15.0 + - Add `--verbose` for printing each test as it is run + +Changes in 0.14.1 + - Add test assets to source tarball (see #189) + +Changes in 0.14.0 + - GHC 8.4 compatibility. + +Changes in 0.13.0 + - Add `--preserve-it` for allowing the `it` variable to be preserved between examples + +Changes in 0.12.0 + - Preserve the 'it' variable between examples + +Changes in 0.11.4 + - Add `--fast`, which disables running `:reload` between example groups + +Changes in 0.11.3 + - Add `--info` + - Add `--no-magic` + +Changes in 0.11.2 + - Make `...` match zero lines + +Changes in 0.11.1 + - Fix an issue with Unicode output on Windows (see #149) + +Changes in 0.11.0 + - Support for GHC 8.0.1-rc2 + +Changes in 0.10.1 + - Automatically expand directories into contained Haskell source files (thanks @snoyberg) + - Add cabal_macros.h and autogen dir by default (thanks @snoyberg) + +Changes in 0.10.0 + - Support HASKELL_PACKAGE_SANDBOXES (thanks @snoyberg) + +Changes in 0.9.13 + - Add ellipsis as wildcard + +Changes in 0.9.12 + - Add support for GHC 7.10 + +Changes in 0.9.11 + - Defaults ambiguous type variables to Integer (#74) + +Changes in 0.9.10 + - Add support for the upcoming GHC 7.8 release + +Changes in 0.9.9 + - Add support for multi-line statements + +Changes in 0.9.8 + - Support for GHC HEAD (7.7) + +Changes in 0.9.7 + - Ignore trailing whitespace when matching example output + +Changes in 0.9.6 + - Fail gracefully if GHCi is not supported (#46) + +Changes in 0.9.5 + - Fix a GHC panic with GHC 7.6.1 (#41) + +Changes in 0.9.4 + - Respect HASKELL_PACKAGE_SANDBOX (#39) + - Print path to ghc on --version + +Changes in 0.9.3 + - Properly handle additional object files (#38) + +Changes in 0.9.2 + - Add support for QuickCheck properties + +Changes in 0.9.1 + - Fix an issue with GHC 7.6.1 and type families + +Changes in 0.9.0 + - Add support for setup code (see README). + - There is no distinction between example/interaction anymore. Each + expression is counted as an example in the summary. + +Changes in 0.8.0 + - Doctest now directly accepts arbitrary GHC options, prefixing GHC options + with --optghc is no longer necessary + +Changes in 0.7.0 + - Print source location for failing tests + - Output less clutter on failing examples + - Expose Doctest's functionality through a very simplistic API, which can be + used for cabal integration + +Changes in 0.6.1 + - Fix a parser bug with CR+LF line endings + +Changes in 0.6.0 + - Support for ghc-7.4 + - Doctest now comes with it's own parser and does not depend on Haddock + anymore + +Changes in 0.5.2 + - Proper handling of singular/plural when printing stats + - Improve handling of invalid command line options + +Changes in 0.5.1 + - Adapted for ghc-7.2 + +Changes in 0.5.0 + - Print number of interactions to stderr before running tests + - Exit with exitFailure on failed tests + - Improve documentation + - Give a useful error message if ghc is not executable diff -Nru haskell-doctest-0.16.3/debian/changelog haskell-doctest-0.18.2/debian/changelog --- haskell-doctest-0.16.3/debian/changelog 2021-09-11 04:52:47.000000000 +0000 +++ haskell-doctest-0.18.2/debian/changelog 2022-08-23 05:43:13.000000000 +0000 @@ -1,32 +1,20 @@ -haskell-doctest (0.16.3-1build5.1) impish; urgency=medium +haskell-doctest (0.18.2-1build2) kinetic; urgency=medium - * No-change rebuild for libffi soname change. + * No-change rebuild for new ghc - -- Matthias Klose Sat, 11 Sep 2021 06:52:47 +0200 + -- Steve Langasek Tue, 23 Aug 2022 05:43:13 +0000 -haskell-doctest (0.16.3-1build5) hirsute; urgency=medium +haskell-doctest (0.18.2-1build1) kinetic; urgency=medium - * Rebuild against new GHC ABI. + * No-change rebuild for new ghc - -- Gianfranco Costamagna Tue, 05 Jan 2021 10:50:49 +0100 + -- Steve Langasek Tue, 23 Aug 2022 02:35:42 +0000 -haskell-doctest (0.16.3-1build3) hirsute; urgency=medium +haskell-doctest (0.18.2-1) unstable; urgency=medium - * No-change rebuild for new GHC ABIs + * New upstream release - -- Steve Langasek Thu, 29 Oct 2020 22:31:20 +0000 - -haskell-doctest (0.16.3-1build2) groovy; urgency=medium - - * No-change rebuild against libffi8ubuntu1 - - -- Steve Langasek Thu, 27 Aug 2020 00:06:36 +0000 - -haskell-doctest (0.16.3-1build1) groovy; urgency=medium - - * No change rebuild against new ghc ABI. - - -- Dimitri John Ledkov Wed, 22 Jul 2020 01:25:22 +0100 + -- Clint Adams Tue, 14 Jun 2022 15:24:08 -0400 haskell-doctest (0.16.3-1) unstable; urgency=medium diff -Nru haskell-doctest-0.16.3/debian/control haskell-doctest-0.18.2/debian/control --- haskell-doctest-0.16.3/debian/control 2020-07-22 00:25:22.000000000 +0000 +++ haskell-doctest-0.18.2/debian/control 2022-08-23 02:35:42.000000000 +0000 @@ -14,6 +14,8 @@ libghc-base-compat-prof, libghc-code-page-dev (>= 0.1), libghc-code-page-prof, + libghc-exceptions-dev, + libghc-exceptions-prof, libghc-ghc-paths-dev (>= 0.1.0.9), libghc-ghc-paths-prof, libghc-syb-dev (>= 0.3), @@ -21,6 +23,7 @@ Build-Depends-Indep: ghc-doc, libghc-base-compat-doc, libghc-code-page-doc, + libghc-exceptions-doc, libghc-ghc-paths-doc, libghc-syb-doc, Standards-Version: 4.1.4 diff -Nru haskell-doctest-0.16.3/doctest.cabal haskell-doctest-0.18.2/doctest.cabal --- haskell-doctest-0.16.3/doctest.cabal 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/doctest.cabal 2001-09-09 01:46:40.000000000 +0000 @@ -1,16 +1,16 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0. +-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack -- --- hash: 4cde762c2c650b42498854666c00b2d44f751e196c9b0dd779fcb055b388414f +-- hash: 3c86bef70634c1ec5f684a059a0805713b8f747ef2dcaecf351c5f773410e4d2 name: doctest -version: 0.16.3 +version: 0.18.2 synopsis: Test interactive Haskell examples description: The doctest program checks examples in source code comments. It is modeled - after doctest for Python (). + after doctest for Python (). . Documentation is at . category: Testing @@ -20,8 +20,20 @@ license-file: LICENSE copyright: (c) 2009-2018 Simon Hengel author: Simon Hengel -maintainer: quasicomputational +maintainer: quasicomputational@gmail.com, Andreas Abel build-type: Simple +tested-with: + GHC == 7.6.3 + , GHC == 7.8.4 + , GHC == 7.10.3 + , GHC == 8.0.2 + , GHC == 8.2.2 + , GHC == 8.4.4 + , GHC == 8.6.5 + , GHC == 8.8.4 + , GHC == 8.10.7 + , GHC == 9.0.1 + , GHC == 9.2.1 extra-source-files: example/example.cabal example/src/Example.hs @@ -71,6 +83,7 @@ test/integration/failing/Foo.hs test/integration/it/Foo.hs test/integration/it/Setup.hs + test/integration/local-stderr-binding/A.hs test/integration/multiline/Multiline.hs test/integration/parse-error/Foo.hs test/integration/property-bool-with-type-signature/Foo.hs @@ -81,6 +94,7 @@ test/integration/property-setup/Foo.hs test/integration/setup-skip-on-failure/Foo.hs test/integration/setup/Foo.hs + test/integration/system-io-imported/A.hs test/integration/template-haskell-bugfix/Main.hs test/integration/template-haskell-bugfix/Printf.hs test/integration/template-haskell/Foo.hs @@ -98,9 +112,7 @@ test/integration/trailing-whitespace/Foo.hs test/integration/with-cbits/Bar.hs test/integration/with-cbits/foo.c - test/sandbox/bad.config - test/sandbox/cabal.sandbox.config - CHANGES + CHANGES.markdown README.markdown source-repository head @@ -126,7 +138,6 @@ Run Runner Runner.Example - Sandbox Util Language.Haskell.GhciWrapper Paths_doctest @@ -136,8 +147,9 @@ , code-page >=0.1 , deepseq , directory + , exceptions , filepath - , ghc >=7.0 && <8.11 + , ghc >=7.0 && <9.3 , ghc-paths >=0.1.0.9 , process , syb >=0.3 @@ -158,8 +170,9 @@ , deepseq , directory , doctest + , exceptions , filepath - , ghc >=7.0 && <8.11 + , ghc >=7.0 && <9.3 , ghc-paths >=0.1.0.9 , process , syb >=0.3 @@ -179,8 +192,9 @@ , deepseq , directory , doctest + , exceptions , filepath - , ghc >=7.0 && <8.11 + , ghc >=7.0 && <9.3 , ghc-paths >=0.1.0.9 , process , syb >=0.3 @@ -202,7 +216,6 @@ Runner.ExampleSpec RunnerSpec RunSpec - SandboxSpec UtilSpec Extract GhcUtil @@ -215,7 +228,6 @@ Run Runner Runner.Example - Sandbox Test.DocTest Util Language.Haskell.GhciWrapper @@ -237,8 +249,9 @@ , code-page >=0.1 , deepseq , directory + , exceptions , filepath - , ghc >=7.0 && <8.11 + , ghc >=7.0 && <9.3 , ghc-paths >=0.1.0.9 , hspec >=2.3.0 , hspec-core >=2.3.0 diff -Nru haskell-doctest-0.16.3/ghci-wrapper/src/Language/Haskell/GhciWrapper.hs haskell-doctest-0.18.2/ghci-wrapper/src/Language/Haskell/GhciWrapper.hs --- haskell-doctest-0.16.3/ghci-wrapper/src/Language/Haskell/GhciWrapper.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/ghci-wrapper/src/Language/Haskell/GhciWrapper.hs 2001-09-09 01:46:40.000000000 +0000 @@ -15,7 +15,7 @@ import System.Exit import Control.Monad import Control.Exception -import Data.List +import Data.List (isSuffixOf) import Data.Maybe data Config = Config { @@ -54,20 +54,20 @@ setMode stdin_ setMode stdout_ let interpreter = Interpreter {hIn = stdin_, hOut = stdout_, process = processHandle} - _ <- eval interpreter "import System.IO" - _ <- eval interpreter "import GHC.IO.Handle" + _ <- eval interpreter "import qualified System.IO" + _ <- eval interpreter "import qualified GHC.IO.Handle" -- The buffering of stdout and stderr is NoBuffering - _ <- eval interpreter "hDuplicateTo stdout stderr" + _ <- eval interpreter "GHC.IO.Handle.hDuplicateTo System.IO.stdout System.IO.stderr" -- Now the buffering of stderr is BlockBuffering Nothing -- In this situation, GHC 7.7 does not flush the buffer even when -- error happens. - _ <- eval interpreter "hSetBuffering stdout LineBuffering" - _ <- eval interpreter "hSetBuffering stderr LineBuffering" + _ <- eval interpreter "GHC.IO.Handle.hSetBuffering System.IO.stdout GHC.IO.Handle.LineBuffering" + _ <- eval interpreter "GHC.IO.Handle.hSetBuffering System.IO.stderr GHC.IO.Handle.LineBuffering" -- this is required on systems that don't use utf8 as default encoding (e.g. -- Windows) - _ <- eval interpreter "hSetEncoding stdout utf8" - _ <- eval interpreter "hSetEncoding stderr utf8" + _ <- eval interpreter "GHC.IO.Handle.hSetEncoding System.IO.stdout GHC.IO.Handle.utf8" + _ <- eval interpreter "GHC.IO.Handle.hSetEncoding System.IO.stderr GHC.IO.Handle.utf8" _ <- eval interpreter ":m - System.IO" _ <- eval interpreter ":m - GHC.IO.Handle" @@ -102,7 +102,7 @@ putExpression Interpreter{hIn = stdin} preserveIt e = do hPutStrLn stdin e when preserveIt $ hPutStrLn stdin $ "let " ++ itMarker ++ " = it" - hPutStrLn stdin marker + hPutStrLn stdin (marker ++ " :: Data.String.String") when preserveIt $ hPutStrLn stdin $ "let it = " ++ itMarker hFlush stdin @@ -142,5 +142,5 @@ -- | Evaluate an expression evalEcho :: Interpreter -> String -> IO String evalEcho repl expr = do - putExpression repl True expr + putExpression repl False expr getResult True repl diff -Nru haskell-doctest-0.16.3/README.markdown haskell-doctest-0.18.2/README.markdown --- haskell-doctest-0.16.3/README.markdown 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/README.markdown 2001-09-09 01:46:40.000000000 +0000 @@ -67,7 +67,7 @@ haddock -h Fib.hs -o doc/ `doctest` will fail on comments that `haddock` also doesn't like. -Sometimes (e.g., (https://github.com/sol/doctest/issues/251)[#251]), this means that `doctest` will fail on input that GHC accepts. +Sometimes (e.g., [#251](https://github.com/sol/doctest/issues/251)), this means that `doctest` will fail on input that GHC accepts. `doctest` likes UTF-8. If you are running it with, e.g., `LC_ALL=C`, you may need to invoke `doctest` with `LC_ALL=C.UTF-8`. @@ -412,20 +412,42 @@ ## Contributors * Adam Vogt + * Alan Zimmerman + * Alexander Bernauer + * Alexandre Esteves * Anders Persson + * Andreas Abel * Ankit Ahuja + * Artyom Kazak * Edward Kmett + * Gabor Greif * Hiroki Hattori + * Ignat Insarov + * Jens Petersen * Joachim Breitner + * John Chee * João Cristóvão * Julian Arni * Kazu Yamamoto + * Leon Schoorl * Levent Erkok * Luke Murphy * Matvey Aksenov * Michael Orlitzky * Michael Snoyman + * Mitchell Rosen * Nick Smallbone + * Nikos Baxevanis + * Oleg Grenrus + * quasicomputational + * Ryan Scott * Sakari Jokinen * Simon Hengel * Sönke Hahn + * Takano Akio + * Tamar Christina + * Veronika Romashkina + +For up-to-date list, query + + git shortlog -s diff -Nru haskell-doctest-0.16.3/src/Extract.hs haskell-doctest-0.18.2/src/Extract.hs --- haskell-doctest-0.16.3/src/Extract.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Extract.hs 2001-09-09 01:46:40.000000000 +0000 @@ -19,12 +19,25 @@ #if __GLASGOW_HASKELL__ < 707 import GHC hiding (flags, Module, Located) import MonadUtils (liftIO, MonadIO) -#else +#elif __GLASGOW_HASKELL__ < 900 import GHC hiding (Module, Located) import DynFlags import MonadUtils (liftIO) +#else +import GHC hiding (Module, Located) +import GHC.Driver.Session +import GHC.Utils.Monad (liftIO) #endif + +#if __GLASGOW_HASKELL__ < 900 +import Digraph (flattenSCCs) import Exception (ExceptionMonad) +#else +import GHC.Data.Graph.Directed (flattenSCCs) +import GHC.Utils.Exception (ExceptionMonad) +import Control.Monad.Catch (generalBracket) +#endif + import System.Directory import System.FilePath @@ -37,8 +50,6 @@ import FastString (unpackFS) #endif -import Digraph (flattenSCCs) - import System.Posix.Internals (c_getpid) import GhcUtil (withGhc) @@ -48,7 +59,15 @@ 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 #endif -- | A wrapper around `SomeException`, to allow for a custom `Show` instance. @@ -85,12 +104,6 @@ #if __GLASGOW_HASKELL__ < 803 type GhcPs = RdrName - -needsTemplateHaskellOrQQ :: ModuleGraph -> Bool -needsTemplateHaskellOrQQ = needsTemplateHaskell - -mapMG :: (ModSummary -> ModSummary) -> ModuleGraph -> ModuleGraph -mapMG = map #endif #if __GLASGOW_HASKELL__ < 805 @@ -99,36 +112,26 @@ #endif -- | Parse a list of modules. -parse :: [String] -> IO [TypecheckedModule] +parse :: [String] -> IO [ParsedModule] parse args = withGhc args $ \modules_ -> withTempOutputDir $ do -- ignore additional object files let modules = filter (not . isSuffixOf ".o") modules_ - mapM (`guessTarget` Nothing) modules >>= setTargets + setTargets =<< forM modules (\ m -> guessTarget m +#if __GLASGOW_HASKELL__ >= 903 + Nothing +#endif + Nothing) mods <- depanal [] False - mods' <- if needsTemplateHaskellOrQQ mods then enableCompilation mods else return mods - - let sortedMods = flattenSCCs (topSortModuleGraph False mods' Nothing) - reverse <$> mapM (loadModPlugins >=> parseModule >=> typecheckModule >=> loadModule) sortedMods - where - -- copied from Haddock/Interface.hs - enableCompilation :: ModuleGraph -> Ghc ModuleGraph - enableCompilation modGraph = do -#if __GLASGOW_HASKELL__ < 707 - let enableComp d = d { hscTarget = defaultObjectTarget } -#elif __GLASGOW_HASKELL__ < 809 - let enableComp d = let platform = targetPlatform d - in d { hscTarget = defaultObjectTarget platform } -#else - let enableComp d = d { hscTarget = defaultObjectTarget d } + let sortedMods = flattenSCCs +#if __GLASGOW_HASKELL__ >= 901 + $ filterToposortToModules #endif - modifySessionDynFlags enableComp - -- We need to update the DynFlags of the ModSummaries as well. - let upd m = m { ms_hspp_opts = enableComp (ms_hspp_opts m) } - let modGraph' = mapMG upd modGraph - return modGraph' + $ topSortModuleGraph False mods Nothing + reverse <$> mapM (loadModPlugins >=> parseModule) sortedMods + where -- copied from Haddock/GhcUtils.hs modifySessionDynFlags :: (DynFlags -> DynFlags) -> Ghc () @@ -159,7 +162,11 @@ -- | A variant of 'gbracket' where the return value from the first computation -- is not required. gbracket_ :: ExceptionMonad m => m a -> m b -> m c -> m c +#if __GLASGOW_HASKELL__ < 900 gbracket_ before_ after thing = gbracket before_ (const after) (const thing) +#else + gbracket_ before_ after thing = fst <$> generalBracket before_ (\ _ _ -> after) (const thing) +#endif setOutputDir f d = d { objectDir = Just f @@ -171,9 +178,21 @@ #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) hsc_env <- getSession + +# if __GLASGOW_HASKELL__ >= 903 + hsc_env' <- liftIO (initializePlugins hsc_env Nothing) + setSession hsc_env' + return $ modsum +# elif __GLASGOW_HASKELL__ >= 901 + hsc_env' <- liftIO (initializePlugins hsc_env) + setSession hsc_env' + return $ modsum +# else dynflags' <- liftIO (initializePlugins hsc_env (GHC.ms_hspp_opts modsum)) return $ modsum { ms_hspp_opts = dynflags' } +# endif #else loadModPlugins = return #endif @@ -187,7 +206,7 @@ packageDBArgs <- getPackageDBArgs let args' = args ++ packageDBArgs mods <- parse args' - let docs = map (fmap (fmap convertDosLineEndings) . extractFromModule . tm_parsed_module) mods + let docs = map (fmap (fmap convertDosLineEndings) . extractFromModule) mods (docs `deepseq` return docs) `catches` [ -- Re-throw AsyncException, otherwise execution will not terminate on @@ -219,13 +238,15 @@ -- traversing the whole source in a generic way, to ensure that we get -- everything in source order. header = [(Nothing, x) | Just x <- [hsmodHaddockModHeader source]] + exports = [ (Nothing, L (locA loc) doc) #if __GLASGOW_HASKELL__ < 710 - exports = [(Nothing, L loc doc) | L loc (IEDoc doc) <- concat (hsmodExports source)] + | L loc (IEDoc doc) <- concat (hsmodExports source) #elif __GLASGOW_HASKELL__ < 805 - exports = [(Nothing, L loc doc) | L loc (IEDoc doc) <- maybe [] unLoc (hsmodExports source)] + | L loc (IEDoc doc) <- maybe [] unLoc (hsmodExports source) #else - exports = [(Nothing, L loc doc) | L loc (IEDoc _ doc) <- maybe [] unLoc (hsmodExports source)] + | L loc (IEDoc _ doc) <- maybe [] unLoc (hsmodExports source) #endif + ] decls = extractDocStrings (hsmodDecls source) type Selector a = a -> ([(Maybe String, LHsDocString)], Bool) @@ -279,15 +300,21 @@ -- no location information attached. The location information is -- attached to HsDecl instead. #if __GLASGOW_HASKELL__ < 805 - DocD x -> select (fromDocDecl loc x) + DocD x #else - DocD _ x -> select (fromDocDecl loc x) + DocD _ x #endif + -> select (fromDocDecl (locA loc) x) _ -> (extractDocStrings decl, True) - fromLDocDecl :: Selector LDocDecl - fromLDocDecl (L loc x) = select (fromDocDecl loc x) + fromLDocDecl :: Selector +#if __GLASGOW_HASKELL__ >= 901 + (LDocDecl GhcPs) +#else + LDocDecl +#endif + fromLDocDecl (L loc x) = select (fromDocDecl (locA loc) x) fromLHsDocString :: Selector LHsDocString fromLHsDocString x = select (Nothing, x) @@ -302,3 +329,8 @@ unpackHDS :: HsDocString -> String unpackHDS (HsDocString s) = unpackFS s #endif + +#if __GLASGOW_HASKELL__ < 901 +locA :: SrcSpan -> SrcSpan +locA = id +#endif diff -Nru haskell-doctest-0.16.3/src/GhcUtil.hs haskell-doctest-0.18.2/src/GhcUtil.hs --- haskell-doctest-0.16.3/src/GhcUtil.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/GhcUtil.hs 2001-09-09 01:46:40.000000000 +0000 @@ -8,11 +8,25 @@ import DynFlags (dopt_set) #else import GHC +#if __GLASGOW_HASKELL__ < 900 import DynFlags (gopt_set) +#else +import GHC.Driver.Session (gopt_set) +#endif #endif + +#if __GLASGOW_HASKELL__ < 900 import Panic (throwGhcException) +#else +import GHC.Utils.Panic (throwGhcException) +#endif +#if __GLASGOW_HASKELL__ < 900 import MonadUtils (liftIO) +#else +import GHC.Utils.Monad (liftIO) +#endif + import System.Exit (exitFailure) #if __GLASGOW_HASKELL__ < 702 @@ -66,7 +80,13 @@ handleDynamicFlags :: GhcMonad m => [Located String] -> m [String] handleDynamicFlags flags = do - (dynflags, locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= flip parseDynamicFlags flags +#if __GLASGOW_HASKELL__ >= 901 + logger <- getLogger + let parseDynamicFlags' = parseDynamicFlags logger +#else + let parseDynamicFlags' = parseDynamicFlags +#endif + (dynflags, locSrcs, _) <- (setHaddockMode `fmap` getSessionDynFlags) >>= (`parseDynamicFlags'` flags) _ <- setSessionDynFlags dynflags -- We basically do the same thing as `ghc/Main.hs` to distinguish @@ -83,7 +103,11 @@ #else setHaddockMode dynflags = (gopt_set dynflags Opt_Haddock) { #endif +#if __GLASGOW_HASKELL__ >= 901 + backend = NoBackend +#else hscTarget = HscNothing +#endif , ghcMode = CompManager , ghcLink = NoLink } diff -Nru haskell-doctest-0.16.3/src/Location.hs haskell-doctest-0.18.2/src/Location.hs --- haskell-doctest-0.16.3/src/Location.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Location.hs 2001-09-09 01:46:40.000000000 +0000 @@ -2,9 +2,16 @@ module Location where import Control.DeepSeq (deepseq, NFData(rnf)) + +#if __GLASGOW_HASKELL__ < 900 import SrcLoc hiding (Located) import qualified SrcLoc as GHC import FastString (unpackFS) +#else +import GHC.Types.SrcLoc hiding (Located) +import qualified GHC.Types.SrcLoc as GHC +import GHC.Data.FastString (unpackFS) +#endif #if __GLASGOW_HASKELL__ < 702 import Outputable (showPpr) @@ -60,8 +67,12 @@ | otherwise = (UnhelpfulLocation . showPpr) start where start = srcSpanStart loc -#else +#elif __GLASGOW_HASKELL__ < 900 toLocation loc = case loc of UnhelpfulSpan str -> UnhelpfulLocation (unpackFS str) RealSrcSpan sp -> Location (unpackFS . srcSpanFile $ sp) (srcSpanStartLine sp) +#else +toLocation loc = case loc of + UnhelpfulSpan str -> UnhelpfulLocation (unpackFS $ unhelpfulSpanFS str) + RealSrcSpan sp _ -> Location (unpackFS . srcSpanFile $ sp) (srcSpanStartLine sp) #endif diff -Nru haskell-doctest-0.16.3/src/Options.hs haskell-doctest-0.18.2/src/Options.hs --- haskell-doctest-0.16.3/src/Options.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Options.hs 2001-09-09 01:46:40.000000000 +0000 @@ -18,12 +18,22 @@ import Prelude () import Prelude.Compat -import Data.List.Compat -import Data.Maybe +import Control.Monad.Trans.RWS (RWS, execRWS) +import qualified Control.Monad.Trans.RWS as RWS + +import Control.Monad (when) +import Data.List.Compat (intercalate, stripPrefix) +import Data.Monoid (Endo (Endo)) import qualified Paths_doctest import Data.Version (showVersion) + +#if __GLASGOW_HASKELL__ < 900 import Config as GHC +#else +import GHC.Settings.Config as GHC +#endif + import Interpreter (ghc) usage :: String @@ -89,40 +99,79 @@ defaultVerbose :: Bool defaultVerbose = False +defaultRun :: Run +defaultRun = Run { + runWarnings = [] +, runOptions = [] +, runMagicMode = defaultMagic +, runFastMode = defaultFastMode +, runPreserveIt = defaultPreserveIt +, runVerbose = defaultVerbose +} + +modifyWarnings :: ([String] -> [String]) -> Run -> Run +modifyWarnings f run = run { runWarnings = f (runWarnings run) } + +setOptions :: [String] -> Run -> Run +setOptions opts run = run { runOptions = opts } + +setMagicMode :: Bool -> Run -> Run +setMagicMode magic run = run { runMagicMode = magic } + +setFastMode :: Bool -> Run -> Run +setFastMode fast run = run { runFastMode = fast } + +setPreserveIt :: Bool -> Run -> Run +setPreserveIt preserveIt run = run { runPreserveIt = preserveIt } + +setVerbose :: Bool -> Run -> Run +setVerbose verbose run = run { runVerbose = verbose } + parseOptions :: [String] -> Result Run parseOptions args | "--help" `elem` args = Output usage | "--info" `elem` args = Output info | "--version" `elem` args = Output versionInfo - | otherwise = case fmap (fmap (fmap stripOptGhc)) - . fmap (fmap stripVerbose) - . fmap stripPreserveIt - . stripFast - <$> stripNoMagic args of - (magicMode, (fastMode, (preserveIt, (verbose, (warning, xs))))) -> - Result (Run (maybeToList warning) xs magicMode fastMode preserveIt verbose) - -stripNoMagic :: [String] -> (Bool, [String]) -stripNoMagic = stripFlag (not defaultMagic) "--no-magic" - -stripFast :: [String] -> (Bool, [String]) -stripFast = stripFlag (not defaultFastMode) "--fast" - -stripPreserveIt :: [String] -> (Bool, [String]) -stripPreserveIt = stripFlag (not defaultPreserveIt) "--preserve-it" - -stripVerbose :: [String] -> (Bool, [String]) -stripVerbose = stripFlag (not defaultVerbose) "--verbose" - -stripFlag :: Bool -> String -> [String] -> (Bool, [String]) -stripFlag enableIt flag args = ((flag `elem` args) == enableIt, filter (/= flag) args) - -stripOptGhc :: [String] -> (Maybe Warning, [String]) -stripOptGhc = go + | otherwise = case execRWS parse () args of + (xs, Endo setter) -> + Result (setOptions xs $ setter defaultRun) + where + parse :: RWS () (Endo Run) [String] () + parse = do + stripNoMagic + stripFast + stripPreserveIt + stripVerbose + stripOptGhc + +stripNoMagic :: RWS () (Endo Run) [String] () +stripNoMagic = stripFlag (setMagicMode False) "--no-magic" + +stripFast :: RWS () (Endo Run) [String] () +stripFast = stripFlag (setFastMode True) "--fast" + +stripPreserveIt :: RWS () (Endo Run) [String] () +stripPreserveIt = stripFlag (setPreserveIt True) "--preserve-it" + +stripVerbose :: RWS () (Endo Run) [String] () +stripVerbose = stripFlag (setVerbose True) "--verbose" + +stripFlag :: (Run -> Run) -> String -> RWS () (Endo Run) [String] () +stripFlag setter flag = do + args <- RWS.get + when (flag `elem` args) $ + RWS.tell (Endo setter) + RWS.put (filter (/= flag) args) + +stripOptGhc :: RWS () (Endo Run) [String] () +stripOptGhc = do + issueWarning <- RWS.state go + when issueWarning $ + RWS.tell $ Endo $ modifyWarnings (++ [warning]) where go args = case args of - [] -> (Nothing, []) - "--optghc" : opt : rest -> (Just warning, opt : snd (go rest)) - opt : rest -> maybe (fmap (opt :)) (\x (_, xs) -> (Just warning, x : xs)) (stripPrefix "--optghc=" opt) (go rest) + [] -> (False, []) + "--optghc" : opt : rest -> (True, opt : snd (go rest)) + opt : rest -> maybe (fmap (opt :)) (\x (_, xs) -> (True, x : xs)) (stripPrefix "--optghc=" opt) (go rest) warning = "WARNING: --optghc is deprecated, doctest now accepts arbitrary GHC options\ndirectly." diff -Nru haskell-doctest-0.16.3/src/PackageDBs.hs haskell-doctest-0.18.2/src/PackageDBs.hs --- haskell-doctest-0.16.3/src/PackageDBs.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/PackageDBs.hs 2001-09-09 01:46:40.000000000 +0000 @@ -12,9 +12,6 @@ import System.Environment (getEnvironment) import System.FilePath (splitSearchPath, searchPathSeparator) -import qualified Sandbox -import Control.Exception (try, SomeException) -import System.Directory (getCurrentDirectory) -- | Full stack of GHC package databases data PackageDBs = PackageDBs @@ -55,30 +52,16 @@ buildArgStyle = Pre76 #endif --- | Determine the PackageDBs based on the environment and cabal sandbox --- information +-- | Determine the PackageDBs based on the environment. getPackageDBsFromEnv :: IO PackageDBs getPackageDBsFromEnv = do env <- getEnvironment - case () of + return $ case () of () - | Just sandboxes <- lookup "HASKELL_PACKAGE_SANDBOXES" env - -> return $ fromEnvMulti sandboxes - | Just extra <- lookup "HASKELL_PACKAGE_SANDBOX" env - -> return PackageDBs - { includeUser = True - , includeGlobal = True - , extraDBs = [extra] - } - | Just sandboxes <- lookup "GHC_PACKAGE_PATH" env - -> return $ fromEnvMulti sandboxes - | otherwise -> do - eres <- try $ getCurrentDirectory - >>= Sandbox.getSandboxConfigFile - >>= Sandbox.getPackageDbDir - return $ case eres :: Either SomeException FilePath of - Left _ -> PackageDBs True True [] - Right db -> PackageDBs False True [db] + | Just packageDBs <- lookup "GHC_PACKAGE_PATH" env + -> fromEnvMulti packageDBs + | otherwise + -> PackageDBs True True [] where fromEnvMulti s = PackageDBs { includeUser = False diff -Nru haskell-doctest-0.16.3/src/Parse.hs haskell-doctest-0.18.2/src/Parse.hs --- haskell-doctest-0.16.3/src/Parse.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Parse.hs 2001-09-09 01:46:40.000000000 +0000 @@ -18,7 +18,7 @@ ) where import Data.Char (isSpace) -import Data.List +import Data.List (isPrefixOf, stripPrefix) import Data.Maybe import Data.String #if __GLASGOW_HASKELL__ < 710 diff -Nru haskell-doctest-0.16.3/src/Run.hs haskell-doctest-0.18.2/src/Run.hs --- haskell-doctest-0.16.3/src/Run.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Run.hs 2001-09-09 01:46:40.000000000 +0000 @@ -20,7 +20,12 @@ import System.IO.CodePage (withCP65001) import qualified Control.Exception as E + +#if __GLASGOW_HASKELL__ < 900 import Panic +#else +import GHC.Utils.Panic +#endif import PackageDBs import Parse diff -Nru haskell-doctest-0.16.3/src/Runner/Example.hs haskell-doctest-0.18.2/src/Runner/Example.hs --- haskell-doctest-0.16.3/src/Runner/Example.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Runner/Example.hs 2001-09-09 01:46:40.000000000 +0000 @@ -4,7 +4,7 @@ ) where import Data.Char -import Data.List +import Data.List (isPrefixOf) import Util import Parse diff -Nru haskell-doctest-0.16.3/src/Sandbox.hs haskell-doctest-0.18.2/src/Sandbox.hs --- haskell-doctest-0.16.3/src/Sandbox.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/src/Sandbox.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -{-# LANGUAGE CPP, BangPatterns #-} - -module Sandbox - ( getSandboxArguments - , getPackageDbDir - , getSandboxConfigFile - ) where - -#if __GLASGOW_HASKELL__ < 710 -import Data.Functor ((<$>)) -#endif -import Control.Exception as E (catch, SomeException, throwIO) -import Data.Char (isSpace) -import Data.List (isPrefixOf, tails) -import System.Directory (getCurrentDirectory, doesFileExist) -import System.FilePath ((), takeDirectory, takeFileName) - -configFile :: String -configFile = "cabal.sandbox.config" - -pkgDbKey :: String -pkgDbKey = "package-db:" - -pkgDbKeyLen :: Int -pkgDbKeyLen = length pkgDbKey - -getSandboxArguments :: IO [String] -getSandboxArguments = (sandboxArguments <$> getPkgDb) `E.catch` handler - where - getPkgDb = getCurrentDirectory >>= getSandboxConfigFile >>= getPackageDbDir - handler :: SomeException -> IO [String] - handler _ = return [] - --- | Find a sandbox config file by tracing ancestor directories. --- Exception is thrown if not found -getSandboxConfigFile :: FilePath -> IO FilePath -getSandboxConfigFile dir = do - let cfile = dir configFile - exist <- doesFileExist cfile - if exist then - return cfile - else do - let dir' = takeDirectory dir - if dir == dir' then - throwIO $ userError "sandbox config file not found" - else - getSandboxConfigFile dir' - --- | Extract a package db directory from the sandbox config file. --- Exception is thrown if the sandbox config file is broken. -getPackageDbDir :: FilePath -> IO FilePath -getPackageDbDir sconf = do - -- Be strict to ensure that an error can be caught. - !path <- extractValue . parse <$> readFile sconf - return path - where - parse = head . filter ("package-db:" `isPrefixOf`) . lines - extractValue = fst . break isSpace . dropWhile isSpace . drop pkgDbKeyLen - --- | Adding necessary GHC options to the package db. --- Exception is thrown if the string argument is incorrect. --- --- >>> sandboxArguments "/foo/bar/i386-osx-ghc-7.6.3-packages.conf.d" --- ["-no-user-package-db","-package-db","/foo/bar/i386-osx-ghc-7.6.3-packages.conf.d"] --- >>> sandboxArguments "/foo/bar/i386-osx-ghc-7.4.1-packages.conf.d" --- ["-no-user-package-conf","-package-conf","/foo/bar/i386-osx-ghc-7.4.1-packages.conf.d"] -sandboxArguments :: FilePath -> [String] -sandboxArguments pkgDb = [noUserPkgDbOpt, pkgDbOpt, pkgDb] - where - ver = extractGhcVer pkgDb - (pkgDbOpt,noUserPkgDbOpt) - | ver < 706 = ("-package-conf","-no-user-package-conf") - | otherwise = ("-package-db", "-no-user-package-db") - --- | Extracting GHC version from the path of package db. --- Exception is thrown if the string argument is incorrect. --- --- >>> extractGhcVer "/foo/bar/i386-osx-ghc-7.6.3-packages.conf.d" --- 706 -extractGhcVer :: String -> Int -extractGhcVer dir = ver - where - file = takeFileName dir - findVer = drop 4 . head . filter ("ghc-" `isPrefixOf`) . tails - (verStr1,_:left) = break (== '.') $ findVer file - (verStr2,_) = break (== '.') left - ver = read verStr1 * 100 + read verStr2 diff -Nru haskell-doctest-0.16.3/test/extract/th/Bar.hs haskell-doctest-0.18.2/test/extract/th/Bar.hs --- haskell-doctest-0.16.3/test/extract/th/Bar.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/extract/th/Bar.hs 2001-09-09 01:46:40.000000000 +0000 @@ -1,4 +1,8 @@ {-# LANGUAGE TemplateHaskell #-} + module Bar where -bar = [|23|] +import Language.Haskell.TH.Lib (ExpQ) + +bar :: ExpQ +bar = [| 23 |] diff -Nru haskell-doctest-0.16.3/test/ExtractSpec.hs haskell-doctest-0.18.2/test/ExtractSpec.hs --- haskell-doctest-0.16.3/test/ExtractSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/ExtractSpec.hs 2001-09-09 01:46:40.000000000 +0000 @@ -1,11 +1,18 @@ -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE FlexibleContexts #-} + module ExtractSpec (main, spec) where import Test.Hspec import Test.HUnit + +#if __GLASGOW_HASKELL__ < 900 import Panic (GhcException (..)) +#else +import GHC.Utils.Panic (GhcException (..)) +#endif import Extract import Location diff -Nru haskell-doctest-0.16.3/test/integration/local-stderr-binding/A.hs haskell-doctest-0.18.2/test/integration/local-stderr-binding/A.hs --- haskell-doctest-0.16.3/test/integration/local-stderr-binding/A.hs 1970-01-01 00:00:00.000000000 +0000 +++ haskell-doctest-0.18.2/test/integration/local-stderr-binding/A.hs 2001-09-09 01:46:40.000000000 +0000 @@ -0,0 +1,11 @@ +module A where + +stderr :: Bool +stderr = True + +stdout :: String +stdout = "hello" + +-- | +-- >>> 3 + 3 +-- 6 diff -Nru haskell-doctest-0.16.3/test/integration/system-io-imported/A.hs haskell-doctest-0.18.2/test/integration/system-io-imported/A.hs --- haskell-doctest-0.16.3/test/integration/system-io-imported/A.hs 1970-01-01 00:00:00.000000000 +0000 +++ haskell-doctest-0.18.2/test/integration/system-io-imported/A.hs 2001-09-09 01:46:40.000000000 +0000 @@ -0,0 +1,10 @@ +module A where + +import System.IO + +-- ghci-wrapper needs to poke around with System.IO itself, and unloads the module once it's done. Test to make sure legitimate uses of System.IO don't get lost in the wash. + +-- | +-- >>> ReadMode +-- ReadMode + diff -Nru haskell-doctest-0.16.3/test/LocationSpec.hs haskell-doctest-0.18.2/test/LocationSpec.hs --- haskell-doctest-0.16.3/test/LocationSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/LocationSpec.hs 2001-09-09 01:46:40.000000000 +0000 @@ -1,10 +1,18 @@ +{-# LANGUAGE CPP #-} + module LocationSpec (main, spec) where import Test.Hspec import Location + +#if __GLASGOW_HASKELL__ < 900 import SrcLoc import FastString (fsLit) +#else +import GHC.Types.SrcLoc +import GHC.Data.FastString (fsLit) +#endif main :: IO () main = hspec spec diff -Nru haskell-doctest-0.16.3/test/MainSpec.hs haskell-doctest-0.18.2/test/MainSpec.hs --- haskell-doctest-0.16.3/test/MainSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/MainSpec.hs 2001-09-09 01:46:40.000000000 +0000 @@ -106,9 +106,18 @@ doctest "setup-skip-on-failure" ["Foo.hs"] (cases 3) {sTried = 1, sFailures = 1} - it "works with additional object files" $ do - doctest "with-cbits" ["Bar.hs", "../../../dist/build/spec/spec-tmp/test/integration/with-cbits/foo.o"] - (cases 1) + -- Andreas, 2021-02-27, see issue #294. + -- This test case contains a hard-wired path that does not work + -- with v2-cabal. + -- I tested it under v2-cabal with a very non-portable path. + -- Deactivating the test case until a systematic solution is found... + -- + -- it "works with additional object files" $ do + -- -- -- Path for v1-cabal: + -- -- doctest "with-cbits" ["Bar.hs", "../../../dist/build/spec/spec-tmp/test/integration/with-cbits/foo.o"] + -- -- -- Path for v2-cabal with ghc-9.0.1 + -- -- doctest "with-cbits" ["Bar.hs", "../../../dist-newstyle/build/x86_64-osx/ghc-9.0.1/doctest-0.19/t/spec/build/spec/spec-tmp/Test/integration/with-cbits/foo.o"] + -- (cases 1) it "ignores trailing whitespace when matching test output" $ do doctest "trailing-whitespace" ["Foo.hs"] @@ -167,3 +176,11 @@ it "template-haskell-bugfix" $ do doctest "template-haskell-bugfix" ["Main.hs"] (cases 2) + + it "doesn't clash with user bindings of stdout/stderr" $ do + doctest "local-stderr-binding" ["A.hs"] + (cases 1) + + it "doesn't get confused by doctests using System.IO imports" $ do + doctest "system-io-imported" ["A.hs"] + (cases 1) diff -Nru haskell-doctest-0.16.3/test/PackageDBsSpec.hs haskell-doctest-0.18.2/test/PackageDBsSpec.hs --- haskell-doctest-0.16.3/test/PackageDBsSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/PackageDBsSpec.hs 2001-09-09 01:46:40.000000000 +0000 @@ -6,7 +6,6 @@ import qualified Control.Exception as E import Data.List (intercalate) import PackageDBs -import System.Directory (getCurrentDirectory, setCurrentDirectory) import System.Environment.Compat import System.FilePath (searchPathSeparator) import Test.Hspec @@ -16,12 +15,6 @@ main :: IO () main = hspec spec -withCurrentDirectory :: FilePath -> IO a -> IO a -withCurrentDirectory workingDir action = do - E.bracket getCurrentDirectory setCurrentDirectory $ \_ -> do - setCurrentDirectory workingDir - action - withEnv :: String -> String -> IO a -> IO a withEnv k v action = E.bracket save restore $ \_ -> do setEnv k v >> action @@ -32,8 +25,6 @@ clearEnv :: IO a -> IO a clearEnv = withEnv "GHC_PACKAGE_PATH" "" - . withEnv "HASKELL_PACKAGE_SANDBOX" "" - . withEnv "HASKELL_PACKAGE_SANDBOXES" "" combineDirs :: [FilePath] -> String combineDirs = intercalate [searchPathSeparator] @@ -41,33 +32,10 @@ spec :: Spec spec = around_ clearEnv $ do describe "getPackageDBsFromEnv" $ do - context "without a cabal sandbox present" $ do - around_ (inTempDirectory) $ do - it "uses global and user when no env or sandboxing used" $ do - getPackageDBsFromEnv `shouldReturn` PackageDBs True True [] - - it "respects GHC_PACKAGE_PATH" $ - withEnv "GHC_PACKAGE_PATH" (combineDirs ["foo", "bar", ""]) $ do - getPackageDBsFromEnv `shouldReturn` PackageDBs False True ["foo", "bar"] - - it "HASKELL_PACKAGE_SANDBOXES trumps GHC_PACKAGE_PATH" $ - withEnv "GHC_PACKAGE_PATH" (combineDirs ["foo1", "bar1", ""]) $ do - withEnv "HASKELL_PACKAGE_SANDBOXES" (combineDirs ["foo2", "bar2", ""]) $ do - getPackageDBsFromEnv `shouldReturn` PackageDBs False True ["foo2", "bar2"] - - it "HASKELL_PACKAGE_SANDBOX trumps GHC_PACKAGE_PATH" $ - withEnv "GHC_PACKAGE_PATH" (combineDirs ["foo1", "bar1", ""]) $ do - withEnv "HASKELL_PACKAGE_SANDBOX" (combineDirs ["foo2"]) $ do - - getPackageDBsFromEnv `shouldReturn` PackageDBs True True ["foo2"] - - context "with a cabal sandbox present" $ do - around_ (withCurrentDirectory "test/sandbox") $ do - it "respects cabal sandboxes" $ do - getPackageDBsFromEnv `shouldReturn` - PackageDBs False True ["/home/me/doctest-haskell/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d"] - - it "GHC_PACKAGE_PATH takes precedence" $ - withEnv "GHC_PACKAGE_PATH" (combineDirs ["foo", "bar"]) $ do - getPackageDBsFromEnv `shouldReturn` - PackageDBs False False ["foo", "bar"] + around_ (inTempDirectory) $ do + it "uses global and user when no env used" $ do + getPackageDBsFromEnv `shouldReturn` PackageDBs True True [] + + it "respects GHC_PACKAGE_PATH" $ + withEnv "GHC_PACKAGE_PATH" (combineDirs ["foo", "bar", ""]) $ do + getPackageDBsFromEnv `shouldReturn` PackageDBs False True ["foo", "bar"] diff -Nru haskell-doctest-0.16.3/test/RunSpec.hs haskell-doctest-0.18.2/test/RunSpec.hs --- haskell-doctest-0.16.3/test/RunSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/RunSpec.hs 2001-09-09 01:46:40.000000000 +0000 @@ -8,15 +8,8 @@ import System.Exit import qualified Control.Exception as E -#if __GLASGOW_HASKELL__ < 707 -import System.Cmd -#else -import System.Process -#endif -import System.Directory (getCurrentDirectory, setCurrentDirectory, removeDirectoryRecursive) -import Data.List.Compat - -import System.Environment.Compat +import System.Directory (getCurrentDirectory, setCurrentDirectory) +import Data.List.Compat (isPrefixOf, sort) import System.IO.Silently import System.IO (stderr) @@ -33,16 +26,6 @@ setCurrentDirectory workingDir action -rmDir :: FilePath -> IO () -rmDir dir = removeDirectoryRecursive dir `E.catch` (const $ return () :: E.IOException -> IO ()) - -withEnv :: String -> String -> IO a -> IO a -withEnv k v action = E.bracket save restore $ \_ -> do - setEnv k v >> action - where - save = lookup k <$> getEnvironment - restore = maybe (unsetEnv k) (setEnv k) - main :: IO () main = hspec spec @@ -81,22 +64,6 @@ , "Try `doctest --help' for more information." ] - it "respects HASKELL_PACKAGE_SANDBOX" $ do - withCurrentDirectory "test/integration/custom-package-conf/foo" $ do - ExitSuccess <- rawSystem "ghc-pkg" ["init", "../packages"] - ExitSuccess <- rawSystem "cabal" ["v1-configure", "--disable-optimization", "--disable-library-profiling", "--package-db=../packages"] - ExitSuccess <- rawSystem "cabal" ["v1-build"] - ExitSuccess <- rawSystem "cabal" ["v1-register", "--inplace"] - return () - - withEnv "HASKELL_PACKAGE_SANDBOX" "test/integration/custom-package-conf/packages" $ do - hCapture_ [stderr] (doctest ["test/integration/custom-package-conf/Bar.hs"]) - `shouldReturn` "Examples: 2 Tried: 2 Errors: 0 Failures: 0\n" - - `E.finally` do - rmDir "test/integration/custom-package-conf/packages/" - rmDir "test/integration/custom-package-conf/foo/dist/" - it "prints verbose description of a specification" $ do (r, ()) <- hCapture [stderr] $ doctest ["--verbose", "test/integration/testSimple/Fib.hs"] r `shouldBe` unlines [ diff -Nru haskell-doctest-0.16.3/test/sandbox/bad.config haskell-doctest-0.18.2/test/sandbox/bad.config --- haskell-doctest-0.16.3/test/sandbox/bad.config 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/sandbox/bad.config 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -broken \ No newline at end of file diff -Nru haskell-doctest-0.16.3/test/sandbox/cabal.sandbox.config haskell-doctest-0.18.2/test/sandbox/cabal.sandbox.config --- haskell-doctest-0.16.3/test/sandbox/cabal.sandbox.config 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/sandbox/cabal.sandbox.config 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ --- This is a Cabal package environment file. --- THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY. --- Please create a 'cabal.config' file in the same directory --- if you want to change the default settings for this sandbox. - - -local-repo: /home/me/doctest-haskell/.cabal-sandbox/packages -logs-dir: /home/me/doctest-haskell/.cabal-sandbox/logs -world-file: /home/me/doctest-haskell/.cabal-sandbox/world -user-install: False -package-db: /home/me/doctest-haskell/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d -build-summary: /home/me/doctest-haskell/.cabal-sandbox/logs/build.log - -install-dirs - prefix: /home/me/doctest-haskell/.cabal-sandbox - bindir: $prefix/bin - libdir: $prefix/lib - libsubdir: $arch-$os-$compiler/$pkgid - libexecdir: $prefix/libexec - datadir: $prefix/share - datasubdir: $arch-$os-$compiler/$pkgid - docdir: $datadir/doc/$arch-$os-$compiler/$pkgid - htmldir: $docdir/html - haddockdir: $htmldir - sysconfdir: $prefix/etc diff -Nru haskell-doctest-0.16.3/test/SandboxSpec.hs haskell-doctest-0.18.2/test/SandboxSpec.hs --- haskell-doctest-0.16.3/test/SandboxSpec.hs 2001-09-09 01:46:40.000000000 +0000 +++ haskell-doctest-0.18.2/test/SandboxSpec.hs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -module SandboxSpec where - -import Test.Hspec - -import Sandbox - -main :: IO () -main = hspec spec - -spec :: Spec -spec = do - describe "getPackageDbDir" $ do - it "parses a config file and extracts package db" $ do - pkgDb <- getPackageDbDir "test/sandbox/cabal.sandbox.config" - pkgDb `shouldBe` "/home/me/doctest-haskell/.cabal-sandbox/i386-osx-ghc-7.6.3-packages.conf.d" - - it "throws an error if a config file is broken" $ do - getPackageDbDir "test/sandbox/bad.config" `shouldThrow` anyException