diff --git a/doctest.cabal b/doctest.cabal index 7861d1ff..b9b6a9fe 100644 --- a/doctest.cabal +++ b/doctest.cabal @@ -127,7 +127,9 @@ library Test.DocTest.Internal.Location Test.DocTest.Internal.Parse Test.DocTest.Internal.Run + Test.DocTest.Internal.Cabal other-modules: + Cabal Extract GhcUtil Imports @@ -155,6 +157,7 @@ library , ghc-paths >=0.1.0.9 , process , syb >=0.3 + , temporary , transformers default-language: Haskell2010 if impl(ghc >= 9.0) @@ -163,7 +166,7 @@ library ghc-options: -fno-warn-x-partial executable cabal-doctest - main-is: driver/cabal-doctest.hs + main-is: driver/cabal.hs other-modules: Paths_doctest default-extensions: @@ -174,9 +177,7 @@ executable cabal-doctest ghc-options: -Wall -threaded build-depends: base >=4.7 && <5 - , filepath - , process - , temporary + , doctest default-language: Haskell2010 if impl(ghc >= 9.0) ghc-options: -fwarn-unused-packages @@ -223,6 +224,7 @@ test-suite spec RunnerSpec RunSpec UtilSpec + Cabal Extract GhcUtil Imports @@ -238,6 +240,7 @@ test-suite spec Runner Runner.Example Test.DocTest + Test.DocTest.Internal.Cabal Test.DocTest.Internal.Extract Test.DocTest.Internal.Location Test.DocTest.Internal.Parse @@ -277,6 +280,7 @@ test-suite spec , silently >=1.2.4 , stringbuilder >=0.4 , syb >=0.3 + , temporary , transformers default-language: Haskell2010 if impl(ghc >= 9.0) diff --git a/driver/cabal.hs b/driver/cabal.hs new file mode 100644 index 00000000..33f43f93 --- /dev/null +++ b/driver/cabal.hs @@ -0,0 +1,8 @@ +module Main (main) where + +import Prelude +import qualified Test.DocTest.Internal.Cabal as Cabal +import System.Environment (getArgs) + +main :: IO () +main = getArgs >>= Cabal.doctest diff --git a/package.yaml b/package.yaml index aa755ca5..1491adee 100644 --- a/package.yaml +++ b/package.yaml @@ -51,6 +51,7 @@ library: - Test.DocTest.Internal.Location - Test.DocTest.Internal.Parse - Test.DocTest.Internal.Run + - Test.DocTest.Internal.Cabal dependencies: &dependencies ghc: ">= 8.0 && < 9.12" @@ -63,6 +64,7 @@ library: process: ghc-paths: ">= 0.1.0.9" transformers: + temporary: flags: cabal-doctest: @@ -71,19 +73,15 @@ flags: default: false executables: - doctest: + doctest: &doctest main: driver/doctest.hs ghc-options: -threaded dependencies: - doctest cabal-doctest: - main: driver/cabal-doctest.hs - ghc-options: -threaded - dependencies: - - process - - filepath - - temporary + <<: *doctest + main: driver/cabal.hs when: condition: flag(cabal-doctest) then: diff --git a/driver/cabal-doctest.hs b/src/Cabal.hs similarity index 92% rename from driver/cabal-doctest.hs rename to src/Cabal.hs index 13691d59..2b3a0833 100644 --- a/driver/cabal-doctest.hs +++ b/src/Cabal.hs @@ -1,7 +1,7 @@ {-# LANGUAGE LambdaCase #-} -module Main (main) where +module Cabal (externalCommand) where -import Prelude +import Imports import Data.Version import System.Environment @@ -12,9 +12,6 @@ import System.Process import Paths_doctest (version) -main :: IO () -main = getArgs >>= externalCommand - externalCommand :: [String] -> IO () externalCommand args = do lookupEnv "CABAL" >>= \ case diff --git a/src/Test/DocTest/Internal/Cabal.hs b/src/Test/DocTest/Internal/Cabal.hs new file mode 100644 index 00000000..82b75806 --- /dev/null +++ b/src/Test/DocTest/Internal/Cabal.hs @@ -0,0 +1,10 @@ +module Test.DocTest.Internal.Cabal ( + doctest +) where + +import Imports + +import qualified Cabal + +doctest :: [String] -> IO () +doctest = Cabal.externalCommand