Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Jul 15, 2024
1 parent 9e49571 commit 8924b98
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
12 changes: 8 additions & 4 deletions doctest.cabal

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions driver/cabal.hs
Original file line number Diff line number Diff line change
@@ -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
12 changes: 5 additions & 7 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -63,6 +64,7 @@ library:
process:
ghc-paths: ">= 0.1.0.9"
transformers:
temporary:

flags:
cabal-doctest:
Expand All @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions driver/cabal-doctest.hs → src/Cabal.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Main (main) where
module Cabal (externalCommand) where

import Prelude
import Imports

import Data.Version
import System.Environment
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/Test/DocTest/Internal/Cabal.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Test.DocTest.Internal.Cabal (
doctest
) where

import Imports

import qualified Cabal

doctest :: [String] -> IO ()
doctest = Cabal.externalCommand

0 comments on commit 8924b98

Please sign in to comment.