[Git][ghc/ghc][wip/T23155] testsuite: Fix racing prints in T21465

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Mar 29 18:14:46 UTC 2023



Ben Gamari pushed to branch wip/T23155 at Glasgow Haskell Compiler / GHC


Commits:
6ac4ca8f by Ben Gamari at 2023-03-29T14:14:40-04:00
testsuite: Fix racing prints in T21465

As noted in #23155, we previously failed to add flushes necessary to
ensure predictable output.

Fixes #23155.

- - - - -


3 changed files:

- testsuite/tests/rts/T21465/T21465.hs
- testsuite/tests/rts/T21465/T21465.stdout
- testsuite/tests/rts/T21465/T21465_c.c


Changes:

=====================================
testsuite/tests/rts/T21465/T21465.hs
=====================================
@@ -1,10 +1,12 @@
 {-# LANGUAGE ForeignFunctionInterface #-}
 module Main where
 
+import System.IO
+
 foreign import ccall "test_c" testC :: IO ()
 
 helper :: IO ()
-helper = putStrLn "This is the helper function"
+helper = putStrLn "This is the helper function" >> hFlush stdout
 
 foreign export ccall helper :: IO ()
 


=====================================
testsuite/tests/rts/T21465/T21465.stdout
=====================================
@@ -1,5 +1,4 @@
 This is the helper function
-Done.
  0: 01 01
  1: 02 02
  2: 03 03
@@ -16,3 +15,4 @@ Done.
 13: 0e 0e
 14: 0f 0f
 15: 10 10
+Done.


=====================================
testsuite/tests/rts/T21465/T21465_c.c
=====================================
@@ -25,4 +25,5 @@ void test_c() {
     for (int i = 0; i < 16; i++) {
         printf("%2i: %02x %02x\n", i, blah[i], foo[i]);
     }
+    fflush(stdout);
 }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ac4ca8f2ccc05dfb75d4625431181d69bbfd41d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/6ac4ca8f2ccc05dfb75d4625431181d69bbfd41d
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/20230329/bbff7e97/attachment-0001.html>


More information about the ghc-commits mailing list