[libcxx-commits] [libcxx] 2ec75a0 - [lit] Flush stderr manually on Windows after printing messages

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Sat Dec 18 11:42:10 PST 2021


Author: Martin Storsjö
Date: 2021-12-18T21:41:40+02:00
New Revision: 2ec75a0869ab01fa9caf310e8a31eb7716182d30

URL: https://github.com/llvm/llvm-project/commit/2ec75a0869ab01fa9caf310e8a31eb7716182d30
DIFF: https://github.com/llvm/llvm-project/commit/2ec75a0869ab01fa9caf310e8a31eb7716182d30.diff

LOG: [lit] Flush stderr manually on Windows after printing messages

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; 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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index 77827df261b1c..a28590ef0bc14 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -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

diff  --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py
index 92a4fcee28450..38b7a18c6a583 100644
--- a/llvm/utils/lit/lit/LitConfig.py
+++ b/llvm/utils/lit/lit/LitConfig.py
@@ -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:


        


More information about the libcxx-commits mailing list