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

Ensure escape on TOML and requirements is treated as cancel. #20739

Merged
merged 2 commits into from
Feb 27, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ async function createEnvironment(options?: CreateEnvironmentOptions): Promise<Cr
throw ex;
}

if (version === undefined) {
traceError('Python version was not selected for creating conda environment.');
return MultiStepAction.Cancel;
}
return MultiStepAction.Continue;
},
undefined,
Expand Down
4 changes: 4 additions & 0 deletions src/client/pythonEnvironments/creation/provider/venvUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export async function pickPackagesToInstall(
});
}
packages.push({ installType: 'toml', source: tomlPath });
} else {
return MultiStepAction.Cancel;
}
} catch (ex) {
if (ex === MultiStepAction.Back || ex === MultiStepAction.Cancel) {
Expand Down Expand Up @@ -192,6 +194,8 @@ export async function pickPackagesToInstall(
installList.forEach((i) => {
packages.push({ installType: 'requirements', installItem: i });
});
} else {
return MultiStepAction.Cancel;
}
} catch (ex) {
if (ex === MultiStepAction.Back || ex === MultiStepAction.Cancel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ suite('Conda Creation provider tests', () => {
});
pickPythonVersionStub.resolves(undefined);

assert.isUndefined(await condaProvider.createEnvironment());
await assert.isRejected(condaProvider.createEnvironment());
});

test('Create conda environment', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ suite('Venv Utils test', () => {
'[project]\nname = "spam"\nversion = "2020.0.0"\n[build-system]\nrequires = ["setuptools ~= 58.0", "cython ~= 0.29.0"]\n[project.optional-dependencies]\ntest = ["pytest"]\ndoc = ["sphinx", "furo"]',
);

showQuickPickWithBackStub.rejects(windowApis.MultiStepAction.Cancel);
showQuickPickWithBackStub.resolves(undefined);

await assert.isRejected(pickPackagesToInstall(workspace1));
assert.isTrue(
Expand Down Expand Up @@ -215,7 +215,7 @@ suite('Venv Utils test', () => {
return Promise.resolve([]);
});

showQuickPickWithBackStub.rejects(windowApis.MultiStepAction.Cancel);
showQuickPickWithBackStub.resolves(undefined);

await assert.isRejected(pickPackagesToInstall(workspace1));
assert.isTrue(
Expand Down