зеркало из https://github.com/Azure/azure-dev.git
Run "env refresh" command as task (#2060)
This gives the user a chance to interact with the command and fixes https://github.com/Azure/azure-dev/issues/2045 Also refactors the code that runs VS Code unit tests, and upgrades `test-electron` library to fix tests failing with `Error: spawn UNKNOWN` message on Windows
This commit is contained in:
Родитель
c669a0af21
Коммит
f8ebe0208d
|
@ -5,4 +5,5 @@ hostapi
|
|||
azureresourcegroups
|
||||
azureresources
|
||||
walkthrough
|
||||
walkthroughs
|
||||
walkthroughs
|
||||
DEBUGTELEMETRY
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
"DEBUGTELEMETRY": "true"
|
||||
},
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js"
|
||||
]
|
||||
"${workspaceFolder}/dist/**/*.js",
|
||||
"${workspaceFolder}/*.js"
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Run AZD + Azure Resources Extensions",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/../../../../vscode-azureresourcegroups",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}/../../../vscode-azureresourcegroups",
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
],
|
||||
"preLaunchTask": "${defaultBuildTask}",
|
||||
|
@ -35,7 +36,13 @@
|
|||
// Disable telemetry when running the extension under the debugger.
|
||||
// Set this to "verbose" to show telemetry in the console during debugging.
|
||||
"DEBUGTELEMETRY": "true"
|
||||
}
|
||||
},
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/dist/**/*.js",
|
||||
"${workspaceFolder}/*.js",
|
||||
"${workspaceFolder}/../../../vscode-azureresourcegroups/dist/**/*.js",
|
||||
"${workspaceFolder}/../../../vscode-azureresourcegroups/*.js"
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "Debug Unit Tests",
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -485,7 +485,7 @@
|
|||
"@types/vscode": "~1.76",
|
||||
"@typescript-eslint/eslint-plugin": "~5",
|
||||
"@typescript-eslint/parser": "~5",
|
||||
"@vscode/test-electron": "~2.1",
|
||||
"@vscode/test-electron": "~2.3",
|
||||
"@vscode/vsce": "~2",
|
||||
"chai": "~4.3",
|
||||
"copy-webpack-plugin": "~11.0",
|
||||
|
|
|
@ -168,32 +168,23 @@ export async function refreshEnvironment(context: IActionContext, selectedItem?:
|
|||
if (!folder) {
|
||||
folder = await quickPickWorkspaceFolder(context, vscode.l10n.t("To run '{0}' command you must first open a folder or workspace in VS Code", 'env refresh'));
|
||||
}
|
||||
const cwd = folder.uri.fsPath;
|
||||
|
||||
const azureCli = await createAzureDevCli(context);
|
||||
const progressOptions: vscode.ProgressOptions = {
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: vscode.l10n.t('Refreshing environment values...'),
|
||||
};
|
||||
azureCli.commandBuilder.withArg('env').withArg('refresh');
|
||||
|
||||
let command = azureCli.commandBuilder.withArg('env').withArg('refresh');
|
||||
if (selectedEnvironment) {
|
||||
azureCli.commandBuilder.withNamedArg('--environment', selectedEnvironment.name);
|
||||
command = command.withNamedArg('--environment', selectedEnvironment.name);
|
||||
}
|
||||
|
||||
let errorMsg: string | undefined = undefined;
|
||||
|
||||
await vscode.window.withProgress(progressOptions, async () => {
|
||||
try {
|
||||
await spawnAsync(azureCli.commandBuilder.build(), azureCli.spawnOptions(cwd));
|
||||
} catch(err) {
|
||||
errorMsg = parseError(err).message;
|
||||
void executeAsTask(command.build(), getAzDevTerminalTitle(), {
|
||||
focus: true,
|
||||
alwaysRunNew: true,
|
||||
cwd: folder.uri.fsPath,
|
||||
env: azureCli.env
|
||||
}, TelemetryId.EnvRefreshCli).then(() => {
|
||||
if (selectedEnvironment) {
|
||||
selectedEnvironment.context.refreshEnvironments();
|
||||
}
|
||||
});
|
||||
if (errorMsg) {
|
||||
await promptCreateNewEnvironment(
|
||||
vscode.l10n.t('Environment values could not be refreshed. Infrastructure might have never been provisioned in Azure, or there might be no environments. Would you like to create one?'), errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
async function promptCreateNewEnvironment(message: string, details?: string): Promise<void> {
|
||||
|
|
|
@ -54,6 +54,9 @@ export enum TelemetryId {
|
|||
|
||||
// Reported when 'env new' CLI command is invoked.
|
||||
EnvNewCli = 'azure-dev.commands.cli.env-new.task',
|
||||
|
||||
// Reported when 'env refresh' CLI command is invoked.
|
||||
EnvRefreshCli = 'azure-dev.commands.cli.env-refresh.task',
|
||||
|
||||
// Reported when the product evaluates whether to prompt the user for a survey.
|
||||
// We capture
|
||||
|
|
|
@ -1,26 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
import { runTests } from '@vscode/test-electron';
|
||||
import { runExtensionTests } from "./runExtensionTests";
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
||||
|
||||
// The path to test runner
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './suite/allTests');
|
||||
|
||||
// Download VS Code, unzip it and run the integration test
|
||||
await runTests({ extensionDevelopmentPath, extensionTestsPath });
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests');
|
||||
process.exit(1);
|
||||
}
|
||||
try {
|
||||
await runExtensionTests('suite', 'allTests');
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests: ', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void main();
|
||||
void main();
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
import { runTests, downloadAndUnzipVSCode } from '@vscode/test-electron';
|
||||
|
||||
export async function runExtensionTests(...testPath: string[] ) {
|
||||
try {
|
||||
const vsCodePath = await downloadAndUnzipVSCode('stable');
|
||||
|
||||
// The folder containing the Extension Manifest package.json
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '..', '..');
|
||||
|
||||
// The path to test runner
|
||||
const extensionTestsPath = path.resolve(__dirname, ...testPath);
|
||||
|
||||
await runTests({
|
||||
vscodeExecutablePath: vsCodePath,
|
||||
extensionDevelopmentPath: extensionDevelopmentPath,
|
||||
extensionTestsPath: extensionTestsPath,
|
||||
extensionTestsEnv: {
|
||||
DEBUGTELEMETRY: 'true',
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests: ', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
|
@ -1,26 +1,15 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
import { runTests } from '@vscode/test-electron';
|
||||
import { runExtensionTests } from "./runExtensionTests";
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// The folder containing the Extension Manifest package.json
|
||||
// Passed to `--extensionDevelopmentPath`
|
||||
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
|
||||
|
||||
// The path to test runner
|
||||
// Passed to --extensionTestsPath
|
||||
const extensionTestsPath = path.resolve(__dirname, './suite/unitTests');
|
||||
|
||||
// Download VS Code, unzip it and run unit tests
|
||||
await runTests({ extensionDevelopmentPath, extensionTestsPath });
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests');
|
||||
process.exit(1);
|
||||
}
|
||||
try {
|
||||
await runExtensionTests('suite', 'unitTests');
|
||||
} catch (err) {
|
||||
console.error('Failed to run tests: ', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void main();
|
||||
void main();
|
||||
|
|
|
@ -17,7 +17,7 @@ export function run(): Promise<void> {
|
|||
const testsRoot = path.resolve(__dirname, '..');
|
||||
|
||||
return new Promise((c, e) => {
|
||||
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
||||
glob('suite/**/**.test.js', { cwd: testsRoot }, (err, files) => {
|
||||
if (err) {
|
||||
return e(err);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче