mgorny created this revision.
mgorny added reviewers: krytarowski, ikudrin, pcc, zturner.
mgorny added a project: lld.
Herald added subscribers: llvm-commits, MaskRay.

Capture the stderr from 'tar --version' call as otherwise error messages
spill onto user's terminal unnecessarily (e.g. on NetBSD where tar does
not support long options).  While at it, refactor the code to use
communicate() instead of reinventing the wheel.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D55443

Files:
  test/lit.cfg.py


Index: test/lit.cfg.py
===================================================================
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -94,7 +94,10 @@
 tar_executable = lit.util.which('tar', config.environment['PATH'])
 if tar_executable:
     tar_version = subprocess.Popen(
-        [tar_executable, '--version'], stdout=subprocess.PIPE, env={'LANG': 
'C'})
-    if 'GNU tar' in tar_version.stdout.read().decode():
+        [tar_executable, '--version'],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        env={'LANG': 'C'})
+    sout, serr = tar_version.communicate()
+    if 'GNU tar' in sout:
         config.available_features.add('gnutar')
-    tar_version.wait()


Index: test/lit.cfg.py
===================================================================
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -94,7 +94,10 @@
 tar_executable = lit.util.which('tar', config.environment['PATH'])
 if tar_executable:
     tar_version = subprocess.Popen(
-        [tar_executable, '--version'], stdout=subprocess.PIPE, env={'LANG': 'C'})
-    if 'GNU tar' in tar_version.stdout.read().decode():
+        [tar_executable, '--version'],
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        env={'LANG': 'C'})
+    sout, serr = tar_version.communicate()
+    if 'GNU tar' in sout:
         config.available_features.add('gnutar')
-    tar_version.wait()
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to