@@ -110,14 +110,19 @@ function filterExecArgv(arg, i, arr) {
110
110
! ArrayPrototypeSome ( kFilterArgValues , ( p ) => arg === p || ( i > 0 && arr [ i - 1 ] === p ) || StringPrototypeStartsWith ( arg , `${ p } =` ) ) ;
111
111
}
112
112
113
- function getRunArgs ( { path, inspectPort, testNamePatterns } ) {
113
+ function getRunArgs ( { path, inspectPort, testNamePatterns, bail } ) {
114
114
const argv = ArrayPrototypeFilter ( process . execArgv , filterExecArgv ) ;
115
115
if ( isUsingInspector ( ) ) {
116
116
ArrayPrototypePush ( argv , `--inspect-port=${ getInspectPort ( inspectPort ) } ` ) ;
117
117
}
118
118
if ( testNamePatterns ) {
119
119
ArrayPrototypeForEach ( testNamePatterns , ( pattern ) => ArrayPrototypePush ( argv , `--test-name-pattern=${ pattern } ` ) ) ;
120
120
}
121
+
122
+ if ( bail ) {
123
+ ArrayPrototypePush ( argv , '--test-bail' ) ;
124
+ }
125
+
121
126
ArrayPrototypePush ( argv , path ) ;
122
127
123
128
return argv ;
@@ -301,10 +306,10 @@ class FileTest extends Test {
301
306
}
302
307
}
303
308
304
- function runTestFile ( path , root , inspectPort , filesWatcher , testNamePatterns ) {
309
+ function runTestFile ( path , root , inspectPort , filesWatcher , testNamePatterns , bail ) {
305
310
const watchMode = filesWatcher != null ;
306
311
const subtest = root . createSubtest ( FileTest , path , async ( t ) => {
307
- const args = getRunArgs ( { __proto__ : null , path, inspectPort, testNamePatterns } ) ;
312
+ const args = getRunArgs ( { __proto__ : null , path, inspectPort, testNamePatterns, bail } ) ;
308
313
const stdio = [ 'pipe' , 'pipe' , 'pipe' ] ;
309
314
const env = { __proto__ : null , ...process . env , NODE_TEST_CONTEXT : 'child-v8' } ;
310
315
if ( watchMode ) {
@@ -381,7 +386,7 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) {
381
386
return subtest . start ( ) ;
382
387
}
383
388
384
- function watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns ) {
389
+ function watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns , bail ) {
385
390
const runningProcesses = new SafeMap ( ) ;
386
391
const runningSubtests = new SafeMap ( ) ;
387
392
const watcher = new FilesWatcher ( { __proto__ : null , debounce : 200 , mode : 'filter' , signal } ) ;
@@ -403,7 +408,7 @@ function watchFiles(testFiles, root, inspectPort, signal, testNamePatterns) {
403
408
root . harness . counters . topLevel = 0 ;
404
409
}
405
410
await runningSubtests . get ( file ) ;
406
- runningSubtests . set ( file , runTestFile ( file , root , inspectPort , filesWatcher , testNamePatterns ) ) ;
411
+ runningSubtests . set ( file , runTestFile ( file , root , inspectPort , filesWatcher , testNamePatterns , bail ) ) ;
407
412
} , undefined , ( error ) => {
408
413
triggerUncaughtException ( error , true /* fromPromise */ ) ;
409
414
} ) ) ;
@@ -425,14 +430,19 @@ function run(options) {
425
430
options = kEmptyObject ;
426
431
}
427
432
let { testNamePatterns, shard } = options ;
428
- const { concurrency, timeout, signal, files, inspectPort, watch, setup } = options ;
433
+ const { concurrency, timeout, signal, files, inspectPort, watch, setup, bail } = options ;
429
434
430
435
if ( files != null ) {
431
436
validateArray ( files , 'options.files' ) ;
432
437
}
433
438
if ( watch != null ) {
434
439
validateBoolean ( watch , 'options.watch' ) ;
435
440
}
441
+
442
+ if ( bail != null ) {
443
+ validateBoolean ( bail , 'options.bail' ) ;
444
+ }
445
+
436
446
if ( shard != null ) {
437
447
validateObject ( shard , 'options.shard' ) ;
438
448
// Avoid re-evaluating the shard object in case it's a getter
@@ -479,13 +489,13 @@ function run(options) {
479
489
let postRun = ( ) => root . postRun ( ) ;
480
490
let filesWatcher ;
481
491
if ( watch ) {
482
- filesWatcher = watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns ) ;
492
+ filesWatcher = watchFiles ( testFiles , root , inspectPort , signal , testNamePatterns , bail ) ;
483
493
postRun = undefined ;
484
494
}
485
495
const runFiles = ( ) => {
486
496
root . harness . bootstrapComplete = true ;
487
497
return SafePromiseAllSettledReturnVoid ( testFiles , ( path ) => {
488
- const subtest = runTestFile ( path , root , inspectPort , filesWatcher , testNamePatterns ) ;
498
+ const subtest = runTestFile ( path , root , inspectPort , filesWatcher , testNamePatterns , bail ) ;
489
499
filesWatcher ?. runningSubtests . set ( path , subtest ) ;
490
500
return subtest ;
491
501
} ) ;
0 commit comments