[Git][ghc/ghc][wip/romes/tmp-fix-echo-plugins] fix: Explicitly flush stdout on plugin

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Fri Feb 17 09:21:08 UTC 2023



Rodrigo Mesquita pushed to branch wip/romes/tmp-fix-echo-plugins at Glasgow Haskell Compiler / GHC


Commits:
4d9658d9 by romes at 2023-02-17T09:20:55+00:00
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.

- - - - -


3 changed files:

- testsuite/tests/plugins/all.T
- testsuite/tests/plugins/echo-plugin/Echo.hs
- testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs


Changes:

=====================================
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',


=====================================
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 [] []
 


=====================================
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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d9658d9998c8be457c5eed3ed3e3315d7787ccf

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4d9658d9998c8be457c5eed3ed3e3315d7787ccf
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230217/a8f599c2/attachment-0001.html>


More information about the ghc-commits mailing list