1- /* global process */
21/* eslint-disable no-await-in-loop, no-continue, no-labels, no-unreachable-loop */
32
43/* The ses-ava command allows a single package to run the same test suite with
@@ -39,7 +38,7 @@ const passThroughArgOptions = new Set([
3938 '--port' ,
4039] ) ;
4140
42- /** @type {(args: string[]) => Promise<void > } */
41+ /** @type {(args: string[]) => Promise<number > } */
4342export const main = async args => {
4443 // Parse configuration.
4544 const descriptorText = await fs . promises . readFile ( 'package.json' , 'utf8' ) ;
@@ -138,6 +137,7 @@ export const main = async args => {
138137 }
139138
140139 // Execute configurations serially.
140+ let exitCode = 0 ;
141141 for ( const config of configs ) {
142142 console . warn ( `[ses-ava] config:` , config ) ;
143143 const avaArgs = [
@@ -147,17 +147,16 @@ export const main = async args => {
147147 const child = popen . spawn ( 'ava' , avaArgs , {
148148 stdio : [ 'inherit' , 'inherit' , 'inherit' ] ,
149149 } ) ;
150- await new Promise ( ( resolve , reject ) => {
151- child . on ( 'exit' , code => {
152- process . exitCode ||= typeof code === 'number' ? code : 1 ;
153- if ( failFast && process . exitCode !== 0 ) {
154- process . exit ( ) ;
155- }
156- resolve ( undefined ) ;
150+ const configExitCode = await new Promise ( ( resolve , reject ) => {
151+ child . on ( 'exit' , ( code , _signal ) => {
152+ resolve ( typeof code === 'number' ? code : 1 ) ;
157153 } ) ;
158154 child . on ( 'error' , error => {
159155 reject ( error ) ;
160156 } ) ;
161157 } ) ;
158+ exitCode ||= configExitCode ;
159+ if ( failFast && exitCode !== 0 ) break ;
162160 }
161+ return exitCode ;
163162} ;
0 commit comments