Skip to content

Commit adb7be2

Browse files
author
Kartik Raj
authored
Auto discover tests on interpreter change (#9723)
* Auto discover tests on interpreter change * Oops'
1 parent 9238d01 commit adb7be2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/client/testing/main.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../common/extensions';
1111
import { traceError } from '../common/logger';
1212
import { IConfigurationService, IDisposableRegistry, IExperimentsManager, ILogger, IOutputChannel, Resource } from '../common/types';
1313
import { noop } from '../common/utils/misc';
14+
import { IInterpreterService } from '../interpreter/contracts';
1415
import { IServiceContainer } from '../ioc/types';
1516
import { EventName } from '../telemetry/constants';
1617
import { captureTelemetry, sendTelemetryEvent } from '../telemetry/index';
@@ -440,6 +441,7 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
440441
}
441442
public registerHandlers() {
442443
const documentManager = this.serviceContainer.get<IDocumentManager>(IDocumentManager);
444+
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
443445

444446
this.disposableRegistry.push(documentManager.onDidSaveTextDocument(this.onDocumentSaved.bind(this)));
445447
this.disposableRegistry.push(
@@ -450,5 +452,10 @@ export class UnitTestManagementService implements ITestManagementService, Dispos
450452
this.configChangedTimer = setTimeout(() => this.configurationChangeHandler(e), 1000);
451453
})
452454
);
455+
this.disposableRegistry.push(
456+
interpreterService.onDidChangeInterpreter(() =>
457+
this.autoDiscoverTests(undefined).catch(ex => traceError('Failed to auto discover tests upon changing interpreter', ex))
458+
)
459+
);
453460
}
454461
}

0 commit comments

Comments
 (0)