Skip to content

Commit

Permalink
Allow passing extra arguments to the doctest test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
mmhat committed Aug 20, 2023
1 parent ab3b42a commit 983e987
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
13 changes: 9 additions & 4 deletions dhall-docs/doctest/Main.hs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
module Main where
module Main (main) where

import System.FilePath ((</>))

import qualified GHC.IO.Encoding
import qualified System.Directory
import qualified System.Environment
import qualified System.IO
import qualified Test.DocTest

main :: IO ()
main = do
GHC.IO.Encoding.setLocaleEncoding System.IO.utf8
pwd <- System.Directory.getCurrentDirectory
args <- System.Environment.getArgs
pwd <- System.Directory.getCurrentDirectory
prefix <- System.Directory.makeAbsolute pwd
Test.DocTest.doctest
let src = prefix </> "src"

Test.DocTest.doctest $
[ "--fast"
, prefix </> "src"
] <> args <>
[ src
]
15 changes: 9 additions & 6 deletions dhall-lsp-server/doctest/Main.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
module Main where
module Main (main) where

import System.FilePath ((</>))

import qualified GHC.IO.Encoding
import qualified System.Directory
import qualified System.Environment
import qualified System.IO
import qualified Test.DocTest

main :: IO ()
main = do

GHC.IO.Encoding.setLocaleEncoding System.IO.utf8
pwd <- System.Directory.getCurrentDirectory
args <- System.Environment.getArgs
pwd <- System.Directory.getCurrentDirectory
prefix <- System.Directory.makeAbsolute pwd
let src = prefix </> "src"

Test.DocTest.doctest
Test.DocTest.doctest $
[ "--fast"
, "-XOverloadedStrings"
, "-XRecordWildCards"
, "-i" <> (prefix </> "src")
, prefix </> "src/Dhall/LSP/Backend/Diagnostics.hs"
] <> args <>
[ "-i" <> src
, src </> "Dhall/LSP/Backend/Diagnostics.hs"
]
14 changes: 12 additions & 2 deletions dhall-toml/doctest/Main.hs
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
module Main where
module Main (main) where

import System.FilePath ((</>))

import qualified GHC.IO.Encoding
import qualified System.Directory
import qualified System.Environment
import qualified System.IO
import qualified Test.DocTest

main :: IO ()
main = do
GHC.IO.Encoding.setLocaleEncoding System.IO.utf8
args <- System.Environment.getArgs
pwd <- System.Directory.getCurrentDirectory
prefix <- System.Directory.makeAbsolute pwd
let src = prefix </> "src"
Test.DocTest.doctest [ "--fast", "-i" <> src, src ]

Test.DocTest.doctest $
[ "--fast"
] <> args <>
[ "-i" <> src
, src
]
22 changes: 12 additions & 10 deletions dhall/doctest/Main.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}

module Main where
module Main (main) where

import System.FilePath ((</>))

Expand All @@ -13,10 +13,11 @@ import qualified Test.Mockery.Directory

main :: IO ()
main = do

GHC.IO.Encoding.setLocaleEncoding System.IO.utf8
pwd <- System.Directory.getCurrentDirectory
args <- System.Environment.getArgs
pwd <- System.Directory.getCurrentDirectory
prefix <- System.Directory.makeAbsolute pwd
let src = prefix </> "src"

System.Environment.setEnv "XDG_CACHE_HOME" (pwd </> ".cache")

Expand All @@ -34,11 +35,12 @@ main = do
, "in { name = \"Simon\", favoriteFont = Font.`Comic Sans` } : Person"
]

Test.DocTest.doctest
Test.DocTest.doctest $
[ "-DWITH_HTTP"
, "-DUSE_HTTP_CLIENT_TLS"
, "--fast"
, prefix </> "ghc-src"
] <> args <>
[ prefix </> "ghc-src"

-- Unfortunately we cannot target the entire @src@ directory.
-- The reason is that src/Dhall/Version.hs depends on
Expand All @@ -47,11 +49,11 @@ main = do
-- Instead, we target a selection of modules whose combined module
-- dependency tree covers all modules that contain doctests.

-- , prefix </> "src"
, "-i" <> (prefix </> "src")
-- , src
, "-i" <> src
#if __GLASGOW_HASKELL__ >= 806
, prefix </> "src/Dhall/Deriving.hs"
, src </> "Dhall/Deriving.hs"
#endif
, prefix </> "src/Dhall/Tags.hs"
, prefix </> "src/Dhall/Tutorial.hs"
, src </> "Dhall/Tags.hs"
, src </> "Dhall/Tutorial.hs"
]

0 comments on commit 983e987

Please sign in to comment.