summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-01-18 16:36:45 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-01-19 10:36:38 +0000
commitc265d482947cd0aa42da39b535a785ffafdf5734 (patch)
treedb8aa538366deeeecbc37abb7e46eb9d63425b96
parentc2d84c3319b3ac1175ccb9619553b3522b27d00f (diff)
downloadhaskell-c265d482947cd0aa42da39b535a785ffafdf5734.tar.gz
Add flushes to plugin tests which print to stdout
Due to #20791 you need to explicitly flush as otherwise the output from these tests doesn't make it to stdout.
-rw-r--r--testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs6
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs12
-rw-r--r--testsuite/tests/plugins/simple-plugin/Simple/TrustworthyPlugin.hs3
3 files changed, 20 insertions, 1 deletions
diff --git a/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs b/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
index c85b4ca395..7615a3c69e 100644
--- a/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
+++ b/testsuite/tests/plugins/T16104-plugin/T16104_Plugin.hs
@@ -4,6 +4,7 @@ module T16104_Plugin (plugin) where
import GHC.Plugins
import Data.Bits
+import System.IO
plugin :: Plugin
plugin = defaultPlugin {installCoreToDos = install}
@@ -14,7 +15,10 @@ plugin = defaultPlugin {installCoreToDos = install}
check :: ModGuts -> CoreM ModGuts
check m = do mbN <- thNameToGhcName 'complement
case mbN of
- Just _ -> liftIO $ putStrLn "Found complement!"
+ Just _ -> do
+ liftIO $ putStrLn "Found complement!"
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
Nothing -> error "Failed to locate complement"
return m
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
index 0a9ef301d6..bb0458bf3e 100644
--- a/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
+++ b/testsuite/tests/plugins/simple-plugin/Simple/SourcePlugin.hs
@@ -15,6 +15,7 @@ import GHC.Utils.Outputable
import GHC.Hs.ImpExp
import GHC.Hs.Decls
import GHC.Hs.Doc
+import System.IO
plugin :: Plugin
plugin = defaultPlugin { parsedResultAction = parsedPlugin
@@ -28,6 +29,8 @@ parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule
-> Hsc HsParsedModule
parsedPlugin opts _ pm
= do liftIO $ putStrLn $ "parsePlugin(" ++ intercalate "," opts ++ ")"
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
return pm
renamedAction :: [CommandLineOption]
@@ -35,17 +38,24 @@ renamedAction :: [CommandLineOption]
-> TcM (TcGblEnv, HsGroup GhcRn)
renamedAction _ env grp
= do liftIO $ putStrLn "typeCheckPlugin (rn)"
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
return (env, grp)
typecheckPlugin :: [CommandLineOption] -> ModSummary -> TcGblEnv -> TcM TcGblEnv
typecheckPlugin _ _ tc
= do liftIO $ putStrLn "typeCheckPlugin (tc)"
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
return tc
metaPlugin' :: [CommandLineOption] -> LHsExpr GhcTc -> TcM (LHsExpr GhcTc)
metaPlugin' _ meta
= do dflags <- getDynFlags
liftIO $ putStrLn $ "metaPlugin: " ++ (showSDoc dflags $ ppr meta)
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
+
return meta
interfaceLoadPlugin' :: [CommandLineOption] -> ModIface -> IfM lcl ModIface
@@ -53,4 +63,6 @@ interfaceLoadPlugin' _ iface
= do dflags <- getDynFlags
liftIO $ putStrLn $ "interfacePlugin: "
++ (showSDoc dflags $ ppr $ mi_module iface)
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
return iface
diff --git a/testsuite/tests/plugins/simple-plugin/Simple/TrustworthyPlugin.hs b/testsuite/tests/plugins/simple-plugin/Simple/TrustworthyPlugin.hs
index ecf509e40e..802a05803a 100644
--- a/testsuite/tests/plugins/simple-plugin/Simple/TrustworthyPlugin.hs
+++ b/testsuite/tests/plugins/simple-plugin/Simple/TrustworthyPlugin.hs
@@ -2,6 +2,7 @@ module Simple.TrustworthyPlugin (plugin) where
import GHC.Plugins
import GHC.Tc.Utils.Monad
+import System.IO
plugin :: Plugin
plugin = defaultPlugin
@@ -14,4 +15,6 @@ plugin = defaultPlugin
safe <- finalSafeMode dflags tcg
print $ gopt Opt_PluginTrustworthy dflags
putStrLn $ showPpr dflags safe
+ -- TODO: Remove #20791
+ hFlush stdout
return tcg