summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromes <rodrigo.m.mesquita@gmail.com>2023-02-15 14:33:45 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-02-20 15:27:52 -0500
commit0196cc2ba8f848187be47b5fc53bab89e5026bf6 (patch)
tree71fc01889c8c87f0aef4c2e90eaeea3d5fff47ef
parent26243de1e3716886161d79918af9359f7639314b (diff)
downloadhaskell-0196cc2ba8f848187be47b5fc53bab89e5026bf6.tar.gz
fix: Explicitly flush stdout on plugin
Because of #20791, the plugins tests often fail. This is a temporary fix to stop the tests from failing due to unflushed outputs on windows and the explicit flush should be removed when #20791 is fixed.
-rw-r--r--testsuite/tests/plugins/all.T12
-rw-r--r--testsuite/tests/plugins/echo-plugin/Echo.hs5
-rw-r--r--testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs5
3 files changed, 14 insertions, 8 deletions
diff --git a/testsuite/tests/plugins/all.T b/testsuite/tests/plugins/all.T
index 468f509b91..ef0096f064 100644
--- a/testsuite/tests/plugins/all.T
+++ b/testsuite/tests/plugins/all.T
@@ -294,26 +294,22 @@ test('T20803b',
test('test-echo-in-turn',
[extra_files(['echo-plugin/']),
- pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}'),
- when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
+ pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn TOP={top}')],
makefile_test, [])
test('test-echo-in-line',
[extra_files(['echo-plugin/']),
- pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}'),
- when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
+ pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line TOP={top}')],
makefile_test, [])
test('test-echo-in-turn-many-args',
[extra_files(['echo-plugin/']),
- pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}'),
- when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
+ pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-turn-many-args TOP={top}')],
makefile_test, [])
test('test-echo-in-line-many-args',
[extra_files(['echo-plugin/']),
- pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}'),
- when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
+ pre_cmd('$MAKE -s --no-print-directory -C echo-plugin package.test-echo-in-line-many-args TOP={top}')],
makefile_test, [])
test('plugins-external',
diff --git a/testsuite/tests/plugins/echo-plugin/Echo.hs b/testsuite/tests/plugins/echo-plugin/Echo.hs
index 9c2a71a088..5a8ea1adfd 100644
--- a/testsuite/tests/plugins/echo-plugin/Echo.hs
+++ b/testsuite/tests/plugins/echo-plugin/Echo.hs
@@ -5,6 +5,7 @@ import GHC.Tc.Plugin
import GHC.Tc.Utils.Monad
import qualified GHC.Tc.Utils.Monad as Utils
import GHC.Types.Unique.FM ( emptyUFM )
+import System.IO
plugin :: Plugin
plugin = mkPureOptTcPlugin optCallCount
@@ -27,6 +28,10 @@ optCallCount opts = Just $
n <- unsafeTcPluginTcM $ readMutVar c
let msg = if null opts then "" else mconcat opts
tcPluginIO . putStrLn $ "Echo TcPlugin " ++ msg ++ "#" ++ show n
+
+ -- TODO: Remove #20791
+ tcPluginIO $ hFlush stdout
+
unsafeTcPluginTcM $ writeMutVar c (n + 1)
return $ TcPluginOk [] []
diff --git a/testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs b/testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs
index adfa6e28cf..bf717b26c0 100644
--- a/testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs
+++ b/testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs
@@ -10,6 +10,7 @@ import GHC.Hs.Lit
import GHC.Driver.Hooks
import GHC.Tc.Utils.Monad
import GHC.Parser.Annotation
+import System.IO
plugin :: Plugin
plugin = defaultPlugin { driverPlugin = hooksP }
@@ -28,6 +29,10 @@ hooksP opts hsc_env = do
fakeRunMeta :: [CommandLineOption] -> MetaHook TcM
fakeRunMeta opts (MetaE r) _ = do
liftIO . putStrLn $ "Options = " ++ show opts
+
+ -- TODO: Remove #20791
+ liftIO $ hFlush stdout
+
pure $ r zero
where zero :: LHsExpr GhcPs