[test] Capture stderr from 'tar --version' call as well
authorMichal Gorny <mgorny@gentoo.org>
Fri, 14 Dec 2018 22:38:01 +0000 (22:38 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Fri, 14 Dec 2018 22:38:01 +0000 (22:38 +0000)
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.

Differential Revision: https://reviews.llvm.org/D55443

llvm-svn: 349204

lld/test/lit.cfg.py

index d4d9ea7..9989a1c 100644 (file)
@@ -94,7 +94,10 @@ if config.have_dia_sdk:
 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, _ = tar_version.communicate()
+    if 'GNU tar' in sout.decode():
         config.available_features.add('gnutar')
-    tar_version.wait()