Skip to content

Commit

Permalink
[lit] Flush stderr manually on Windows after printing messages
Browse files Browse the repository at this point in the history
When run in a git bash terminal, sys.stderr isn't flushed implicitly
after printing each line. Manually flush it after each printout,
to avoid getting broken/misordered output.

A similar fix had been done in the old libcxx test config, committed
as part of 7e3ee09 / D28725; this
generalizes the fix, making it available in the new libcxx test
configs too, and for any other test that uses lit_config.note().

Differential Revision: https://reviews.llvm.org/D115761
  • Loading branch information
mstorsjo committed Dec 18, 2021
1 parent 982604c commit 2ec75a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion libcxx/utils/libcxx/test/config.py
Expand Up @@ -159,7 +159,6 @@ def print_config_info(self):
self.lit_config.note("Running against the C++ Library at {}".format(self.cxx_runtime_root))
self.lit_config.note("Linking against the ABI Library at {}".format(self.abi_library_root))
self.lit_config.note("Running against the ABI Library at {}".format(self.abi_runtime_root))
sys.stderr.flush() # Force flushing to avoid broken output on Windows

def get_test_format(self):
from libcxx.test.format import LibcxxTestFormat
Expand Down
5 changes: 5 additions & 0 deletions llvm/utils/lit/lit/LitConfig.py
Expand Up @@ -169,6 +169,11 @@ def _write_message(self, kind, message):
line = inspect.getlineno(f)
sys.stderr.write('%s: %s:%d: %s: %s\n' % (self.progname, file, line,
kind, message))
if self.isWindows:
# In a git bash terminal, the writes to sys.stderr aren't visible
# on screen immediately. Flush them here to avoid broken/misoredered
# output.
sys.stderr.flush()

def note(self, message):
if not self.quiet:
Expand Down

0 comments on commit 2ec75a0

Please sign in to comment.