@@ -44,6 +44,8 @@ import { PytestTestDiscoveryAdapter } from './pytest/pytestDiscoveryAdapter';
4444import { PytestTestExecutionAdapter } from './pytest/pytestExecutionAdapter' ;
4545import { WorkspaceTestAdapter } from './workspaceTestAdapter' ;
4646import { ITestDebugLauncher } from '../common/types' ;
47+ import { pythonTestAdapterRewriteEnabled } from './common/utils' ;
48+ import { IServiceContainer } from '../../ioc/types' ;
4749
4850// Types gymnastics to make sure that sendTriggerTelemetry only accepts the correct types.
4951type EventPropertyType = IEventNamePropertyMapping [ EventName . UNITTEST_DISCOVERY_TRIGGER ] ;
@@ -93,6 +95,7 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
9395 @inject ( IPythonExecutionFactory ) private readonly pythonExecFactory : IPythonExecutionFactory ,
9496 @inject ( ITestDebugLauncher ) private readonly debugLauncher : ITestDebugLauncher ,
9597 @inject ( ITestOutputChannel ) private readonly testOutputChannel : ITestOutputChannel ,
98+ @inject ( IServiceContainer ) private readonly serviceContainer : IServiceContainer ,
9699 ) {
97100 this . refreshCancellation = new CancellationTokenSource ( ) ;
98101
@@ -241,12 +244,11 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
241244 if ( uri ) {
242245 const settings = this . configSettings . getSettings ( uri ) ;
243246 traceVerbose ( `Testing: Refreshing test data for ${ uri . fsPath } ` ) ;
244- const rewriteTestingEnabled = process . env . ENABLE_PYTHON_TESTING_REWRITE ;
245247 if ( settings . testing . pytestEnabled ) {
246248 // Ensure we send test telemetry if it gets disabled again
247249 this . sendTestDisabledTelemetry = true ;
248- if ( rewriteTestingEnabled ) {
249- // ** rewriteTestingEnabled set to true to use NEW test discovery mechanism
250+ // ** experiment to roll out NEW test discovery mechanism
251+ if ( pythonTestAdapterRewriteEnabled ( this . serviceContainer ) ) {
250252 const workspace = this . workspaceService . getWorkspaceFolder ( uri ) ;
251253 traceVerbose ( `Discover tests for workspace name: ${ workspace ?. name } - uri: ${ uri . fsPath } ` ) ;
252254 const testAdapter =
@@ -263,8 +265,8 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
263265 } else if ( settings . testing . unittestEnabled ) {
264266 // ** Ensure we send test telemetry if it gets disabled again
265267 this . sendTestDisabledTelemetry = true ;
266- if ( rewriteTestingEnabled ) {
267- // ** rewriteTestingEnabled set to true to use NEW test discovery mechanism
268+ // ** experiment to roll out NEW test discovery mechanism
269+ if ( pythonTestAdapterRewriteEnabled ( this . serviceContainer ) ) {
268270 const workspace = this . workspaceService . getWorkspaceFolder ( uri ) ;
269271 traceVerbose ( `Discover tests for workspace name: ${ workspace ?. name } - uri: ${ uri . fsPath } ` ) ;
270272 const testAdapter =
@@ -388,14 +390,13 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
388390
389391 const settings = this . configSettings . getSettings ( workspace . uri ) ;
390392 if ( testItems . length > 0 ) {
391- const rewriteTestingEnabled = process . env . ENABLE_PYTHON_TESTING_REWRITE ;
392393 if ( settings . testing . pytestEnabled ) {
393394 sendTelemetryEvent ( EventName . UNITTEST_RUN , undefined , {
394395 tool : 'pytest' ,
395396 debugging : request . profile ?. kind === TestRunProfileKind . Debug ,
396397 } ) ;
397- // ** rewriteTestingEnabled set to true to use NEW test discovery mechanism
398- if ( rewriteTestingEnabled ) {
398+ // ** experiment to roll out NEW test discovery mechanism
399+ if ( pythonTestAdapterRewriteEnabled ( this . serviceContainer ) ) {
399400 const testAdapter =
400401 this . testAdapters . get ( workspace . uri ) ||
401402 ( this . testAdapters . values ( ) . next ( ) . value as WorkspaceTestAdapter ) ;
@@ -425,8 +426,8 @@ export class PythonTestController implements ITestController, IExtensionSingleAc
425426 tool : 'unittest' ,
426427 debugging : request . profile ?. kind === TestRunProfileKind . Debug ,
427428 } ) ;
428- // ** rewriteTestingEnabled set to true to use NEW test discovery mechanism
429- if ( rewriteTestingEnabled ) {
429+ // ** experiment to roll out NEW test discovery mechanism
430+ if ( pythonTestAdapterRewriteEnabled ( this . serviceContainer ) ) {
430431 const testAdapter =
431432 this . testAdapters . get ( workspace . uri ) ||
432433 ( this . testAdapters . values ( ) . next ( ) . value as WorkspaceTestAdapter ) ;
0 commit comments