summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-11-12 10:36:58 +0100
committerSylvain Henry <sylvain@haskus.fr>2020-12-14 19:45:13 +0100
commitd0e8c10d587e4b9984526d0dfcfcb258b75733b8 (patch)
treee0993719d76f87a0f4f8eccef089526217bf5bb4 /testsuite/tests
parent92377c27e1a48d0d3776f65c7074dfeb122b46db (diff)
downloadhaskell-d0e8c10d587e4b9984526d0dfcfcb258b75733b8.tar.gz
Move Unit related fields from DynFlags to HscEnv
The unit database cache, the home unit and the unit state were stored in DynFlags while they ought to be stored in the compiler session state (HscEnv). This patch fixes this. It introduces a new UnitEnv type that should be used in the future to handle separate unit environments (especially host vs target units). Related to #17957 Bump haddock submodule
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghc-api/T7478/T7478.hs3
-rw-r--r--testsuite/tests/ghc-api/T9595.hs11
-rw-r--r--testsuite/tests/parser/should_run/CountParserDeps.stdout3
-rw-r--r--testsuite/tests/regalloc/regalloc_unit_tests.hs3
-rw-r--r--testsuite/tests/rts/linker/LinkerUnload.hs3
5 files changed, 13 insertions, 10 deletions
diff --git a/testsuite/tests/ghc-api/T7478/T7478.hs b/testsuite/tests/ghc-api/T7478/T7478.hs
index 2fa0f6095e..89fd61a22c 100644
--- a/testsuite/tests/ghc-api/T7478/T7478.hs
+++ b/testsuite/tests/ghc-api/T7478/T7478.hs
@@ -11,6 +11,7 @@ import qualified GHC.Utils.Outputable as GHC
import qualified GHC.Driver.Ppr as GHC
import GHC.Driver.Monad (liftIO)
import GHC.Utils.Outputable (PprStyle, queryQual)
+import GHC.Unit.State
compileInGhc :: [FilePath] -- ^ Targets
-> (String -> IO ()) -- ^ handler for each SevOutput message
@@ -43,7 +44,7 @@ compileInGhc targets handlerOutput = do
_ -> error "fileFromTarget: not a known target"
collectSrcError handlerOutput flags _ SevOutput _srcspan msg
- = handlerOutput $ GHC.showSDocForUser flags alwaysQualify msg
+ = handlerOutput $ GHC.showSDocForUser flags emptyUnitState alwaysQualify msg
collectSrcError _ _ _ _ _ _
= return ()
diff --git a/testsuite/tests/ghc-api/T9595.hs b/testsuite/tests/ghc-api/T9595.hs
index 468b63a342..9a5450fbd3 100644
--- a/testsuite/tests/ghc-api/T9595.hs
+++ b/testsuite/tests/ghc-api/T9595.hs
@@ -3,18 +3,18 @@ module Main where
import GHC
import GHC.Unit.State
import GHC.Driver.Monad
-import GHC.Utils.Outputable
-import System.Environment
import GHC.Driver.Session
+import GHC.Driver.Env
+import GHC.Utils.Outputable
import GHC.Unit.Module
+import System.Environment
main =
do [libdir] <- getArgs
_ <- runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
setSessionDynFlags dflags
- dflags <- getSessionDynFlags
- let state = unitState dflags
+ state <- hsc_units <$> getSession
liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames state)
_ <- runGhc (Just libdir) $ do
dflags <- getSessionDynFlags
@@ -23,7 +23,6 @@ main =
(PackageArg "ghc")
(ModRenaming True [])]
})
- dflags <- getSessionDynFlags
- let state = unitState dflags
+ state <- hsc_units <$> getSession
liftIO $ print (mkModuleName "GHC.Utils.Outputable" `elem` listVisibleModuleNames state)
return ()
diff --git a/testsuite/tests/parser/should_run/CountParserDeps.stdout b/testsuite/tests/parser/should_run/CountParserDeps.stdout
index 97b7dc743f..9c3db2105a 100644
--- a/testsuite/tests/parser/should_run/CountParserDeps.stdout
+++ b/testsuite/tests/parser/should_run/CountParserDeps.stdout
@@ -1,4 +1,4 @@
-Found 235 parser module dependencies
+Found 236 parser module dependencies
GHC.Builtin.Names
GHC.Builtin.PrimOps
GHC.Builtin.Types
@@ -193,6 +193,7 @@ GHC.Types.Var
GHC.Types.Var.Env
GHC.Types.Var.Set
GHC.Unit
+GHC.Unit.Env
GHC.Unit.External
GHC.Unit.Finder.Types
GHC.Unit.Home
diff --git a/testsuite/tests/regalloc/regalloc_unit_tests.hs b/testsuite/tests/regalloc/regalloc_unit_tests.hs
index 6bd6864706..d889b90bc7 100644
--- a/testsuite/tests/regalloc/regalloc_unit_tests.hs
+++ b/testsuite/tests/regalloc/regalloc_unit_tests.hs
@@ -25,6 +25,7 @@ import qualified GHC.CmmToAsm.Reg.Linear.Base as Linear
import qualified GHC.CmmToAsm.X86.Instr as X86.Instr
import qualified GHC.CmmToAsm.X86 as X86
import GHC.Driver.Main
+import GHC.Driver.Env
import GHC.StgToCmm.CgUtils
import GHC.CmmToAsm
import GHC.CmmToAsm.Config
@@ -110,7 +111,7 @@ compileCmmForRegAllocStats dflags' cmmFile ncgImplF us = do
hscEnv <- newHscEnv dflags
-- parse the cmm file and output any warnings or errors
- (warnings, errors, parsedCmm) <- parseCmmFile dflags cmmFile
+ (warnings, errors, parsedCmm) <- parseCmmFile dflags (hsc_home_unit hscEnv) cmmFile
let warningMsgs = fmap pprWarning warnings
errorMsgs = fmap pprError errors
diff --git a/testsuite/tests/rts/linker/LinkerUnload.hs b/testsuite/tests/rts/linker/LinkerUnload.hs
index 9bdc92fdc2..6529dd654d 100644
--- a/testsuite/tests/rts/linker/LinkerUnload.hs
+++ b/testsuite/tests/rts/linker/LinkerUnload.hs
@@ -2,6 +2,7 @@ module LinkerUnload (init) where
import GHC
import GHC.Unit.State
+import GHC.Driver.Env
import GHC.Driver.Session
import GHC.Driver.Backend
import qualified GHC.Linker.Loader as Loader
@@ -19,4 +20,4 @@ loadPackages = do
, ghcLink = LinkInMemory }
setSessionDynFlags dflags'
hsc_env <- getSession
- liftIO $ Loader.loadPackages hsc_env (preloadUnits (unitState dflags'))
+ liftIO $ Loader.loadPackages hsc_env (preloadUnits (hsc_units hsc_env))