[PATCH] D52831: [lit] Only return a found bash executable on Windows if it can understand Windows paths

Greg Bedwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 10 07:47:38 PDT 2018


gbedwell updated this revision to Diff 169011.
gbedwell added a comment.

Another iteration :)

This is the original solution, but with added warnings, essentially reverting the general behaviour of https://reviews.llvm.org/rL228221 - "Don't warn or note if bash is missing".

Now that we're using the internal shell by default on Windows, the only place the warnings turn up is in log output for those two lit tests that specifically use the external shell, so this shouldn't be a regression in behaviour.  If someone is enabling the external shell more widely and doesn't have bash available, it sounds like they'd want to know about it.  I've also verified that I don't see any differences in lit output with Ubuntu 18.04.


https://reviews.llvm.org/D52831

Files:
  utils/lit/lit/LitConfig.py


Index: utils/lit/lit/LitConfig.py
===================================================================
--- utils/lit/lit/LitConfig.py
+++ utils/lit/lit/LitConfig.py
@@ -120,6 +120,22 @@
         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):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52831.169011.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181010/ad79f3ad/attachment.bin>


More information about the llvm-commits mailing list