@@ -14,6 +14,7 @@ import qualified Data.Text.Lazy as T (toStrict)
14
14
import qualified Data.Text.Lazy.Encoding as T (decodeUtf8 )
15
15
import Data.Version (makeVersion , showVersion )
16
16
import System.FilePath ((</>) )
17
+ import System.IO (BufferMode (LineBuffering ), hSetBuffering , stderr , stdout )
17
18
import System.Process.Typed (proc , readProcessStdout_ )
18
19
19
20
import Cli (Compiler (.. ), HackageTests (.. ), Opts (.. ), parseOpts , whenVerbose )
@@ -24,6 +25,18 @@ import Step (Step (..), displayStep)
24
25
-- | Entry-point for @cabal-validate@.
25
26
main :: IO ()
26
27
main = do
28
+ -- You'd _think_ that line-buffering for stdout and stderr would be the
29
+ -- default behavior, and the documentation makes gestures at it, but it
30
+ -- appears to not be the case!
31
+ --
32
+ -- > For most implementations, physical files will normally be
33
+ -- > block-buffered and terminals will normally be line-buffered.
34
+ --
35
+ -- However, on GitHub Actions and on my machine (macOS M1), adding these
36
+ -- lines makes output appear in the correct order!
37
+ hSetBuffering stdout LineBuffering
38
+ hSetBuffering stderr LineBuffering
39
+
27
40
opts <- parseOpts
28
41
printConfig opts
29
42
printToolVersions opts
@@ -103,11 +116,11 @@ cabalListBinArgs opts = "list-bin" : cabalArgs opts
103
116
cabalListBin :: Opts -> String -> IO FilePath
104
117
cabalListBin opts target = do
105
118
let args = cabalListBinArgs opts ++ [target]
106
- stdout <-
119
+ stdout' <-
107
120
readProcessStdout_ $
108
121
proc (cabal opts) args
109
122
110
- pure (T. unpack $ T. strip $ T. toStrict $ T. decodeUtf8 stdout)
123
+ pure (T. unpack $ T. strip $ T. toStrict $ T. decodeUtf8 stdout' )
111
124
112
125
-- | Get the RTS arguments for invoking test suites.
113
126
--
0 commit comments