Skip to content

Commit

Permalink
Merge pull request #9518 from mpickering/wip/runghc-include
Browse files Browse the repository at this point in the history
Testsuite: pass -i argument to runghc invocations
  • Loading branch information
mergify[bot] committed Mar 8, 2024
2 parents b0f9d0b + b2b9c2f commit 2269835
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/SetupDep/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main where

import SetupDep ( depMain )

main :: IO ()
main = depMain
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/SetupDep/SetupDep.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module SetupDep where

import Distribution.Simple

depMain :: IO ()
depMain = defaultMain
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/SetupDep/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages: .
16 changes: 16 additions & 0 deletions cabal-testsuite/PackageTests/SetupDep/setup-dep.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cabal-version: 2.2
name: setup-dep
version: 0.1.0.0
synopsis: Test for a Setup.hs with a dependency
license: BSD-3-Clause
author: NA
maintainer: NA
category: Testing
build-type: Custom

custom-setup
setup-depends: Cabal, base

library
build-depends: base
default-language: Haskell2010
5 changes: 5 additions & 0 deletions cabal-testsuite/PackageTests/SetupDep/setup.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Setup configure
Configuring setup-dep-0.1.0.0...
# Setup build
Preprocessing library for setup-dep-0.1.0.0...
Building library for setup-dep-0.1.0.0...
4 changes: 4 additions & 0 deletions cabal-testsuite/PackageTests/SetupDep/setup.test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Test.Cabal.Prelude
main = setupTest $ do
setup "configure" []
setup "build" []
21 changes: 15 additions & 6 deletions cabal-testsuite/src/Test/Cabal/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,32 @@ runghc senv mb_cwd env_overrides script_path args = do
-- script with 'runghc'.
runnerCommand :: ScriptEnv -> Maybe FilePath -> [(String, Maybe String)]
-> FilePath -> [String] -> IO (FilePath, [String])
runnerCommand senv _mb_cwd _env_overrides script_path args = do
runnerCommand senv mb_cwd _env_overrides script_path args = do
(prog, _) <- requireProgram verbosity runghcProgram (runnerProgramDb senv)
return (programPath prog,
runghc_args ++ ["--"] ++ map ("--ghc-arg="++) ghc_args ++ [script_path] ++ args)
where
verbosity = runnerVerbosity senv
runghc_args = []
ghc_args = runnerGhcArgs senv
ghc_args = runnerGhcArgs senv mb_cwd

-- | Compute the GHC flags to invoke 'runghc' with under a 'ScriptEnv'.
runnerGhcArgs :: ScriptEnv -> [String]
runnerGhcArgs senv =
runnerGhcArgs :: ScriptEnv -> Maybe FilePath -> [String]
runnerGhcArgs senv mb_cwd =
renderGhcOptions (runnerCompiler senv) (runnerPlatform senv) ghc_options
where
ghc_options = M.mempty { ghcOptPackageDBs = runnerPackageDbStack senv
, ghcOptPackages = toNubListR (runnerPackages senv)
, ghcOptHideAllPackages = Flag True
-- Avoid picking stray module files that look
-- like our imports
, ghcOptSourcePathClear = Flag True }
-- like our imports...
, ghcOptSourcePathClear = Flag True
-- ... yet retain the current directory as an included
-- directory, e.g. so that we can compile a Setup.hs
-- script which imports a locally defined module.
-- See the PackageTests/SetupDep test.
, ghcOptSourcePath = toNubListR $
case mb_cwd of
Nothing -> []
Just wd -> [wd]
}
2 changes: 1 addition & 1 deletion cabal-testsuite/src/Test/Cabal/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ runMain ref m = do
startServer :: Chan ServerLogMsg -> ScriptEnv -> IO Server
startServer chan senv = do
(prog, _) <- requireProgram verbosity ghcProgram (runnerProgramDb senv)
let ghc_args = runnerGhcArgs senv ++ ["--interactive", "-v0", "-ignore-dot-ghci"]
let ghc_args = runnerGhcArgs senv Nothing ++ ["--interactive", "-v0", "-ignore-dot-ghci"]
proc_spec = (proc (programPath prog) ghc_args) {
create_group = True,
-- Closing fds is VERY important to avoid
Expand Down

0 comments on commit 2269835

Please sign in to comment.