Set test environment variable to prevent double activation

When we add activation on startup finished we encountered a new bug with the test process that has existed for many years
it will activate twice and the extension will be in a bad state. we need to allow manual activation to inject the correct mock classes into the extension and prevent it from activating on startupfinished under test.
This commit is contained in:
Noah Gilson 2024-02-20 10:41:35 -08:00
Родитель 12e06d3e81
Коммит e4a0f6d365
3 изменённых файлов: 26 добавлений и 8 удалений

Просмотреть файл

@ -87,9 +87,16 @@ const configPrefix = 'dotnetAcquisitionExtension';
const displayChannelName = '.NET Runtime';
const defaultTimeoutValue = 600;
const moreInfoUrl = 'https://github.com/dotnet/vscode-dotnet-runtime/blob/main/Documentation/troubleshooting-runtime.md';
let disableActivationUnderTest = true;
export function activate(context: vscode.ExtensionContext, extensionContext?: IExtensionContext)
{
if(process.env['DOTNET_INSTALL_TOOL_UNDER_TEST'] === 'true' && disableActivationUnderTest)
{
return;
}
// Loading Extension Configuration
const extensionConfiguration = extensionContext !== undefined && extensionContext.extensionConfiguration ?
extensionContext.extensionConfiguration :
@ -416,3 +423,8 @@ export function activate(context: vscode.ExtensionContext, extensionContext?: IE
reportIssueRegistration,
...eventStreamObservers);
}
export function allowManualTestActivation()
{
disableActivationUnderTest = false;
}

Просмотреть файл

@ -73,6 +73,8 @@ suite('DotnetCoreAcquisitionExtension End to End', function() {
extensionPath,
logPath,
} as any;
extension.allowManualTestActivation();
extension.activate(extensionContext, {
telemetryReporter: new MockTelemetryReporter(),
extensionConfiguration: new MockExtensionConfiguration([{extensionId: 'alternative.extension', path: 'foo'}], true),

Просмотреть файл

@ -33,14 +33,18 @@ async function main() {
}
// Download VS Code, unzip it and run the integration test
await runTests({
...(platformValue !== '' && {platform: platformValue}),
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
// This disables all extensions except the one being testing
'--disable-extensions',
]});
await runTests(
{
...(platformValue !== '' && {platform: platformValue}),
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
// This disables all extensions except the one being testing
'--disable-extensions',
],
extensionTestsEnv : { DOTNET_INSTALL_TOOL_UNDER_TEST : 'true' }
}
);
} catch (err) {
console.error('Failed to run tests');
process.exit(1);