[lit] Respect LLVM_LIT_TOOLS_DIR when looking for 'tar' on Windows.
authorIgor Kudrin <ikudrin@accesssoftek.com>
Thu, 26 Oct 2017 02:31:36 +0000 (02:31 +0000)
committerIgor Kudrin <ikudrin@accesssoftek.com>
Thu, 26 Oct 2017 02:31:36 +0000 (02:31 +0000)
Changes in D38977 expect 'tar' to be found in one of PATH directories.
On Windows, one might opt to use LLVM_LIT_TOOLS_DIR rather than add MSYS
tools directory to the PATH. In that case, tests for lld failed on run.

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

llvm-svn: 316635

lld/test/lit.cfg.py

index 0c6c6b5..05efee9 100644 (file)
@@ -83,8 +83,10 @@ if (lit.util.which('cvtres', config.environment['PATH'])) or \
 if (config.llvm_libxml2_enabled == '1'):
     config.available_features.add('libxml2')
 
-tar_version = subprocess.Popen(
-    ['tar', '--version'], stdout=subprocess.PIPE, env={'LANG': 'C'})
-if 'GNU tar' in tar_version.stdout.read().decode():
-    config.available_features.add('gnutar')
-tar_version.wait()
+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():
+        config.available_features.add('gnutar')
+    tar_version.wait()