@@ -45,7 +45,6 @@ const {
45
45
createDeferredCallback,
46
46
countCompletedTest,
47
47
isTestFailureError,
48
- parseCommandLine,
49
48
} = require ( 'internal/test_runner/utils' ) ;
50
49
const {
51
50
createDeferredPromise,
@@ -79,14 +78,6 @@ const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']);
79
78
const kUnwrapErrors = new SafeSet ( )
80
79
. add ( kTestCodeFailure ) . add ( kHookFailure )
81
80
. add ( 'uncaughtException' ) . add ( 'unhandledRejection' ) ;
82
- const {
83
- forceExit,
84
- sourceMaps,
85
- testNamePatterns,
86
- testSkipPatterns,
87
- only : testOnlyFlag ,
88
- updateSnapshots,
89
- } = parseCommandLine ( ) ;
90
81
let kResistStopPropagation ;
91
82
let assertObj ;
92
83
let findSourceMap ;
@@ -132,7 +123,7 @@ function lazyAssertObject(harness) {
132
123
const { getOptionValue } = require ( 'internal/options' ) ;
133
124
if ( getOptionValue ( '--experimental-test-snapshots' ) ) {
134
125
const { SnapshotManager } = require ( 'internal/test_runner/snapshot' ) ;
135
- harness . snapshotManager = new SnapshotManager ( updateSnapshots ) ;
126
+ harness . snapshotManager = new SnapshotManager ( harness . config . updateSnapshots ) ;
136
127
assertObj . set ( 'snapshot' , harness . snapshotManager . createAssert ( ) ) ;
137
128
}
138
129
}
@@ -406,16 +397,17 @@ class Test extends AsyncResource {
406
397
this . filtered = false ;
407
398
408
399
if ( parent === null ) {
400
+ this . root = this ;
401
+ this . harness = options . harness ;
402
+ this . config = this . harness . config ;
409
403
this . concurrency = 1 ;
410
404
this . nesting = 0 ;
411
- this . only = testOnlyFlag ;
405
+ this . only = this . config . only ;
412
406
this . reporter = new TestsStream ( ) ;
413
407
this . runOnlySubtests = this . only ;
414
408
this . childNumber = 0 ;
415
409
this . timeout = kDefaultTimeout ;
416
410
this . entryFile = entryFile ;
417
- this . root = this ;
418
- this . harness = options . harness ;
419
411
this . hooks = {
420
412
__proto__ : null ,
421
413
before : [ ] ,
@@ -428,6 +420,9 @@ class Test extends AsyncResource {
428
420
const nesting = parent . parent === null ? parent . nesting :
429
421
parent . nesting + 1 ;
430
422
423
+ this . root = parent . root ;
424
+ this . harness = null ;
425
+ this . config = this . root . harness . config ;
431
426
this . concurrency = parent . concurrency ;
432
427
this . nesting = nesting ;
433
428
this . only = only ?? ( parent . only && ! parent . runOnlySubtests ) ;
@@ -436,8 +431,6 @@ class Test extends AsyncResource {
436
431
this . childNumber = parent . subtests . length + 1 ;
437
432
this . timeout = parent . timeout ;
438
433
this . entryFile = parent . entryFile ;
439
- this . root = parent . root ;
440
- this . harness = null ;
441
434
this . hooks = {
442
435
__proto__ : null ,
443
436
before : [ ] ,
@@ -452,7 +445,7 @@ class Test extends AsyncResource {
452
445
this . parent . filteredSubtestCount ++ ;
453
446
}
454
447
455
- if ( testOnlyFlag && only === false ) {
448
+ if ( this . config . only && only === false ) {
456
449
fn = noop ;
457
450
}
458
451
}
@@ -522,7 +515,7 @@ class Test extends AsyncResource {
522
515
this . waitingOn = 0 ;
523
516
this . finished = false ;
524
517
525
- if ( ! testOnlyFlag && ( only || this . parent ?. runOnlySubtests ) ) {
518
+ if ( ! this . config . only && ( only || this . parent ?. runOnlySubtests ) ) {
526
519
const warning =
527
520
"'only' and 'runOnly' require the --test-only command-line option." ;
528
521
this . diagnostic ( warning ) ;
@@ -538,7 +531,7 @@ class Test extends AsyncResource {
538
531
file : loc [ 2 ] ,
539
532
} ;
540
533
541
- if ( sourceMaps === true ) {
534
+ if ( this . config . sourceMaps === true ) {
542
535
const map = lazyFindSourceMap ( this . loc . file ) ;
543
536
const entry = map ?. findEntry ( this . loc . line - 1 , this . loc . column - 1 ) ;
544
537
@@ -556,7 +549,9 @@ class Test extends AsyncResource {
556
549
}
557
550
558
551
willBeFiltered ( ) {
559
- if ( testOnlyFlag && ! this . only ) return true ;
552
+ if ( this . config . only && ! this . only ) return true ;
553
+
554
+ const { testNamePatterns, testSkipPatterns } = this . config ;
560
555
561
556
if ( testNamePatterns && ! testMatchesPattern ( this , testNamePatterns ) ) {
562
557
return true ;
@@ -920,7 +915,7 @@ class Test extends AsyncResource {
920
915
// This helps catch any asynchronous activity that occurs after the tests
921
916
// have finished executing.
922
917
this . postRun ( ) ;
923
- } else if ( forceExit ) {
918
+ } else if ( this . config . forceExit ) {
924
919
// This is the root test, and all known tests and hooks have finished
925
920
// executing. If the user wants to force exit the process regardless of
926
921
// any remaining ref'ed handles, then do that now. It is theoretically
@@ -1163,11 +1158,13 @@ class Suite extends Test {
1163
1158
constructor ( options ) {
1164
1159
super ( options ) ;
1165
1160
1166
- if ( testNamePatterns !== null && testSkipPatterns !== null && ! options . skip ) {
1161
+ if ( this . config . testNamePatterns !== null &&
1162
+ this . config . testSkipPatterns !== null &&
1163
+ ! options . skip ) {
1167
1164
this . fn = options . fn || this . fn ;
1168
1165
this . skipped = false ;
1169
1166
}
1170
- this . runOnlySubtests = testOnlyFlag ;
1167
+ this . runOnlySubtests = this . config . only ;
1171
1168
1172
1169
try {
1173
1170
const { ctx, args } = this . getRunArgs ( ) ;
@@ -1198,9 +1195,9 @@ class Suite extends Test {
1198
1195
this . filtered = false ;
1199
1196
this . parent . filteredSubtestCount -- ;
1200
1197
} else if (
1201
- testOnlyFlag &&
1202
- testNamePatterns == null &&
1203
- testSkipPatterns == null &&
1198
+ this . config . only &&
1199
+ this . config . testNamePatterns == null &&
1200
+ this . config . testSkipPatterns == null &&
1204
1201
this . filteredSubtestCount === this . subtests . length
1205
1202
) {
1206
1203
// If no subtests are marked as "only", run them all
0 commit comments