1- import * as vscode from 'vscode' ;
2- import { Disposable , OutputChannel , Uri , workspace } from 'vscode' ;
1+ import { CancellationToken , CancellationTokenSource , Disposable , OutputChannel , Uri , workspace } from 'vscode' ;
32import { PythonSettings } from '../../../common/configSettings' ;
43import { isNotInstalledError } from '../../../common/helpers' ;
5- import { IPythonSettings } from '../../../common/types' ;
6- import { IDisposableRegistry , IInstaller , IOutputChannel , Product } from '../../../common/types' ;
4+ import { IDisposableRegistry , IInstaller , IOutputChannel , IPythonSettings , Product } from '../../../common/types' ;
75import { IServiceContainer } from '../../../ioc/types' ;
86import { UNITTEST_DISCOVER , UNITTEST_RUN } from '../../../telemetry/constants' ;
97import { sendTelemetryEvent } from '../../../telemetry/index' ;
108import { TestDiscoverytTelemetry , TestRunTelemetry } from '../../../telemetry/types' ;
119import { CANCELLATION_REASON , CommandSource , TEST_OUTPUT_CHANNEL } from './../constants' ;
12- import { displayTestErrorMessage } from './../testUtils' ;
13- import { ITestCollectionStorageService , ITestDiscoveryService , ITestManager , ITestResultsService } from './../types' ;
14- import { TestDiscoveryOptions , TestProvider , Tests , TestStatus , TestsToRun } from './../types' ;
10+ import { ITestCollectionStorageService , ITestDiscoveryService , ITestManager , ITestResultsService , ITestsHelper , TestDiscoveryOptions , TestProvider , Tests , TestStatus , TestsToRun } from './../types' ;
1511
1612enum CancellationTokenType {
1713 testDiscovery ,
@@ -33,9 +29,9 @@ export abstract class BaseTestManager implements ITestManager {
3329 private tests ?: Tests ;
3430 // tslint:disable-next-line:variable-name
3531 private _status : TestStatus = TestStatus . Unknown ;
36- private testDiscoveryCancellationTokenSource ?: vscode . CancellationTokenSource ;
37- private testRunnerCancellationTokenSource ?: vscode . CancellationTokenSource ;
38- private _installer : IInstaller ;
32+ private testDiscoveryCancellationTokenSource ?: CancellationTokenSource ;
33+ private testRunnerCancellationTokenSource ?: CancellationTokenSource ;
34+ private _installer ! : IInstaller ;
3935 private discoverTestsPromise ?: Promise < Tests > ;
4036 private get installer ( ) : IInstaller {
4137 if ( ! this . _installer ) {
@@ -53,10 +49,10 @@ export abstract class BaseTestManager implements ITestManager {
5349 this . testCollectionStorage = this . serviceContainer . get < ITestCollectionStorageService > ( ITestCollectionStorageService ) ;
5450 this . _testResultsService = this . serviceContainer . get < ITestResultsService > ( ITestResultsService ) ;
5551 }
56- protected get testDiscoveryCancellationToken ( ) : vscode . CancellationToken | undefined {
52+ protected get testDiscoveryCancellationToken ( ) : CancellationToken | undefined {
5753 return this . testDiscoveryCancellationTokenSource ? this . testDiscoveryCancellationTokenSource . token : undefined ;
5854 }
59- protected get testRunnerCancellationToken ( ) : vscode . CancellationToken | undefined {
55+ protected get testRunnerCancellationToken ( ) : CancellationToken | undefined {
6056 return this . testRunnerCancellationTokenSource ? this . testRunnerCancellationTokenSource . token : undefined ;
6157 }
6258 public dispose ( ) {
@@ -66,7 +62,7 @@ export abstract class BaseTestManager implements ITestManager {
6662 return this . _status ;
6763 }
6864 public get workingDirectory ( ) : string {
69- const settings = PythonSettings . getInstance ( vscode . Uri . file ( this . rootDirectory ) ) ;
65+ const settings = PythonSettings . getInstance ( Uri . file ( this . rootDirectory ) ) ;
7066 return settings . unitTest . cwd && settings . unitTest . cwd . length > 0 ? settings . unitTest . cwd : this . rootDirectory ;
7167 }
7268 public stop ( ) {
@@ -133,9 +129,10 @@ export abstract class BaseTestManager implements ITestManager {
133129 }
134130 } ) ;
135131 if ( haveErrorsInDiscovering && ! quietMode ) {
136- displayTestErrorMessage ( 'There were some errors in discovering unit tests' ) ;
132+ const testsHelper = this . serviceContainer . get < ITestsHelper > ( ITestsHelper ) ;
133+ testsHelper . displayTestErrorMessage ( 'There were some errors in discovering unit tests' ) ;
137134 }
138- const wkspace = workspace . getWorkspaceFolder ( vscode . Uri . file ( this . rootDirectory ) ) ! . uri ;
135+ const wkspace = workspace . getWorkspaceFolder ( Uri . file ( this . rootDirectory ) ) ! . uri ;
139136 this . testCollectionStorage . storeTests ( wkspace , tests ) ;
140137 this . disposeCancellationToken ( CancellationTokenType . testDiscovery ) ;
141138 sendTelemetryEvent ( UNITTEST_DISCOVER , undefined , telementryProperties ) ;
@@ -159,7 +156,7 @@ export abstract class BaseTestManager implements ITestManager {
159156 // tslint:disable-next-line:prefer-template
160157 this . outputChannel . appendLine ( reason . toString ( ) ) ;
161158 }
162- const wkspace = workspace . getWorkspaceFolder ( vscode . Uri . file ( this . rootDirectory ) ) ! . uri ;
159+ const wkspace = workspace . getWorkspaceFolder ( Uri . file ( this . rootDirectory ) ) ! . uri ;
163160 this . testCollectionStorage . storeTests ( wkspace , null ) ;
164161 this . disposeCancellationToken ( CancellationTokenType . testDiscovery ) ;
165162 return Promise . reject ( reason ) ;
@@ -217,8 +214,9 @@ export abstract class BaseTestManager implements ITestManager {
217214 if ( this . testDiscoveryCancellationToken && this . testDiscoveryCancellationToken . isCancellationRequested ) {
218215 return Promise . reject < Tests > ( reason ) ;
219216 }
220- displayTestErrorMessage ( 'Errors in discovering tests, continuing with tests' ) ;
221- return < Tests > {
217+ const testsHelper = this . serviceContainer . get < ITestsHelper > ( ITestsHelper ) ;
218+ testsHelper . displayTestErrorMessage ( 'Errors in discovering tests, continuing with tests' ) ;
219+ return {
222220 rootTestFolders : [ ] , testFiles : [ ] , testFolders : [ ] , testFunctions : [ ] , testSuites : [ ] ,
223221 summary : { errors : 0 , failures : 0 , passed : 0 , skipped : 0 }
224222 } ;
@@ -250,9 +248,9 @@ export abstract class BaseTestManager implements ITestManager {
250248 private createCancellationToken ( tokenType : CancellationTokenType ) {
251249 this . disposeCancellationToken ( tokenType ) ;
252250 if ( tokenType === CancellationTokenType . testDiscovery ) {
253- this . testDiscoveryCancellationTokenSource = new vscode . CancellationTokenSource ( ) ;
251+ this . testDiscoveryCancellationTokenSource = new CancellationTokenSource ( ) ;
254252 } else {
255- this . testRunnerCancellationTokenSource = new vscode . CancellationTokenSource ( ) ;
253+ this . testRunnerCancellationTokenSource = new CancellationTokenSource ( ) ;
256254 }
257255 }
258256 private disposeCancellationToken ( tokenType : CancellationTokenType ) {
0 commit comments