Skip to content

Commit

Permalink
Making sure PreStartupHealthCheck works correctly (#4181)
Browse files Browse the repository at this point in the history
For #4177
  • Loading branch information
Kartik Raj authored and DonJayamanne committed Jan 28, 2019
1 parent 4d62591 commit d919a2f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/client/application/diagnostics/applicationDiagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ApplicationDiagnostics implements IApplicationDiagnostics {
}
public async performPreStartupHealthCheck(resource: Resource): Promise<void> {
// When testing, do not perform health checks, as modal dialogs can be displayed.
if (!isTestExecution()) {
if (isTestExecution()) {
return;
}
const services = this.serviceContainer.getAll<IDiagnosticsService>(IDiagnosticsService);
Expand All @@ -31,7 +31,7 @@ export class ApplicationDiagnostics implements IApplicationDiagnostics {
// Perform these validation checks in the background.
this.runDiagnostics(services.filter(item => item.runInBackground), resource).ignoreErrors();
}
private async runDiagnostics(diagnosticServices: IDiagnosticsService[], resource: Resource): Promise<void>{
private async runDiagnostics(diagnosticServices: IDiagnosticsService[], resource: Resource): Promise<void> {
await Promise.all(diagnosticServices.map(async diagnosticService => {
const diagnostics = await diagnosticService.diagnose(resource);
if (diagnostics.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ suite('Application Diagnostics - ApplicationDiagnostics', () => {
let outputChannel: typemoq.IMock<IOutputChannel>;
let logger: typemoq.IMock<ILogger>;
let appDiagnostics: IApplicationDiagnostics;
const oldValueOfVSC_PYTHON_UNIT_TEST = process.env.VSC_PYTHON_UNIT_TEST;
const oldValueOfVSC_PYTHON_CI_TEST = process.env.VSC_PYTHON_CI_TEST;

setup(() => {
process.env.VSC_PYTHON_UNIT_TEST = undefined;
process.env.VSC_PYTHON_CI_TEST = undefined;
serviceContainer = typemoq.Mock.ofType<IServiceContainer>();
envHealthCheck = typemoq.Mock.ofType<IDiagnosticsService>();
envHealthCheck.setup(service => service.runInBackground).returns(() => true);
Expand All @@ -52,6 +56,11 @@ suite('Application Diagnostics - ApplicationDiagnostics', () => {
appDiagnostics = new ApplicationDiagnostics(serviceContainer.object, outputChannel.object);
});

teardown(() => {
process.env.VSC_PYTHON_UNIT_TEST = oldValueOfVSC_PYTHON_UNIT_TEST;
process.env.VSC_PYTHON_CI_TEST = oldValueOfVSC_PYTHON_CI_TEST;
});

test('Register should register source maps', () => {
const sourceMapService = typemoq.Mock.ofType<ISourceMapSupportService>();
sourceMapService.setup(s => s.register()).verifiable(typemoq.Times.once());
Expand Down
2 changes: 1 addition & 1 deletion src/test/interpreters/autoSelection/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { InterpreterHelper } from '../../../client/interpreter/helpers';

const preferredGlobalInterpreter = 'preferredGlobalPyInterpreter';

suite('xInterpreters - Auto Selection', () => {
suite('Interpreters - Auto Selection', () => {
let autoSelectionService: InterpreterAutoSelectionServiceTest;
let workspaceService: IWorkspaceService;
let stateFactory: IPersistentStateFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
import { InterpreterHelper } from '../../../../client/interpreter/helpers';
import { KnownPathsService } from '../../../../client/interpreter/locators/services/KnownPathsService';

suite('xInterpreters - Auto Selection - Workspace Virtual Envs Rule', () => {
suite('Interpreters - Auto Selection - Workspace Virtual Envs Rule', () => {
let rule: WorkspaceVirtualEnvInterpretersAutoSelectionRuleTest;
let stateFactory: IPersistentStateFactory;
let fs: IFileSystem;
Expand Down
2 changes: 1 addition & 1 deletion src/test/interpreters/pipEnvService.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum OS {
Mac, Windows, Linux
}

suite('xInterpreters - PipEnv', () => {
suite('Interpreters - PipEnv', () => {
const rootWorkspace = Uri.file(path.join('usr', 'desktop', 'wkspc1')).fsPath;
getNamesAndValues(OS).forEach(os => {
[undefined, Uri.file(path.join(rootWorkspace, 'one.py'))].forEach(resource => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/telemetry/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EXTENSION_ROOT_DIR } from '../../client/constants';
import { sendTelemetryEvent } from '../../client/telemetry';
import { correctPathForOsType } from '../common';

suite('xTelemetry', () => {
suite('Telemetry', () => {
const oldValueOfVSC_PYTHON_UNIT_TEST = process.env.VSC_PYTHON_UNIT_TEST;
const oldValueOfVSC_PYTHON_CI_TEST = process.env.VSC_PYTHON_CI_TEST;
setup(() => {
Expand Down

0 comments on commit d919a2f

Please sign in to comment.