@@ -56,79 +56,75 @@ export function runBenchmarkWatch({
5656 ) ;
5757
5858 return combineLatest ( [
59- monitoredProcess . run ( ) . pipe (
60- // In watch mode typically the run will not emit an exit code when it's running sucessfully.
61- startWith ( undefined ) ,
62- concatMap ( processExitCode => {
63- if ( processExitCode !== undefined && processExitCode != command . expectedExitCode ) {
64- logger . debug ( `${ debugPrefix ( ) } exited with ${ processExitCode } but `
65- + `${ command . expectedExitCode } was expected` ) ;
59+ monitoredProcess . run ( ) . pipe (
60+ startWith ( undefined ) ,
61+ tap ( processExitCode => {
62+ if ( processExitCode !== undefined && processExitCode != command . expectedExitCode ) {
63+ logger . debug ( `${ debugPrefix ( ) } exited with ${ processExitCode } but `
64+ + `${ command . expectedExitCode } was expected` ) ;
6665
67- return throwError ( processFailed ) ;
68- }
69-
70- return of ( processExitCode ) ;
71- } ) ,
72- ) ,
73- monitoredProcess . stdout$ . pipe (
74- filter ( stdout => stdout . includes ( watchMatcher ) ) ,
75- timeout ( watchTimeout ) ,
76- take ( 1 ) ,
77- ) ,
78- ] )
79- . pipe (
80- concatMap ( ( ) => {
81- const { cmd, cwd, args } = watchCommand ;
82- failedRuns = 0 ;
66+ throw processFailed ;
67+ }
68+ } ) ,
69+ ) ,
70+ monitoredProcess . stdout$ . pipe (
71+ filter ( stdout => stdout . toString ( ) . includes ( watchMatcher ) ) ,
72+ take ( 1 ) ,
73+ ) ,
74+ ] ) . pipe (
75+ timeout ( watchTimeout ) ,
76+ concatMap ( ( ) => {
77+ const { cmd, cwd, args } = watchCommand ;
78+ failedRuns = 0 ;
8379
84- return of ( null )
85- . pipe (
86- tap ( ( ) => {
87- const { status, error } = spawnSync ( cmd , args , { cwd } ) ;
88- monitoredProcess . resetElapsedTimer ( ) ;
80+ return of ( null )
81+ . pipe (
82+ tap ( ( ) => {
83+ const { status, error } = spawnSync ( cmd , args , { cwd } ) ;
84+ monitoredProcess . resetElapsedTimer ( ) ;
8985
90- if ( status != command . expectedExitCode ) {
91- logger . debug ( `${ debugPrefix ( ) } exited with ${ status } \n${ error ?. message } ` ) ;
92- throw processFailed ;
93- }
86+ if ( status != command . expectedExitCode ) {
87+ logger . debug ( `${ debugPrefix ( ) } exited with ${ status } \n${ error ?. message } ` ) ;
88+ throw processFailed ;
89+ }
9490
95- // Reset fail counter for this iteration.
96- failedRuns = 0 ;
97- } ) ,
98- tap ( ( ) => logger . debug ( `${ debugPrefix ( ) } starting` ) ) ,
99- concatMap ( ( ) => forkJoin ( captures . map ( capture => capture ( stats$ ) ) ) ) ,
100- throwIfEmpty ( ( ) => new Error ( 'Nothing was captured' ) ) ,
101- tap ( ( ) => logger . debug ( `${ debugPrefix ( ) } finished successfully` ) ) ,
102- tap ( ( ) => successfulRuns ++ ) ,
103- repeat ( iterations ) ,
104- retryWhen ( errors => errors
105- . pipe ( concatMap ( val => {
106- // Check if we're still within the retry threshold.
107- failedRuns ++ ;
91+ // Reset fail counter for this iteration.
92+ failedRuns = 0 ;
93+ } ) ,
94+ tap ( ( ) => logger . debug ( `${ debugPrefix ( ) } starting` ) ) ,
95+ concatMap ( ( ) => forkJoin ( captures . map ( capture => capture ( stats$ ) ) ) ) ,
96+ throwIfEmpty ( ( ) => new Error ( 'Nothing was captured' ) ) ,
97+ tap ( ( ) => logger . debug ( `${ debugPrefix ( ) } finished successfully` ) ) ,
98+ tap ( ( ) => successfulRuns ++ ) ,
99+ repeat ( iterations ) ,
100+ retryWhen ( errors => errors
101+ . pipe ( concatMap ( val => {
102+ // Check if we're still within the retry threshold.
103+ failedRuns ++ ;
108104
109- return failedRuns < retries ? of ( val ) : throwError ( val ) ;
110- } ) ) ,
111- ) ,
112- ) ;
113- } ) ,
114- retryWhen ( errors => errors
115- . pipe ( concatMap ( val => {
116- // Check if we're still within the retry threshold.
117- failedRuns ++ ;
105+ return failedRuns < retries ? of ( val ) : throwError ( val ) ;
106+ } ) ) ,
107+ ) ,
108+ ) ;
109+ } ) ,
110+ retryWhen ( errors => errors
111+ . pipe ( concatMap ( val => {
112+ // Check if we're still within the retry threshold.
113+ failedRuns ++ ;
118114
119- if ( failedRuns < retries ) {
120- return of ( val ) ;
121- }
115+ if ( failedRuns < retries ) {
116+ return of ( val ) ;
117+ }
122118
123- return throwError (
124- val === processFailed ?
119+ return throwError (
120+ val === processFailed ?
125121 new MaximumRetriesExceeded ( retries ) :
126122 val ,
127- ) ;
128- } ) ) ,
129- ) ,
130- take ( iterations ) ,
131- reduce ( ( acc , val ) => acc . map ( ( _ , idx ) => aggregateMetricGroups ( acc [ idx ] , val [ idx ] ) ) ) ,
132- tap ( groups => reporters . forEach ( reporter => reporter ( command , groups ) ) ) ,
133- ) ;
123+ ) ;
124+ } ) ) ,
125+ ) ,
126+ take ( iterations ) ,
127+ reduce ( ( acc , val ) => acc . map ( ( _ , idx ) => aggregateMetricGroups ( acc [ idx ] , val [ idx ] ) ) ) ,
128+ tap ( groups => reporters . forEach ( reporter => reporter ( command , groups ) ) ) ,
129+ ) ;
134130}
0 commit comments