diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-01-07 14:25:15 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-13 21:27:34 -0500 |
commit | 8e2f85f6b4662676f0d7addaff9bf2c7d751bb63 (patch) | |
tree | 6a5bea5db12d907874cdf26d709d829a3f3216ba /testsuite/tests/ghc-api | |
parent | 40983d2331fe34c0af6925db7588d5ac6a19ae36 (diff) | |
download | haskell-8e2f85f6b4662676f0d7addaff9bf2c7d751bb63.tar.gz |
Refactor Logger
Before this patch, the only way to override GHC's default logging
behavior was to set `log_action`, `dump_action` and `trace_action`
fields in DynFlags. This patch introduces a new Logger abstraction and
stores it in HscEnv instead.
This is part of #17957 (avoid storing state in DynFlags). DynFlags are
duplicated and updated per-module (because of OPTIONS_GHC pragma), so
we shouldn't store global state in them.
This patch also fixes a race in parallel "--make" mode which updated
the `generatedDumps` IORef concurrently.
Bump haddock submodule
The increase in MultilayerModules is tracked in #19293.
Metric Increase:
MultiLayerModules
Diffstat (limited to 'testsuite/tests/ghc-api')
-rw-r--r-- | testsuite/tests/ghc-api/T10052/T10052.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/T18522-dbg-ppr.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/T7478/T7478.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/apirecomp001/myghc.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/downsweep/OldModLocation.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/target-contents/TargetContents.hs | 3 |
7 files changed, 15 insertions, 8 deletions
diff --git a/testsuite/tests/ghc-api/T10052/T10052.hs b/testsuite/tests/ghc-api/T10052/T10052.hs index 03a4a65d6e..f579c0641d 100644 --- a/testsuite/tests/ghc-api/T10052/T10052.hs +++ b/testsuite/tests/ghc-api/T10052/T10052.hs @@ -19,7 +19,8 @@ runGhc' args act = do flags = map noLoc (tail args) runGhc (Just libdir) $ do dflags0 <- getSessionDynFlags - (dflags1, _leftover, _warns) <- parseDynamicFlags dflags0 flags + logger <- getLogger + (dflags1, _leftover, _warns) <- parseDynamicFlags logger dflags0 flags let dflags2 = dflags1 { backend = Interpreter , ghcLink = LinkInMemory diff --git a/testsuite/tests/ghc-api/T18522-dbg-ppr.hs b/testsuite/tests/ghc-api/T18522-dbg-ppr.hs index a29dc194dd..e0b6a57764 100644 --- a/testsuite/tests/ghc-api/T18522-dbg-ppr.hs +++ b/testsuite/tests/ghc-api/T18522-dbg-ppr.hs @@ -37,6 +37,7 @@ main = do `xopt_set` LangExt.RankNTypes hsc_env <- getSession let dflags = hsc_dflags hsc_env + let logger = hsc_logger hsc_env liftIO $ do th_t <- runQ [t| forall k {j}. forall (a :: k) (b :: j) -> @@ -48,7 +49,7 @@ main = do let (warnings, errors) = partitionMessages messages case mres of Nothing -> do - printBagOfErrors dflags warnings - printBagOfErrors dflags errors + printBagOfErrors logger dflags warnings + printBagOfErrors logger dflags errors Just (t, _) -> do putStrLn $ showSDoc dflags (debugPprType t) diff --git a/testsuite/tests/ghc-api/T7478/T7478.hs b/testsuite/tests/ghc-api/T7478/T7478.hs index 89fd61a22c..786a859644 100644 --- a/testsuite/tests/ghc-api/T7478/T7478.hs +++ b/testsuite/tests/ghc-api/T7478/T7478.hs @@ -19,8 +19,9 @@ compileInGhc :: [FilePath] -- ^ Targets compileInGhc targets handlerOutput = do -- Set flags flags0 <- getSessionDynFlags - let flags = flags0 {verbosity = 1, log_action = collectSrcError handlerOutput} + let flags = flags0 {verbosity = 1 } setSessionDynFlags flags + pushLogHookM (const (collectSrcError handlerOutput)) -- Set up targets. oldTargets <- getTargets let oldFiles = map fileFromTarget oldTargets diff --git a/testsuite/tests/ghc-api/apirecomp001/myghc.hs b/testsuite/tests/ghc-api/apirecomp001/myghc.hs index 03c57e93a5..76dd6511ba 100644 --- a/testsuite/tests/ghc-api/apirecomp001/myghc.hs +++ b/testsuite/tests/ghc-api/apirecomp001/myghc.hs @@ -23,7 +23,8 @@ main = do libdir : args <- getArgs runGhc (Just libdir) $ do dflags0 <- getSessionDynFlags - (dflags, _, _) <- parseDynamicFlags dflags0 + logger <- getLogger + (dflags, _, _) <- parseDynamicFlags logger dflags0 (map (mkGeneralLocated "on the commandline") args) setSessionDynFlags $ dflags { backend = NoBackend , ghcLink = LinkInMemory diff --git a/testsuite/tests/ghc-api/downsweep/OldModLocation.hs b/testsuite/tests/ghc-api/downsweep/OldModLocation.hs index 180932bd18..9e03f925b6 100644 --- a/testsuite/tests/ghc-api/downsweep/OldModLocation.hs +++ b/testsuite/tests/ghc-api/downsweep/OldModLocation.hs @@ -22,7 +22,8 @@ main = do defaultErrorHandler defaultFatalMessager defaultFlushOut $ do dflags0 <- getSessionDynFlags - (dflags1, _, _) <- parseDynamicFlags dflags0 $ map noLoc $ + logger <- getLogger + (dflags1, _, _) <- parseDynamicFlags logger dflags0 $ map noLoc $ [ "-i", "-i.", "-imydir" -- , "-v3" ] ++ args diff --git a/testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs b/testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs index 4f0f4d33bb..bd6849a192 100644 --- a/testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs +++ b/testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs @@ -47,7 +47,8 @@ main = do runGhc (Just libdir) $ do dflags0 <- getSessionDynFlags - (dflags1, _, _) <- parseDynamicFlags dflags0 $ map noLoc $ + logger <- getLogger + (dflags1, _, _) <- parseDynamicFlags logger dflags0 $ map noLoc $ [ "-fno-diagnostics-show-caret" -- , "-v3" ] ++ args diff --git a/testsuite/tests/ghc-api/target-contents/TargetContents.hs b/testsuite/tests/ghc-api/target-contents/TargetContents.hs index 4d8ecf1596..e6be1befd5 100644 --- a/testsuite/tests/ghc-api/target-contents/TargetContents.hs +++ b/testsuite/tests/ghc-api/target-contents/TargetContents.hs @@ -30,7 +30,8 @@ main = do createDirectoryIfMissing False "outdir" runGhc (Just libdir) $ do dflags0 <- getSessionDynFlags - (dflags1, xs, warn) <- parseDynamicFlags dflags0 $ map noLoc $ + logger <- getLogger + (dflags1, xs, warn) <- parseDynamicFlags logger dflags0 $ map noLoc $ [ "-outputdir", "./outdir" , "-fno-diagnostics-show-caret" ] ++ args |