Skip to content

Commit 4959c37

Browse files
authored
Fix failing test on Mac when validating the path of a python interperter (#1958)
1 parent 3c882b5 commit 4959c37

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

news/3 Code Health/1957.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix failing test on Mac when validating the path of a python interperter.

src/test/common/process/pythonProc.simple.multiroot.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { expect, use } from 'chai';
55
import * as chaiAsPromised from 'chai-as-promised';
66
import { execFile } from 'child_process';
7+
import * as fs from 'fs-extra';
78
import { Container } from 'inversify';
89
import { EOL } from 'os';
910
import * as path from 'path';
@@ -114,11 +115,16 @@ suite('PythonExecutableService', () => {
114115

115116
test('Ensure correct path to executable is returned', async () => {
116117
const pythonPath = PythonSettings.getInstance(workspace4Path).pythonPath;
117-
const expectedExecutablePath = await new Promise<string>(resolve => {
118-
execFile(pythonPath, ['-c', 'import sys;print(sys.executable)'], (_error, stdout, _stdErr) => {
119-
resolve(stdout.trim());
118+
let expectedExecutablePath: string;
119+
if (await fs.pathExists(pythonPath)) {
120+
expectedExecutablePath = pythonPath;
121+
} else {
122+
expectedExecutablePath = await new Promise<string>(resolve => {
123+
execFile(pythonPath, ['-c', 'import sys;print(sys.executable)'], (_error, stdout, _stdErr) => {
124+
resolve(stdout.trim());
125+
});
120126
});
121-
});
127+
}
122128
const pythonExecService = await pythonExecFactory.create({ resource: workspace4PyFile });
123129
const executablePath = await pythonExecService.getExecutablePath();
124130
expect(executablePath).to.equal(expectedExecutablePath, 'Executable paths are not the same');

0 commit comments

Comments
 (0)