From ee6a84b4fee5ae1c731ce767d5cab19a161bf0e9 Mon Sep 17 00:00:00 2001 From: Greg Bedwell Date: Tue, 23 Oct 2018 11:34:04 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345019 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/lit/lit/LitConfig.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py index e8fb1533a86..97c09108581 100644 --- a/utils/lit/lit/LitConfig.py +++ b/utils/lit/lit/LitConfig.py @@ -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): -- 2.11.0