Index: utils/lit/lit/LitConfig.py =================================================================== --- utils/lit/lit/LitConfig.py +++ utils/lit/lit/LitConfig.py @@ -120,6 +120,17 @@ 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.bashPath = '' + return self.bashPath def getToolsPath(self, dir, paths, tools): Index: utils/lit/lit/TestRunner.py =================================================================== --- utils/lit/lit/TestRunner.py +++ utils/lit/lit/TestRunner.py @@ -1073,18 +1073,14 @@ return out, err, exitCode, timeoutInfo def executeScript(test, litConfig, tmpBase, commands, cwd): - bashPath = litConfig.getBashPath() - isWin32CMDEXE = (litConfig.isWindows and not bashPath) script = tmpBase + '.script' - if isWin32CMDEXE: + if litConfig.isWindows: script += '.bat' # Write script file mode = 'w' - if litConfig.isWindows and not isWin32CMDEXE: - mode += 'b' # Avoid CRLFs when writing bash scripts. f = open(script, mode) - if isWin32CMDEXE: + if litConfig.isWindows: for i, ln in enumerate(commands): commands[i] = re.sub(kPdbgRegex, "echo '\\1' > nul && ", ln) if litConfig.echo_all_commands: @@ -1103,9 +1099,11 @@ f.write('\n') f.close() - if isWin32CMDEXE: + if litConfig.isWindows: command = ['cmd','/c', script] else: + bashPath = litConfig.getBashPath() + if bashPath: command = [bashPath, script] else: