Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Added support to generate ghcconfig
Browse files Browse the repository at this point in the history
  We will need it for properly configuring python command

Some revisions
  • Loading branch information
chitrak7 committed Jun 18, 2018
1 parent 79d2b03 commit 931ab04
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ testsuitePackages = return [ checkApiAnnotations
, ghci
, ghcPkg
, hp2ps
, parallel ]
, iserv
, parallel
, runGhc ]

-- | Given a 'Context', compute the name of the program that is built in it
-- assuming that the corresponding package's type is 'Program'. For example, GHC
Expand Down
36 changes: 32 additions & 4 deletions src/Rules/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ testRules = do
writeFile (root -/- timeoutProgPath) script
makeExecutable (root -/- timeoutProgPath)

-- | Using program shipped with testsuite to generate ghcconfig file.
root -/- ghcConfigProgPath ~> do
ghc <- builderPath $ Ghc CompileHs Stage0
command [] ghc [ghcConfigHsPath, "-o" , root -/- ghcConfigProgPath]

-- | TODO : Use input test compiler and not just stage2 compiler.
root -/- ghcConfigPath ~> do
ghcPath <- needfile Stage1 ghc
need [ root -/- ghcConfigProgPath]
command [FileStdout $ root -/- ghcConfigPath] (root -/- ghcConfigProgPath)
[ ghcPath ]

"validate" ~> do
needTestBuilders
build $ target (vanillaContext Stage2 compiler) (Make "testsuite/tests") [] []
Expand All @@ -42,6 +54,10 @@ testRules = do

-- Prepare the timeout program.
need [ root -/- timeoutProgPath ]

-- TODO : Should we remove the previosly generated config file?
-- Prepare Ghc configuration file for input compiler.
need [ root -/- ghcConfigPath ]

-- TODO This approach doesn't work.
-- Set environment variables for test's Makefile.
Expand All @@ -68,15 +84,18 @@ testRules = do
-- Execute the test target.
buildWithCmdOptions env $ target (vanillaContext Stage2 compiler) RunTest [] []

-- | Build extra programs required by testsuite
needTestsuiteBuilders :: Action ()
needTestsuiteBuilders = do
-- | Build extra programs and libraries required by testsuite
needTestsuiteLibraries :: Action ()
needTestsuiteLibraries = do
targets <- mapM (needfile Stage1) =<< testsuitePackages
binPath <- stageBinPath Stage1
libPath <- stageLibPath Stage1
iservPath <- needfile Stage1 iserv
runhaskellPath <- needfile Stage1 runGhc
need targets
-- | We need to copy iserv bin to lib/bin as this is where testsuite looks
-- | for iserv. Also, using runhaskell gives different stdout due to
-- | difference in program name. This causes StdMismatch errors.
copyFile iservPath $ libPath -/- "bin/ghc-iserv"
copyFile runhaskellPath $ binPath -/- "runghc"

Expand All @@ -86,7 +105,7 @@ needTestBuilders = do
needBuilder $ GhcPkg Update Stage1
needBuilder Hpc
needBuilder (Hsc2Hs Stage1)
needTestsuiteBuilders
needTestsuiteLibraries

-- | Extra flags to send to the Haskell compiler to run tests.
runTestGhcFlags :: Action String
Expand Down Expand Up @@ -124,6 +143,15 @@ timeoutPyPath = "test/bin/timeout.py"
timeoutProgPath :: FilePath
timeoutProgPath = "test/bin/timeout" <.> exe

ghcConfigHsPath :: FilePath
ghcConfigHsPath = "testsuite/mk/ghc-config.hs"

ghcConfigProgPath :: FilePath
ghcConfigProgPath = "test/bin/ghc-config"

ghcConfigPath :: FilePath
ghcConfigPath = "test/ghcconfig"

needfile :: Stage -> Package -> Action FilePath
needfile stage pkg
--TODO (Alp): we might sometimes need more than vanilla!
Expand Down

0 comments on commit 931ab04

Please sign in to comment.