@@ -10,16 +10,12 @@ import * as util from '../../../src/common';
1010import * as api from 'vscode-cpptools' ;
1111import * as apit from 'vscode-cpptools/out/testApi' ;
1212import * as config from '../../../src/LanguageServer/configurations' ;
13- import { getActiveClient } from '../../../src/LanguageServer/extension' ;
14- import { initializeTemporaryCommandRegistrar } from '../../../src/commands' ;
1513
16- const defaultTimeout : number = 60000 ;
14+ const defaultTimeout : number = 100000 ;
1715
1816suite ( "multiline comment setting tests" , function ( ) : void {
1917 suiteSetup ( async function ( ) : Promise < void > {
2018 let extension : vscode . Extension < any > = vscode . extensions . getExtension ( "ms-vscode.cpptools" ) ;
21- util . setExtensionPath ( extension . extensionPath ) ;
22- initializeTemporaryCommandRegistrar ( ) ;
2319 if ( ! extension . isActive ) {
2420 await extension . activate ( ) ;
2521 }
@@ -93,20 +89,12 @@ function cppPropertiesPath(): string {
9389}
9490
9591async function changeCppProperties ( cppProperties : config . ConfigurationJson , disposables : vscode . Disposable [ ] ) : Promise < void > {
96- let promise : Promise < void > = new Promise < void > ( ( resolve , reject ) => {
97- disposables . push ( getActiveClient ( ) . ActiveConfigChanged ( name => {
98- if ( name === cppProperties . configurations [ 0 ] . name ) {
99- resolve ( ) ;
100- }
101- } ) ) ;
102-
103- // Can't trust the file watcher, so we need to allocate additional time for the backup watcher to fire.
104- setTimeout ( ( ) => { reject ( new Error ( "timeout" ) ) ; } , 4000 ) ;
105- } ) ;
10692 await util . writeFileText ( cppPropertiesPath ( ) , JSON . stringify ( cppProperties ) ) ;
10793 let contents : string = await util . readFileText ( cppPropertiesPath ( ) ) ;
10894 console . log ( " wrote c_cpp_properties.json: " + contents ) ;
109- return promise ;
95+
96+ // Sleep for 4000ms for file watcher
97+ return new Promise ( r => setTimeout ( r , 4000 ) ) ;
11098}
11199
112100/******************************************************************************/
@@ -188,15 +176,16 @@ suite("extensibility tests v3", function(): void {
188176 disposables . forEach ( d => d . dispose ( ) ) ;
189177 } ) ;
190178
191- test ( "Check provider" , async ( ) => {
179+ test ( "Check provider - main3.cpp " , async ( ) => {
192180 // Open a c++ file to start the language server.
193181 let path : string = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath + "/main3.cpp" ;
194182 let uri : vscode . Uri = vscode . Uri . file ( path ) ;
195183
196184 let testHook : apit . CppToolsTestHook = cpptools . getTestHook ( ) ;
197185 let testResult : any = new Promise < void > ( ( resolve , reject ) => {
198- disposables . push ( testHook . StatusChanged ( status => {
199- if ( status === apit . Status . IntelliSenseReady ) {
186+ disposables . push ( testHook . IntelliSenseStatusChanged ( result => {
187+ result = result as apit . IntelliSenseStatus ;
188+ if ( result . filename === "main3.cpp" && result . status === apit . Status . IntelliSenseReady ) {
200189 let expected : api . SourceFileConfigurationItem [ ] = [ { uri : uri . toString ( ) , configuration : defaultConfig } ] ;
201190 assert . deepEqual ( lastResult , expected ) ;
202191 assert . deepEqual ( lastBrowseResult , defaultFolderBrowseConfig ) ;
@@ -280,15 +269,16 @@ suite("extensibility tests v2", function(): void {
280269 disposables . forEach ( d => d . dispose ( ) ) ;
281270 } ) ;
282271
283- test ( "Check provider" , async ( ) => {
272+ test ( "Check provider - main2.cpp " , async ( ) => {
284273 // Open a c++ file to start the language server.
285274 let path : string = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath + "/main2.cpp" ;
286275 let uri : vscode . Uri = vscode . Uri . file ( path ) ;
287276
288277 let testHook : apit . CppToolsTestHook = cpptools . getTestHook ( ) ;
289278 let testResult : any = new Promise < void > ( ( resolve , reject ) => {
290- disposables . push ( testHook . StatusChanged ( status => {
291- if ( status === apit . Status . IntelliSenseReady ) {
279+ disposables . push ( testHook . IntelliSenseStatusChanged ( result => {
280+ result = result as apit . IntelliSenseStatus ;
281+ if ( result . filename === "main2.cpp" && result . status === apit . Status . IntelliSenseReady ) {
292282 let expected : api . SourceFileConfigurationItem [ ] = [ { uri : uri . toString ( ) , configuration : defaultConfig } ] ;
293283 assert . deepEqual ( lastResult , expected ) ;
294284 assert . deepEqual ( lastBrowseResult , defaultBrowseConfig ) ;
@@ -357,15 +347,16 @@ suite("extensibility tests v1", function(): void {
357347 disposables . forEach ( d => d . dispose ( ) ) ;
358348 } ) ;
359349
360- test ( "Check provider" , async ( ) => {
350+ test ( "Check provider - main1.cpp " , async ( ) => {
361351 // Open a c++ file to start the language server.
362352 let path : string = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath + "/main1.cpp" ;
363353 let uri : vscode . Uri = vscode . Uri . file ( path ) ;
364354
365355 let testHook : apit . CppToolsTestHook = cpptools . getTestHook ( ) ;
366356 let testResult : any = new Promise < void > ( ( resolve , reject ) => {
367- disposables . push ( testHook . StatusChanged ( status => {
368- if ( status === apit . Status . IntelliSenseReady ) {
357+ disposables . push ( testHook . IntelliSenseStatusChanged ( result => {
358+ result = result as apit . IntelliSenseStatus ;
359+ if ( result . filename === "main1.cpp" && result . status === apit . Status . IntelliSenseReady ) {
369360 let expected : api . SourceFileConfigurationItem [ ] = [ { uri : uri . toString ( ) , configuration : defaultConfig } ] ;
370361 assert . deepEqual ( lastResult , expected ) ;
371362 resolve ( ) ;
@@ -430,15 +421,16 @@ suite("extensibility tests v0", function(): void {
430421 await util . deleteFile ( cppPropertiesPath ( ) ) ;
431422 } ) ;
432423
433- test ( "Check provider" , async ( ) => {
424+ test ( "Check provider - main.cpp " , async ( ) => {
434425 // Open a C++ file to start the language server.
435426 let path : string = vscode . workspace . workspaceFolders [ 0 ] . uri . fsPath + "/main.cpp" ;
436427 let uri : vscode . Uri = vscode . Uri . file ( path ) ;
437428
438429 let testHook : apit . CppToolsTestHook = cpptools . getTestHook ( ) ;
439430 let testResult : any = new Promise < void > ( ( resolve , reject ) => {
440- disposables . push ( testHook . StatusChanged ( status => {
441- if ( status === apit . Status . IntelliSenseReady ) {
431+ disposables . push ( testHook . IntelliSenseStatusChanged ( result => {
432+ result = result as apit . IntelliSenseStatus ;
433+ if ( result . filename === "main.cpp" && result . status === apit . Status . IntelliSenseReady ) {
442434 let expected : api . SourceFileConfigurationItem [ ] = [ { uri : uri . toString ( ) , configuration : defaultConfig } ] ;
443435 assert . deepEqual ( lastResult , expected ) ;
444436 resolve ( ) ;
0 commit comments