Skip to content

Commit fd33223

Browse files
kimadelineKartik Raj
authored andcommitted
Release cherry pick (#6515)
* Enable experiment for always displaying the test explorer (#6330) * Add logging
1 parent 9c11195 commit fd33223

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

experiments.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
[]
1+
[
2+
{
3+
"name": "AlwaysDisplayTestExplorer - experiment",
4+
"salt": "AlwaysDisplayTestExplorer",
5+
"min": 80,
6+
"max": 100
7+
},
8+
{
9+
"name": "AlwaysDisplayTestExplorer - control",
10+
"salt": "AlwaysDisplayTestExplorer",
11+
"min": 0,
12+
"max": 20
13+
}
14+
]

src/client/common/crypto.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { createHash } from 'crypto';
88
import { injectable } from 'inversify';
9+
import { traceError } from './logger';
910
import { ICryptoUtils, IHashFormat } from './types';
1011

1112
/**
@@ -15,6 +16,13 @@ import { ICryptoUtils, IHashFormat } from './types';
1516
export class CryptoUtils implements ICryptoUtils {
1617
public createHash<E extends keyof IHashFormat>(data: string, hashFormat: E): IHashFormat[E] {
1718
const hash = createHash('sha512').update(data).digest('hex');
18-
return hashFormat === 'number' ? parseInt(hash, 16) : hash as any;
19+
if (hashFormat === 'number') {
20+
const result = parseInt(hash, 16);
21+
if (isNaN(result)) {
22+
traceError(`Number hash for data '${data}' is NaN`);
23+
}
24+
return result as any;
25+
}
26+
return hash as any;
1927
}
2028
}

src/client/common/experimentGroups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ export const LSEnabled = 'LS - enabled';
44
// Experiment to check whether to always display the test explorer.
55
export enum AlwaysDisplayTestExplorerGroups {
66
control = 'AlwaysDisplayTestExplorer - control',
7-
enabled = 'AlwaysDisplayTestExplorer - enabled'
7+
experiment = 'AlwaysDisplayTestExplorer - experiment'
88
}

src/client/testing/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
7474
}
7575
public checkExperiments() {
7676
const experiments = this.serviceContainer.get<IExperimentsManager>(IExperimentsManager);
77-
if (experiments.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)) {
77+
if (experiments.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)) {
7878
const commandManager = this.serviceContainer.get<ICommandManager>(ICommandManager);
7979
commandManager.executeCommand('setContext', 'testsDiscovered', true).then(noop, noop);
8080
} else {

src/test/testing/main.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,22 @@ suite('Unit Tests - ManagementService', () => {
4747
});
4848

4949
test('Execute command if in experiment', async () => {
50-
when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).thenReturn(true);
50+
when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).thenReturn(true);
5151

5252
await testManagementService.activate(instance(mock(JediSymbolProvider)));
5353

5454
verify(commandManager.executeCommand('setContext', 'testsDiscovered', true)).once();
55-
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).once();
55+
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).once();
5656
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.control)).never();
5757
verify(experiment.sendTelemetryIfInExperiment(anything())).never();
5858
});
5959
test('If not in experiment, check and send Telemetry for control group and do not execute command', async () => {
60-
when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).thenReturn(false);
60+
when(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).thenReturn(false);
6161

6262
await testManagementService.activate(instance(mock(JediSymbolProvider)));
6363

6464
verify(commandManager.executeCommand('setContext', 'testsDiscovered', anything())).never();
65-
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.enabled)).once();
65+
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.experiment)).once();
6666
verify(experiment.inExperiment(AlwaysDisplayTestExplorerGroups.control)).never();
6767
verify(experiment.sendTelemetryIfInExperiment(AlwaysDisplayTestExplorerGroups.control)).once();
6868
});

0 commit comments

Comments
 (0)