Skip to content

Commit

Permalink
Line-buffer stdout and stderr
Browse files Browse the repository at this point in the history
I though this was the default, but apparently not! This seems to fix
output ordering issues.

Noticed here: #10573 (comment)
  • Loading branch information
9999years committed Dec 10, 2024
1 parent 5b32530 commit 17ffa59
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cabal-validate/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Data.Text.Lazy.Encoding as T (decodeUtf8)
import Data.Version (makeVersion, showVersion)
import System.FilePath ((</>))
import System.Process.Typed (proc, readProcessStdout_)
import System.IO (hSetBuffering, BufferMode(LineBuffering), stdout, stderr)

import Cli (Compiler (..), HackageTests (..), Opts (..), parseOpts, whenVerbose)
import OutputUtil (printHeader, withTiming)
Expand All @@ -24,6 +25,18 @@ import Step (Step (..), displayStep)
-- | Entry-point for @cabal-validate@.
main :: IO ()
main = do
-- You'd _think_ that line-buffering for stdout and stderr would be the
-- default behavior, and the documentation makes gestures at it, but it
-- appears to not be the case!
--
-- > For most implementations, physical files will normally be
-- > block-buffered and terminals will normally be line-buffered.
--
-- However, on GitHub Actions and on my machine (macOS M1), adding these
-- lines makes output appear in the correct order!
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering

opts <- parseOpts
printConfig opts
printToolVersions opts
Expand Down

0 comments on commit 17ffa59

Please sign in to comment.