Skip to content

Commit

Permalink
Fix failing test on Mac when validating the path of a python interper…
Browse files Browse the repository at this point in the history
…ter (#1958)
  • Loading branch information
DonJayamanne authored Jun 14, 2018
1 parent 3c882b5 commit 4959c37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/3 Code Health/1957.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix failing test on Mac when validating the path of a python interperter.
14 changes: 10 additions & 4 deletions src/test/common/process/pythonProc.simple.multiroot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { execFile } from 'child_process';
import * as fs from 'fs-extra';
import { Container } from 'inversify';
import { EOL } from 'os';
import * as path from 'path';
Expand Down Expand Up @@ -114,11 +115,16 @@ suite('PythonExecutableService', () => {

test('Ensure correct path to executable is returned', async () => {
const pythonPath = PythonSettings.getInstance(workspace4Path).pythonPath;
const expectedExecutablePath = await new Promise<string>(resolve => {
execFile(pythonPath, ['-c', 'import sys;print(sys.executable)'], (_error, stdout, _stdErr) => {
resolve(stdout.trim());
let expectedExecutablePath: string;
if (await fs.pathExists(pythonPath)) {
expectedExecutablePath = pythonPath;
} else {
expectedExecutablePath = await new Promise<string>(resolve => {
execFile(pythonPath, ['-c', 'import sys;print(sys.executable)'], (_error, stdout, _stdErr) => {
resolve(stdout.trim());
});
});
});
}
const pythonExecService = await pythonExecFactory.create({ resource: workspace4PyFile });
const executablePath = await pythonExecService.getExecutablePath();
expect(executablePath).to.equal(expectedExecutablePath, 'Executable paths are not the same');
Expand Down

0 comments on commit 4959c37

Please sign in to comment.