@@ -605,9 +605,23 @@ class Test extends AsyncResource {
605605 throw new ERR_INVALID_ARG_TYPE ( 'options.concurrency' , [ 'boolean' , 'number' ] , concurrency ) ;
606606 }
607607
608+ // Take timeout from cli
609+ const cliTimeout = this . config . timeout ;
610+ if ( cliTimeout != null && cliTimeout !== Infinity ) {
611+ if ( ! ( this . name === '<root>' && this . parent === null ) &&
612+ this . constructor . name !== 'FileTest' &&
613+ this . constructor . name !== 'Suite' ) {
614+ validateNumber ( cliTimeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
615+ this . timeout = cliTimeout ;
616+ }
617+ }
618+
619+ // Take timeout from options
608620 if ( timeout != null && timeout !== Infinity ) {
609- validateNumber ( timeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
610- this . timeout = timeout ;
621+ if ( ! ( this . name === '<root>' && this . parent === null ) ) {
622+ validateNumber ( timeout , 'options.timeout' , 0 , TIMEOUT_MAX ) ;
623+ this . timeout = timeout ;
624+ }
611625 }
612626
613627 if ( skip ) {
@@ -788,8 +802,6 @@ class Test extends AsyncResource {
788802 }
789803
790804 createSubtest ( Factory , name , options , fn , overrides ) {
791- const timeoutPerTest = this . config . timeoutPerTest ;
792-
793805 if ( typeof name === 'function' ) {
794806 fn = name ;
795807 } else if ( name !== null && typeof name === 'object' ) {
@@ -799,18 +811,9 @@ class Test extends AsyncResource {
799811 fn = options ;
800812 }
801813
802- if ( options !== null && typeof options === 'object' ) {
803- if ( this . childNumber > 0 && options . timeout === undefined && timeoutPerTest !== Infinity ) {
804- options . timeout = timeoutPerTest ;
805- }
806- }
807814
808815 if ( options === null || typeof options !== 'object' ) {
809- if ( this . childNumber > 0 && timeoutPerTest !== Infinity ) {
810- options = { __proto__ : null , timeout : timeoutPerTest } ;
811- } else {
812- options = kEmptyObject ;
813- }
816+ options = kEmptyObject ;
814817 }
815818
816819 let parent = this ;
0 commit comments