@@ -22,7 +22,7 @@ import {
22
22
} from "./TestEventStreamReader" ;
23
23
import { ITestRunState } from "./TestRunState" ;
24
24
import { TestClass } from "../TestDiscovery" ;
25
- import { regexEscapedString , sourceLocationToVSCodeLocation } from "../../utilities/utilities" ;
25
+ import { sourceLocationToVSCodeLocation } from "../../utilities/utilities" ;
26
26
import { exec } from "child_process" ;
27
27
28
28
// All events produced by a swift-testing run will be one of these three types.
@@ -222,44 +222,13 @@ export class SwiftTestingOutputParser {
222
222
* a JSON event and injecting them in to the test run output.
223
223
* @param chunk A chunk of stdout emitted during a test run.
224
224
*/
225
- public parseStdout = ( ( ) => {
226
- const values = [
227
- ...Object . values ( TestSymbol )
228
- . filter ( symbol => symbol !== TestSymbol . none )
229
- . map ( symbol =>
230
- regexEscapedString (
231
- // Trim the ANSI reset code from the search since some lines
232
- // are fully colorized from the symbol to the end of line.
233
- SymbolRenderer . eventMessageSymbol ( symbol ) . replace (
234
- SymbolRenderer . resetANSIEscapeCode ,
235
- ""
236
- )
237
- )
238
- ) ,
239
- // It is possible there is no symbol for a line produced by swift-testing,
240
- // for instance if the user has a multi line comment before a failing expectation
241
- // only the first line of the printed comment will have a symbol, but to make the
242
- // indentation consistent the subsequent lines will have three spaces. We don't want
243
- // to treat this as output produced by the user during the test run, so omit these.
244
- // This isn't ideal since this will swallow lines the user prints if they start with
245
- // three spaces, but until we have user output as part of the JSON event stream we have
246
- // this workaround.
247
- " " ,
248
- ] ;
249
-
250
- // Build a regex of all the line beginnings that come out of swift-testing events.
251
- const isSwiftTestingLineBeginning = new RegExp ( `^${ values . join ( "|" ) } ` ) ;
252
-
253
- return ( chunk : string , runState : ITestRunState ) => {
254
- for ( const line of chunk . split ( "\n" ) ) {
255
- // Any line in stdout that fails to match as a swift-testing line is treated
256
- // as a user printed value and recorded to the test run output with no associated test.
257
- if ( line . trim ( ) . length > 0 && isSwiftTestingLineBeginning . test ( line ) === false ) {
258
- runState . recordOutput ( undefined , `${ line } \r\n` ) ;
259
- }
225
+ public parseStdout ( chunk : string , runState : ITestRunState ) {
226
+ for ( const line of chunk . split ( "\n" ) ) {
227
+ if ( line . trim ( ) . length > 0 ) {
228
+ runState . recordOutput ( undefined , `${ line } \r\n` ) ;
260
229
}
261
- } ;
262
- } ) ( ) ;
230
+ }
231
+ }
263
232
264
233
private createReader ( path : string ) : INamedPipeReader {
265
234
return process . platform === "win32"
@@ -328,16 +297,6 @@ export class SwiftTestingOutputParser {
328
297
return fullNameIndex ;
329
298
}
330
299
331
- private recordOutput (
332
- runState : ITestRunState ,
333
- messages : EventMessage [ ] ,
334
- testIndex : number | undefined
335
- ) {
336
- messages . forEach ( message => {
337
- runState . recordOutput ( testIndex , `${ MessageRenderer . render ( message ) } \r\n` ) ;
338
- } ) ;
339
- }
340
-
341
300
/**
342
301
* Partitions a collection of messages in to issues and details about the issues.
343
302
* This is used to print the issues first, followed by the details.
@@ -411,11 +370,11 @@ export class SwiftTestingOutputParser {
411
370
// Notify the runner that we've recieved all the test cases and
412
371
// are going to start running tests now.
413
372
this . testRunStarted ( ) ;
373
+ return ;
414
374
} else if ( item . payload . kind === "testStarted" ) {
415
375
const testName = this . testName ( item . payload . testID ) ;
416
376
const testIndex = runState . getTestItemIndex ( testName , undefined ) ;
417
377
runState . started ( testIndex , item . payload . instant . absolute ) ;
418
- this . recordOutput ( runState , item . payload . messages , testIndex ) ;
419
378
return ;
420
379
} else if ( item . payload . kind === "testCaseStarted" ) {
421
380
const testID = this . idFromOptionalTestCase (
@@ -424,13 +383,11 @@ export class SwiftTestingOutputParser {
424
383
) ;
425
384
const testIndex = this . getTestCaseIndex ( runState , testID ) ;
426
385
runState . started ( testIndex , item . payload . instant . absolute ) ;
427
- this . recordOutput ( runState , item . payload . messages , testIndex ) ;
428
386
return ;
429
387
} else if ( item . payload . kind === "testSkipped" ) {
430
388
const testName = this . testName ( item . payload . testID ) ;
431
389
const testIndex = runState . getTestItemIndex ( testName , undefined ) ;
432
390
runState . skipped ( testIndex ) ;
433
- this . recordOutput ( runState , item . payload . messages , testIndex ) ;
434
391
return ;
435
392
} else if ( item . payload . kind === "issueRecorded" ) {
436
393
const testID = this . idFromOptionalTestCase (
@@ -466,8 +423,6 @@ export class SwiftTestingOutputParser {
466
423
) ;
467
424
} ) ;
468
425
469
- this . recordOutput ( runState , messages , testIndex ) ;
470
-
471
426
if ( item . payload . _testCase && testID !== item . payload . testID ) {
472
427
const testIndex = this . getTestCaseIndex ( runState , item . payload . testID ) ;
473
428
messages . forEach ( message => {
@@ -478,7 +433,6 @@ export class SwiftTestingOutputParser {
478
433
} else if ( item . payload . kind === "testEnded" ) {
479
434
const testName = this . testName ( item . payload . testID ) ;
480
435
const testIndex = runState . getTestItemIndex ( testName , undefined ) ;
481
- this . recordOutput ( runState , item . payload . messages , testIndex ) ;
482
436
483
437
// When running a single test the testEnded and testCaseEnded events
484
438
// have the same ID, and so we'd end the same test twice.
@@ -494,7 +448,6 @@ export class SwiftTestingOutputParser {
494
448
item . payload . _testCase
495
449
) ;
496
450
const testIndex = this . getTestCaseIndex ( runState , testID ) ;
497
- this . recordOutput ( runState , item . payload . messages , testIndex ) ;
498
451
499
452
// When running a single test the testEnded and testCaseEnded events
500
453
// have the same ID, and so we'd end the same test twice.
@@ -505,8 +458,6 @@ export class SwiftTestingOutputParser {
505
458
runState . completed ( testIndex , { timestamp : item . payload . instant . absolute } ) ;
506
459
return ;
507
460
}
508
-
509
- this . recordOutput ( runState , item . payload . messages , undefined ) ;
510
461
}
511
462
}
512
463
}
0 commit comments