[libcxx-commits] [PATCH] D115761: [lit] Flush stderr manually on Windows after printing messages

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 14 14:24:09 PST 2021


mstorsjo created this revision.
mstorsjo added reviewers: amccarth, hans, rnk, thakis, jdenny.
Herald added subscribers: delcypher, arichardson.
mstorsjo requested review of this revision.
Herald added projects: libc++, LLVM.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

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 7e3ee09ad24cbca3ea7687c50b53be5269127fb1 / D28725 <https://reviews.llvm.org/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().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115761

Files:
  libcxx/utils/libcxx/test/config.py
  llvm/utils/lit/lit/LitConfig.py


Index: llvm/utils/lit/lit/LitConfig.py
===================================================================
--- llvm/utils/lit/lit/LitConfig.py
+++ llvm/utils/lit/lit/LitConfig.py
@@ -169,6 +169,11 @@
         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:
Index: libcxx/utils/libcxx/test/config.py
===================================================================
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -159,7 +159,6 @@
         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 configure_cxx(self):
         # Gather various compiler parameters.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115761.394386.patch
Type: text/x-patch
Size: 1356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211214/2577005e/attachment-0001.bin>


More information about the libcxx-commits mailing list