Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing test on Mac when validating the path of a python interperter #1958

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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