[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
Tue Oct 23 04:36:17 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL345019: [lit] Only return a found bash executable on Windows if it can understand… (authored by gbedwell, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52831?vs=169011&id=170604#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52831

Files:
  llvm/trunk/utils/lit/lit/LitConfig.py


Index: llvm/trunk/utils/lit/lit/LitConfig.py
===================================================================
--- llvm/trunk/utils/lit/lit/LitConfig.py
+++ llvm/trunk/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.170604.patch
Type: text/x-patch
Size: 1166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181023/302050bc/attachment.bin>


More information about the llvm-commits mailing list