44 *--------------------------------------------------------------------------------------------*/
55
66import * as assert from 'assert' ;
7- import { window , tasks , Disposable , TaskDefinition , Task , EventEmitter , CustomExecution , Pseudoterminal , TaskScope , commands , Task2 , env , UIKind } from 'vscode' ;
7+ import { window , tasks , Disposable , TaskDefinition , Task , EventEmitter , CustomExecution , Pseudoterminal , TaskScope , commands , Task2 , env , UIKind , ShellExecution } from 'vscode' ;
88
99// Disable tasks tests:
1010// - Web https://github.com/microsoft/vscode/issues/90528
@@ -118,7 +118,7 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
118118 writeEmitter . fire ( 'exiting' ) ;
119119 closeEmitter . fire ( ) ;
120120 } ,
121- close : ( ) => { }
121+ close : ( ) => { }
122122 } ;
123123 return Promise . resolve ( pty ) ;
124124 } ) ;
@@ -137,5 +137,37 @@ import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomEx
137137 } ) ) ;
138138 commands . executeCommand ( 'workbench.action.tasks.runTask' , `${ taskType } : ${ taskName } ` ) ;
139139 } ) ;
140+
141+ test ( 'Execution from event is equal to original' , ( ) => {
142+ return new Promise ( async ( resolve , reject ) => {
143+ const task = new Task ( { type : 'testTask' } , TaskScope . Workspace , 'echo' , 'testTask' , new ShellExecution ( 'echo' , [ 'hello test' ] ) ) ;
144+ const taskExecution = await tasks . executeTask ( task ) ;
145+ let equalCount = 2 ;
146+ function checkEqualCount ( ) {
147+ equalCount -- ;
148+ if ( equalCount === 0 ) {
149+ resolve ( ) ;
150+ } else if ( equalCount < 0 ) {
151+ reject ( 'Unexpected extra task events.' ) ;
152+ }
153+ }
154+
155+ tasks . onDidStartTaskProcess ( e => {
156+ if ( e . execution === taskExecution ) {
157+ checkEqualCount ( ) ;
158+ } else {
159+ reject ( 'Unexpected task execution value in start process.' ) ;
160+ }
161+ } ) ;
162+
163+ tasks . onDidEndTaskProcess ( e => {
164+ if ( e . execution === taskExecution ) {
165+ checkEqualCount ( ) ;
166+ } else {
167+ reject ( 'Unexpected task execution value in end process.' ) ;
168+ }
169+ } ) ;
170+ } ) ;
171+ } ) ;
140172 } ) ;
141173} ) ;
0 commit comments