diff options
author | romes <rodrigo.m.mesquita@gmail.com> | 2023-02-15 14:33:45 +0000 |
---|---|---|
committer | romes <rodrigo.m.mesquita@gmail.com> | 2023-02-17 09:20:55 +0000 |
commit | 4d9658d9998c8be457c5eed3ed3e3315d7787ccf (patch) | |
tree | e2382aad56c7b078bdcc4f7f09fbb7436c70a4ba | |
parent | 9ca51f9e84abc41ba590203d8bc8df8d6af86db2 (diff) | |
download | haskell-4d9658d9998c8be457c5eed3ed3e3315d7787ccf.tar.gz |
fix: Explicitly flush stdout on pluginwip/romes/tmp-fix-echo-plugins
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.T | 12 | ||||
-rw-r--r-- | testsuite/tests/plugins/echo-plugin/Echo.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs | 5 |
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 |