From 941fcfa938113b00d14cd944399185fcf9f35085 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Tue, 29 Aug 2023 18:55:27 -0700 Subject: [PATCH] Fixes from TPIs (#21896) Closes https://github.com/microsoft/vscode-python/issues/21884 Closes https://github.com/microsoft/vscode-python/issues/21889 --- src/client/common/utils/localize.ts | 4 +++- .../creation/provider/condaCreationProvider.ts | 6 ++++-- .../creation/provider/venvCreationProvider.ts | 7 +++++-- .../creation/provider/condaCreationProvider.unit.test.ts | 6 ++++-- .../creation/provider/venvCreationProvider.unit.test.ts | 6 ++++-- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index eb8e94a85a52..4cda15e15ec0 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -468,7 +468,9 @@ export namespace CreateEnv { export const recreateDescription = l10n.t('Delete existing ".venv" environment and create a new one'); export const useExisting = l10n.t('Use Existing'); export const useExistingDescription = l10n.t('Use existing ".venv" environment with no changes to it'); - export const existingVenvQuickPickPlaceholder = l10n.t('Use or Recreate existing environment?'); + export const existingVenvQuickPickPlaceholder = l10n.t( + 'Choose an option to handle the existing ".venv" environment', + ); export const deletingEnvironmentProgress = l10n.t('Deleting existing ".venv" environment...'); export const errorDeletingEnvironment = l10n.t('Error while deleting existing ".venv" environment.'); } diff --git a/src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts b/src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts index 74a42808e609..7ca44c1b7eff 100644 --- a/src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts +++ b/src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts @@ -128,7 +128,9 @@ async function createCondaEnv( dispose(); if (proc?.exitCode !== 0) { traceError('Error while running venv creation script: ', progressAndTelemetry.getLastError()); - deferred.reject(progressAndTelemetry.getLastError()); + deferred.reject( + progressAndTelemetry.getLastError() || `Conda env creation failed with exitCode: ${proc?.exitCode}`, + ); } else { deferred.resolve(condaEnvPath); } @@ -249,7 +251,7 @@ async function createEnvironment(options?: CreateEnvironmentOptions): Promise { assert.isDefined(_error); _error!('bad arguments'); _complete!(); - await assert.isRejected(promise); + const result = await promise; + assert.ok(result?.error); assert.isTrue(showErrorMessageWithLogsStub.calledOnce); }); @@ -241,7 +242,8 @@ suite('Conda Creation provider tests', () => { _next!({ out: `${CONDA_ENV_CREATED_MARKER}new_environment`, source: 'stdout' }); _complete!(); - await assert.isRejected(promise); + const result = await promise; + assert.ok(result?.error); assert.isTrue(showErrorMessageWithLogsStub.calledOnce); }); }); diff --git a/src/test/pythonEnvironments/creation/provider/venvCreationProvider.unit.test.ts b/src/test/pythonEnvironments/creation/provider/venvCreationProvider.unit.test.ts index 280d05bf5935..de65887b7edc 100644 --- a/src/test/pythonEnvironments/creation/provider/venvCreationProvider.unit.test.ts +++ b/src/test/pythonEnvironments/creation/provider/venvCreationProvider.unit.test.ts @@ -226,7 +226,8 @@ suite('venv Creation provider tests', () => { assert.isDefined(_error); _error!('bad arguments'); _complete!(); - await assert.isRejected(promise); + const result = await promise; + assert.ok(result?.error); assert.isTrue(showErrorMessageWithLogsStub.calledOnce); assert.isTrue(deleteEnvironmentStub.notCalled); }); @@ -283,7 +284,8 @@ suite('venv Creation provider tests', () => { _next!({ out: `${VENV_CREATED_MARKER}new_environment`, source: 'stdout' }); _complete!(); - await assert.isRejected(promise); + const result = await promise; + assert.ok(result?.error); interpreterQuickPick.verifyAll(); progressMock.verifyAll(); assert.isTrue(showErrorMessageWithLogsStub.calledOnce);