-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix venv tests for terminal activation #16747
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
Changes from all commits
86e448c
3eead17
d249e17
836c3a4
8587d1a
f1f9e80
fa20991
6ddc852
3913d27
01da446
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import * as fsapi from 'fs-extra'; | |
| import * as path from 'path'; | ||
| import { traceVerbose } from '../../../common/logger'; | ||
| import { getEnvironmentVariable, getOSType, getUserHomeDir, OSType } from '../../../common/utils/platform'; | ||
| import { exec, pathExists, readFile } from '../externalDependencies'; | ||
| import { exec, getPythonSetting, pathExists, readFile } from '../externalDependencies'; | ||
|
|
||
| import { PythonVersion, UNKNOWN_PYTHON_VERSION } from '../../base/info'; | ||
| import { parseVersion } from '../../base/info/pythonVersion'; | ||
|
|
@@ -238,6 +238,11 @@ export class Conda { | |
|
|
||
| // Produce a list of candidate binaries to be probed by exec'ing them. | ||
| async function* getCandidates() { | ||
| const customCondaPath = getPythonSetting<string>('condaPath'); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conda tests were only failing on Windows. One of the reasons was that conda binary was not picked up from |
||
| if (customCondaPath && customCondaPath !== 'conda') { | ||
| // If user has specified a custom conda path, use it first. | ||
| yield customCondaPath; | ||
| } | ||
| // Check unqualified filename first, in case it's on PATH. | ||
| yield 'conda'; | ||
| if (getOSType() === OSType.Windows) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,9 +24,8 @@ import { | |
| import { EXTENSION_ROOT_DIR_FOR_TESTS, TEST_TIMEOUT } from '../../../constants'; | ||
| import { sleep } from '../../../core'; | ||
| import { initialize, initializeTest } from '../../../initialize'; | ||
| import * as ExperimentHelpers from '../../../../client/common/experiments/helpers'; | ||
|
|
||
| suite.skip('Activation of Environments in Terminal', () => { | ||
| suite('Activation of Environments in Terminal', () => { | ||
| const file = path.join( | ||
| EXTENSION_ROOT_DIR_FOR_TESTS, | ||
| 'src', | ||
|
|
@@ -61,13 +60,12 @@ suite.skip('Activation of Environments in Terminal', () => { | |
| let experiments: IExperimentService; | ||
| const sandbox = sinon.createSandbox(); | ||
| suiteSetup(async () => { | ||
| sandbox.stub(ExperimentHelpers, 'inDiscoveryExperiment').resolves(false); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixed the other non-conda venv tests. Initially, when in discovery experiment, the resolver was slow and hence the tests were timing out. That has been fixed with https://github.com/microsoft/vscode-python-internalbacklog/issues/283 and hence tests now pass upon removing this line. |
||
| envPaths = await fs.readJson(envsLocation); | ||
| terminalSettings = vscode.workspace.getConfiguration('terminal', vscode.workspace.workspaceFolders![0].uri); | ||
| pythonSettings = vscode.workspace.getConfiguration('python', vscode.workspace.workspaceFolders![0].uri); | ||
| defaultShell.Windows = terminalSettings.inspect('integrated.shell.windows').globalValue; | ||
| defaultShell.Linux = terminalSettings.inspect('integrated.shell.linux').globalValue; | ||
| await terminalSettings.update('integrated.shell.linux', '/bin/bash', vscode.ConfigurationTarget.Global); | ||
| defaultShell.Windows = terminalSettings.inspect('integrated.defaultProfile.windows').globalValue; | ||
| defaultShell.Linux = terminalSettings.inspect('integrated.defaultProfile.linux').globalValue; | ||
| await terminalSettings.update('integrated.defaultProfile.linux', 'bash', vscode.ConfigurationTarget.Global); | ||
| experiments = (await initialize()).serviceContainer.get<IExperimentService>(IExperimentService); | ||
| }); | ||
|
|
||
|
|
@@ -105,11 +103,15 @@ suite.skip('Activation of Environments in Terminal', () => { | |
| vscode.ConfigurationTarget.WorkspaceFolder, | ||
| ); | ||
| await terminalSettings.update( | ||
| 'integrated.shell.windows', | ||
| 'integrated.defaultProfile.windows', | ||
| defaultShell.Windows, | ||
| vscode.ConfigurationTarget.Global, | ||
| ); | ||
| await terminalSettings.update('integrated.shell.linux', defaultShell.Linux, vscode.ConfigurationTarget.Global); | ||
| await terminalSettings.update( | ||
| 'integrated.defaultProfile.linux', | ||
| defaultShell.Linux, | ||
| vscode.ConfigurationTarget.Global, | ||
| ); | ||
| await pythonSettings.update('condaPath', undefined, vscode.ConfigurationTarget.Workspace); | ||
| if (experiments.inExperimentSync(DeprecatePythonPath.experiment)) { | ||
| await resetGlobalInterpreterPathSetting(); | ||
|
|
@@ -189,9 +191,10 @@ suite.skip('Activation of Environments in Terminal', () => { | |
| await testActivation(envPaths.virtualEnvPath); | ||
| }); | ||
| test('Should activate with conda', async () => { | ||
| // Powershell does not work with conda by default, hence use cmd. | ||
| await terminalSettings.update( | ||
| 'integrated.shell.windows', | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VSCode deprecated the old setting, which is when the tests started failing as conda tests needs |
||
| 'C:\\Windows\\System32\\cmd.exe', | ||
| 'integrated.defaultProfile.windows', | ||
| 'Command Prompt', | ||
| vscode.ConfigurationTarget.Global, | ||
| ); | ||
| await pythonSettings.update('condaPath', envPaths.condaExecPath, vscode.ConfigurationTarget.Workspace); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize all shells for conda activation (including powershell), so conda activation tests work even when not using cmd. We do not want to rely on this too much though (conda 🤷♂️) so still try to use cmd in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this addition need to be repeated in all the workflow files that have a
Prepare conda for venv testsstep?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 😬