@@ -156,32 +156,44 @@ function runTest(basename) {
156
156
} , err => {
157
157
console . log ( ) ;
158
158
159
- // check expected stderr patterns in order
159
+ // check expected stderr and stdout patterns in order
160
160
let expectStderr = config . stderr ;
161
- if ( expectStderr ) {
162
- const stderrString = stderr . toString ( ) ;
163
- if ( typeof expectStderr === "string" ) expectStderr = [ expectStderr ] ;
164
- let lastIndex = 0 ;
165
- let failed = false ;
166
- expectStderr . forEach ( ( substr , i ) => {
167
- var index = stderrString . indexOf ( substr , lastIndex ) ;
168
- if ( index < 0 ) {
169
- console . log ( "Missing pattern #" + ( i + 1 ) + " '" + substr + "' in stderr at " + lastIndex + "+." ) ;
161
+ let expectStdout = config . stdout ;
162
+ let hasExpected = false ;
163
+ [
164
+ { expected : expectStderr , text : 'stderr' } ,
165
+ { expected : expectStdout , text : 'stdout' }
166
+ ] . forEach ( ( stdPatterns ) => {
167
+ let expected = stdPatterns . expected ;
168
+ if ( expected ) {
169
+ hasExpected = true ;
170
+ const stderrString = stderr . toString ( ) ;
171
+ if ( typeof expected === "string" ) expected = [ expected ] ;
172
+ let lastIndex = 0 ;
173
+ let failed = false ;
174
+ expected . forEach ( ( substr , i ) => {
175
+ var index = stderrString . indexOf ( substr , lastIndex ) ;
176
+ if ( index < 0 ) {
177
+ console . log ( "Missing pattern #" + ( i + 1 ) + " '" + substr + "' in stderr at " + lastIndex + "+." ) ;
178
+ failedTests . add ( basename ) ;
179
+ failed = true ;
180
+ } else {
181
+ lastIndex = index + substr . length ;
182
+ }
183
+ } ) ;
184
+ let text = stdPatterns . text ;
185
+ if ( failed ) {
170
186
failedTests . add ( basename ) ;
171
- failed = true ;
187
+ failedMessages . set ( basename , + text + " mismatch" ) ;
188
+ console . log ( "\n- " + colorsUtil . red ( text + " MISMATCH" ) + "\n" ) ;
172
189
} else {
173
- lastIndex = index + substr . length ;
190
+ console . log ( "- " + colorsUtil . green ( text + " MATCH" ) + "\n" ) ;
174
191
}
175
- } ) ;
176
- if ( failed ) {
177
- failedTests . add ( basename ) ;
178
- failedMessages . set ( basename , "stderr mismatch" ) ;
179
- console . log ( "\n- " + colorsUtil . red ( "stderr MISMATCH" ) + "\n" ) ;
180
- } else {
181
- console . log ( "- " + colorsUtil . green ( "stderr MATCH" ) + "\n" ) ;
192
+ return ;
182
193
}
194
+ } )
195
+ if ( hasExpected )
183
196
return ;
184
- }
185
197
186
198
if ( err )
187
199
stderr . write ( err + os . EOL ) ;
0 commit comments