Permalink
Browse files

[test] Capture stderr from 'tar --version' call as well

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
  • Loading branch information...
mgorny committed Dec 14, 2018
1 parent 8b992a6 commit 6fa89191fa81b6bbfb971e6616a7b0f2ed147d33
Showing with 6 additions and 3 deletions.
  1. +6 −3 lld/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, _ = tar_version.communicate()
if 'GNU tar' in sout.decode():
config.available_features.add('gnutar')
tar_version.wait()

0 comments on commit 6fa8919

Please sign in to comment.