@@ -187,19 +187,22 @@ export function runTests(server: OmnisharpServer, testType) {
187
187
188
188
return server . makeRequest < proto . GetTestContextResponse > ( proto . GetTestContext , request ) . then ( value => {
189
189
let cwd = dirname ( activeEditor . document . fileName ) ;
190
- return runCommandInOutputChannel ( value . TestCommand , channel , cwd ) ;
190
+ return runTestsInOutputChannel ( value . TestCommand , channel , cwd ) ;
191
191
} ) ;
192
192
}
193
193
194
- export function runCommandInOutputChannel ( command : string , channel : OutputChannel , cwd : string ) : Promise < ChildProcess > {
194
+ export function runTestsInOutputChannel ( command : string , channel : OutputChannel , cwd : string ) : Promise < ChildProcess > {
195
195
196
196
return new Promise < ChildProcess > ( ( resolve , reject ) => {
197
+
198
+ window . setStatusBarMessage ( "Running tests..." ) ;
199
+
197
200
let args = command . split ( " " ) ;
198
201
let cmd = args . shift ( ) ;
199
202
let childprocess : ChildProcess ;
200
203
try {
201
204
channel . appendLine ( "[INFO] Running command: " + command ) ;
202
- childprocess = spawn ( cmd , args , { cwd : cwd } ) ;
205
+ childprocess = spawn ( cmd , args , { cwd : cwd } ) ;
203
206
} catch ( e ) {
204
207
channel . appendLine ( "[ERROR]" + e ) ;
205
208
}
@@ -209,9 +212,31 @@ export function runCommandInOutputChannel(command: string, channel: OutputChanne
209
212
} ) ;
210
213
211
214
childprocess . stdout . on ( 'data' , ( data : NodeBuffer ) => {
212
- channel . append ( data . toString ( ) ) ;
215
+ var line = data . toString ( ) ;
216
+ var match = parseTestsResults ( line ) ;
217
+ if ( match . success ) {
218
+ if ( match . errors + match . failures > 0 )
219
+ channel . show ( ) ;
220
+
221
+ window . setStatusBarMessage ( line ) ;
222
+ }
223
+ channel . append ( line ) ;
213
224
} ) ;
214
225
215
226
resolve ( childprocess ) ;
216
227
} ) ;
228
+ }
229
+
230
+
231
+ function parseTestsResults ( text : string ) : any {
232
+
233
+ const finalResultRegex = / (?: T o t a l | T e s t s r u n ) : \d + , E r r o r s : ( \d + ) , (?: F a i l e d | F a i l u r e s ) : ( \d + ) / i;
234
+
235
+ var match = text . match ( finalResultRegex ) ;
236
+ if ( match && match . length > 0 ) {
237
+ var errors = parseInt ( match [ 1 ] ) ;
238
+ var failures = parseInt ( match [ 2 ] ) ;
239
+ return { success : true , errors, failures } ;
240
+ }
241
+ return { success : false , errors : 0 , failures : 0 } ;
217
242
}
0 commit comments