[llvm] r345019 - [lit] Only return a found bash executable on Windows if it can understand Windows paths
Greg Bedwell via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 23 04:34:04 PDT 2018
Author: gbedwell
Date: Tue Oct 23 04:34:04 2018
New Revision: 345019
URL: http://llvm.org/viewvc/llvm-project?rev=345019&view=rev
Log:
[lit] Only return a found bash executable on Windows if it can understand Windows paths
Some versions of bash.exe, for example WSL's version expect paths in the form
/mnt/c/path/to/dir rather than c:\\path\\to\\dir so will cause failures
for any tests that require an external shell if used by lit. If we're on
Windows and looking for an external shell, check that the found version
of bash is able to parse a native path before returning that version.
This patch also partially reverts the behaviour of r228221 by
restoring the warning if bash cannot be found. This shouldn't pollute
the lit stderr anymore as we're now using internal shell by default on
Windows. If someone is explicitly specifying to use an external shell, it's
probably worth alerting them to the fact that bash could not be found.
Differential Revision: https://reviews.llvm.org/D52831
Modified:
llvm/trunk/utils/lit/lit/LitConfig.py
Modified: llvm/trunk/utils/lit/lit/LitConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/LitConfig.py?rev=345019&r1=345018&r2=345019&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/LitConfig.py (original)
+++ llvm/trunk/utils/lit/lit/LitConfig.py Tue Oct 23 04:34:04 2018
@@ -120,6 +120,22 @@ class LitConfig(object):
if self.bashPath is None:
self.bashPath = ''
+ # Check whether the found version of bash is able to cope with paths in
+ # the host path format. If not, don't return it as it can't be used to
+ # run scripts. For example, WSL's bash.exe requires '/mnt/c/foo' rather
+ # than 'C:\\foo' or 'C:/foo'.
+ if self.isWindows and self.bashPath:
+ command = [self.bashPath, '-c',
+ '[[ -f "%s" ]]' % self.bashPath.replace('\\', '\\\\')]
+ _, _, exitCode = lit.util.executeCommand(command)
+ if exitCode:
+ self.note('bash command failed: %s' % (
+ ' '.join('"%s"' % c for c in command)))
+ self.bashPath = ''
+
+ if not self.bashPath:
+ self.warning('Unable to find a usable version of bash.')
+
return self.bashPath
def getToolsPath(self, dir, paths, tools):
More information about the llvm-commits
mailing list