From 9b3f3468079765c593ad6ed7d7a9c701a33fdadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Mon, 18 Sep 2017 12:27:45 +0200 Subject: [PATCH] Fix doctest with Cabal-2.0 by requiring c-i>=1.24 --- .gitlab-ci.yml | 5 ++--- Setup.hs | 20 +++++++++++++++++--- ghc-mod.cabal | 10 +++++++--- test/doctests.hs | 25 +++++++------------------ 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bce8266..4a8c8df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,9 +5,10 @@ stages: before_script: - ls -l .. - apt-get update && apt-get install alex happy + - ghc-pkg list + - cabal update && cabal install --only-dependencies -j2 --enable-tests --enable-documentation - mkdir -p ../ghc-mod.sdist-$CI_PIPELINE_ID - touch ChangeLog - - cabal update - cabal sdist --output-directory=../ghc-mod.sdist-$CI_PIPELINE_ID - cd ../ghc-mod.sdist-$CI_PIPELINE_ID @@ -19,8 +20,6 @@ after_script: .script_template: &common_script script: - echo $PWD - - ghc-pkg list - - cabal install --user --only-dependencies -j2 --force-reinstalls --upgrade-dependencies --enable-tests --enable-documentation - which cabal - cabal --version - cabal configure --enable-tests diff --git a/Setup.hs b/Setup.hs index 93acc07..f671ab2 100755 --- a/Setup.hs +++ b/Setup.hs @@ -1,9 +1,23 @@ #!/usr/bin/env runhaskell +{-# LANGUAGE CPP #-} + +#ifndef MIN_VERSION_cabal_doctest +#error \ + Your version of cabal-install does not seem to support the 'custom-setup' section. \ + Please see https://github.com/DanielG/ghc-mod/wiki/Installing#checking-and-installing-prerequisites for instrutions on how to upgrade. \ + It is also possible that you forgot to install cabal-doctest before running Setup.hs +#endif + import Distribution.Simple import Distribution.Simple.Program +import Distribution.Extra.Doctest + main :: IO () -main = defaultMainWithHooks $ simpleUserHooks { - hookedPrograms = [ simpleProgram "shelltest" ] - } +main = + defaultMainWithHooks $ + addDoctestsUserHook "doctest" $ + simpleUserHooks { + hookedPrograms = [ simpleProgram "shelltest" ] + } diff --git a/ghc-mod.cabal b/ghc-mod.cabal index a3e34cb..d437a4f 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -24,7 +24,7 @@ Description: Category: GHC, Development -Cabal-Version: >= 1.18 +Cabal-Version: >= 1.24 Build-Type: Custom Data-Files: elisp/Makefile elisp/*.el @@ -92,7 +92,8 @@ Extra-Source-Files: ChangeLog Custom-Setup Setup-Depends: base - , Cabal >= 1.18 && < 2.1 + , Cabal < 2.1 && >= 1.24 + , cabal-doctest < 1.1 && >= 1 , containers , filepath , directory @@ -273,7 +274,10 @@ Test-Suite doctest Main-Is: doctests.hs Build-Depends: base < 4.11 && >= 4.6.0.1 , doctest < 0.12 && >= 0.9.3 - + , directory + , ghc + , mtl + , transformers Test-Suite spec Default-Language: Haskell2010 diff --git a/test/doctests.hs b/test/doctests.hs index a85e0ee..1a48779 100644 --- a/test/doctests.hs +++ b/test/doctests.hs @@ -1,23 +1,12 @@ -{-# LANGUAGE CPP #-} module Main where -import Test.DocTest -import System.Environment -import Data.Maybe +import Build_doctests (flags, pkgs, module_sources) +import Data.Foldable (traverse_) +import Test.DocTest (doctest) main :: IO () main = do - distdir <- (fromMaybe "dist" . lookup "DOCTEST_DIST_DIR") `fmap` getEnvironment - doctest - [ "-package", "ghc-" ++ VERSION_ghc - , "-package", "transformers-" ++ VERSION_transformers - , "-package", "mtl-" ++ VERSION_mtl - , "-package", "directory-" ++ VERSION_directory - , "-XScopedTypeVariables", "-XRecordWildCards", "-XNamedFieldPuns", "-XConstraintKinds", "-XFlexibleContexts", "-XDataKinds", "-XKindSignatures", "-XTypeOperators", "-XViewPatterns" - , "-i" ++ distdir ++ "/build/autogen/" - , "-icore/" - , "-ishared" --- , "-optP-include" --- , "-optP" ++ distdir ++ "/build/autogen/cabal_macros.h" - , "GhcMod.hs" - ] + traverse_ putStrLn args -- optionally print arguments + doctest args + where + args = flags ++ pkgs ++ module_sources