diff --git a/cabal-validate/src/Main.hs b/cabal-validate/src/Main.hs index 29afb0be070..2c1e33c1d83 100644 --- a/cabal-validate/src/Main.hs +++ b/cabal-validate/src/Main.hs @@ -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) @@ -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