Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandbox build support #39

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Data.List
import Control.Monad (when)
import System.Exit (exitFailure)
import System.IO
import System.Environment (getEnvironment)

import qualified Control.Exception as E
import Panic
Expand All @@ -35,11 +36,20 @@ doctest args
| "--help" `elem` args = putStr usage
| "--version" `elem` args = printVersion
| otherwise = do
-- Look up the PACKAGE_SANDBOX environment variable and, if present, add
-- it to the list of package databases GHC searches. Intended to make
-- testing from inside sandboxes such as cabal-dev simpler.
env <- getEnvironment
let addPackageConf =
case lookup "PACKAGE_SANDBOX" env of
Nothing -> id
Just p -> \rest -> "-package-conf" : p : rest

let (f, args_) = stripOptGhc args
when f $ do
hPutStrLn stderr "WARNING: --optghc is deprecated, doctest now accepts arbitrary GHC options\ndirectly."
hFlush stderr
r <- doctest_ args_ `E.catch` \e -> do
r <- doctest_ (addPackageConf args_) `E.catch` \e -> do
case fromException e of
Just (UsageError err) -> do
hPutStrLn stderr ("doctest: " ++ err)
Expand Down