@@ -57,20 +57,23 @@ namespace ts.tscWatch {
57
57
function checkOutputErrors (
58
58
host : WatchedSystem ,
59
59
logsBeforeWatchDiagnostic : string [ ] | undefined ,
60
- preErrorsWatchDiagnostic : Diagnostic ,
60
+ preErrorsWatchDiagnostic : Diagnostic | undefined ,
61
61
logsBeforeErrors : string [ ] | undefined ,
62
62
errors : ReadonlyArray < Diagnostic > | ReadonlyArray < string > ,
63
63
disableConsoleClears ?: boolean | undefined ,
64
- ...postErrorsWatchDiagnostics : Diagnostic [ ]
64
+ ...postErrorsWatchDiagnostics : Diagnostic [ ] | string [ ]
65
65
) {
66
66
let screenClears = 0 ;
67
67
const outputs = host . getOutput ( ) ;
68
- const expectedOutputCount = 1 + errors . length + postErrorsWatchDiagnostics . length +
69
- ( logsBeforeWatchDiagnostic ? logsBeforeWatchDiagnostic . length : 0 ) + ( logsBeforeErrors ? logsBeforeErrors . length : 0 ) ;
68
+ const expectedOutputCount = ( preErrorsWatchDiagnostic ? 1 : 0 ) +
69
+ errors . length +
70
+ postErrorsWatchDiagnostics . length +
71
+ ( logsBeforeWatchDiagnostic ? logsBeforeWatchDiagnostic . length : 0 ) +
72
+ ( logsBeforeErrors ? logsBeforeErrors . length : 0 ) ;
70
73
assert . equal ( outputs . length , expectedOutputCount , JSON . stringify ( outputs ) ) ;
71
74
let index = 0 ;
72
75
forEach ( logsBeforeWatchDiagnostic , log => assertLog ( "logsBeforeWatchDiagnostic" , log ) ) ;
73
- assertWatchDiagnostic ( preErrorsWatchDiagnostic ) ;
76
+ if ( preErrorsWatchDiagnostic ) assertWatchDiagnostic ( preErrorsWatchDiagnostic ) ;
74
77
forEach ( logsBeforeErrors , log => assertLog ( "logBeforeError" , log ) ) ;
75
78
// Verify errors
76
79
forEach ( errors , assertDiagnostic ) ;
@@ -98,13 +101,18 @@ namespace ts.tscWatch {
98
101
index ++ ;
99
102
}
100
103
101
- function assertWatchDiagnostic ( diagnostic : Diagnostic ) {
102
- const expected = getWatchDiagnosticWithoutDate ( diagnostic ) ;
103
- if ( ! disableConsoleClears && contains ( screenStartingMessageCodes , diagnostic . code ) ) {
104
- assert . equal ( host . screenClears [ screenClears ] , index , `Expected screen clear at this diagnostic: ${ expected } ` ) ;
105
- screenClears ++ ;
104
+ function assertWatchDiagnostic ( diagnostic : Diagnostic | string ) {
105
+ if ( isString ( diagnostic ) ) {
106
+ assert . equal ( outputs [ index ] , diagnostic , getOutputAtFailedMessage ( "Diagnostic" , diagnostic ) ) ;
107
+ }
108
+ else {
109
+ const expected = getWatchDiagnosticWithoutDate ( diagnostic ) ;
110
+ if ( ! disableConsoleClears && contains ( screenStartingMessageCodes , diagnostic . code ) ) {
111
+ assert . equal ( host . screenClears [ screenClears ] , index , `Expected screen clear at this diagnostic: ${ expected } ` ) ;
112
+ screenClears ++ ;
113
+ }
114
+ assert . isTrue ( endsWith ( outputs [ index ] , expected ) , getOutputAtFailedMessage ( "Watch diagnostic" , expected ) ) ;
106
115
}
107
- assert . isTrue ( endsWith ( outputs [ index ] , expected ) , getOutputAtFailedMessage ( "Watch diagnostic" , expected ) ) ;
108
116
index ++ ;
109
117
}
110
118
@@ -159,6 +167,18 @@ namespace ts.tscWatch {
159
167
assert . equal ( host . exitCode , expectedExitCode ) ;
160
168
}
161
169
170
+ export function checkNormalBuildErrors ( host : WatchedSystem , errors : ReadonlyArray < Diagnostic > | ReadonlyArray < string > , reportErrorSummary ?: boolean ) {
171
+ checkOutputErrors (
172
+ host ,
173
+ /*logsBeforeWatchDiagnostic*/ undefined ,
174
+ /*preErrorsWatchDiagnostic*/ undefined ,
175
+ /*logsBeforeErrors*/ undefined ,
176
+ errors ,
177
+ /*disableConsoleClears*/ undefined ,
178
+ ...( reportErrorSummary ? [ getErrorSummaryText ( errors . length , host . newLine ) ] : emptyArray )
179
+ ) ;
180
+ }
181
+
162
182
function isDiagnosticMessageChain ( message : DiagnosticMessage | DiagnosticMessageChain ) : message is DiagnosticMessageChain {
163
183
return ! ! ( message as DiagnosticMessageChain ) . messageText ;
164
184
}
0 commit comments