|
4 | 4 | import { expect, use } from 'chai'; |
5 | 5 | import * as chaiAsPromised from 'chai-as-promised'; |
6 | 6 | import { execFile } from 'child_process'; |
| 7 | +import * as fs from 'fs-extra'; |
7 | 8 | import { Container } from 'inversify'; |
8 | 9 | import { EOL } from 'os'; |
9 | 10 | import * as path from 'path'; |
@@ -114,11 +115,16 @@ suite('PythonExecutableService', () => { |
114 | 115 |
|
115 | 116 | test('Ensure correct path to executable is returned', async () => { |
116 | 117 | 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 | + }); |
120 | 126 | }); |
121 | | - }); |
| 127 | + } |
122 | 128 | const pythonExecService = await pythonExecFactory.create({ resource: workspace4PyFile }); |
123 | 129 | const executablePath = await pythonExecService.getExecutablePath(); |
124 | 130 | expect(executablePath).to.equal(expectedExecutablePath, 'Executable paths are not the same'); |
|
0 commit comments