@@ -168,22 +168,21 @@ namespace ts {
168
168
} ) ;
169
169
170
170
describe ( "can detect when and what to rebuild" , ( ) => {
171
- let fs : vfs . FileSystem ;
172
- let host : fakes . SolutionBuilderHost ;
173
- let builder : SolutionBuilder ;
174
- before ( ( ) => {
175
- fs = projFs . shadow ( ) ;
176
- host = new fakes . SolutionBuilderHost ( fs ) ;
177
- builder = createSolutionBuilder ( host , [ "/src/tests" ] , { dry : false , force : false , verbose : true } ) ;
178
- } ) ;
179
- after ( ( ) => {
180
- fs = undefined ! ;
181
- host = undefined ! ;
182
- builder = undefined ! ;
183
- } ) ;
171
+ function initializeWithBuild ( ) {
172
+ const fs = projFs . shadow ( ) ;
173
+ const host = new fakes . SolutionBuilderHost ( fs ) ;
174
+ const builder = createSolutionBuilder ( host , [ "/src/tests" ] , { verbose : true } ) ;
175
+ builder . buildAllProjects ( ) ;
176
+ host . clearDiagnostics ( ) ;
177
+ tick ( ) ;
178
+ builder . resetBuildContext ( ) ;
179
+ return { fs, host, builder } ;
180
+ }
184
181
185
182
it ( "Builds the project" , ( ) => {
186
- host . clearDiagnostics ( ) ;
183
+ const fs = projFs . shadow ( ) ;
184
+ const host = new fakes . SolutionBuilderHost ( fs ) ;
185
+ const builder = createSolutionBuilder ( host , [ "/src/tests" ] , { verbose : true } ) ;
187
186
builder . resetBuildContext ( ) ;
188
187
builder . buildAllProjects ( ) ;
189
188
host . assertDiagnosticMessages (
@@ -195,45 +194,38 @@ namespace ts {
195
194
[ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/tests/tsconfig.json" , "src/tests/index.js" ] ,
196
195
[ Diagnostics . Building_project_0 , "/src/tests/tsconfig.json" ]
197
196
) ;
198
- tick ( ) ;
199
197
} ) ;
200
198
201
199
// All three projects are up to date
202
200
it ( "Detects that all projects are up to date" , ( ) => {
203
- host . clearDiagnostics ( ) ;
204
- builder . resetBuildContext ( ) ;
201
+ const { host, builder } = initializeWithBuild ( ) ;
205
202
builder . buildAllProjects ( ) ;
206
203
host . assertDiagnosticMessages (
207
204
getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
208
205
[ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/core/tsconfig.json" , "src/core/anotherModule.ts" , "src/core/anotherModule.js" ] ,
209
206
[ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/logic/tsconfig.json" , "src/logic/index.ts" , "src/logic/index.js" ] ,
210
207
[ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/tests/tsconfig.json" , "src/tests/index.ts" , "src/tests/index.js" ]
211
208
) ;
212
- tick ( ) ;
213
209
} ) ;
214
210
215
211
// Update a file in the leaf node (tests), only it should rebuild the last one
216
212
it ( "Only builds the leaf node project" , ( ) => {
217
- host . clearDiagnostics ( ) ;
213
+ const { fs , host, builder } = initializeWithBuild ( ) ;
218
214
fs . writeFileSync ( "/src/tests/index.ts" , "const m = 10;" ) ;
219
- builder . resetBuildContext ( ) ;
220
215
builder . buildAllProjects ( ) ;
221
-
222
216
host . assertDiagnosticMessages (
223
217
getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
224
218
[ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/core/tsconfig.json" , "src/core/anotherModule.ts" , "src/core/anotherModule.js" ] ,
225
219
[ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/logic/tsconfig.json" , "src/logic/index.ts" , "src/logic/index.js" ] ,
226
220
[ Diagnostics . Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2 , "src/tests/tsconfig.json" , "src/tests/index.js" , "src/tests/index.ts" ] ,
227
221
[ Diagnostics . Building_project_0 , "/src/tests/tsconfig.json" ]
228
222
) ;
229
- tick ( ) ;
230
223
} ) ;
231
224
232
225
// Update a file in the parent (without affecting types), should get fast downstream builds
233
226
it ( "Detects type-only changes in upstream projects" , ( ) => {
234
- host . clearDiagnostics ( ) ;
227
+ const { fs , host, builder } = initializeWithBuild ( ) ;
235
228
replaceText ( fs , "/src/core/index.ts" , "HELLO WORLD" , "WELCOME PLANET" ) ;
236
- builder . resetBuildContext ( ) ;
237
229
builder . buildAllProjects ( ) ;
238
230
239
231
host . assertDiagnosticMessages (
@@ -247,6 +239,19 @@ namespace ts {
247
239
[ Diagnostics . Updating_output_timestamps_of_project_0 , "/src/tests/tsconfig.json" ]
248
240
) ;
249
241
} ) ;
242
+
243
+ it ( "rebuilds completely when version in tsbuildinfo doesnt match ts version" , ( ) => {
244
+ const { host, builder } = initializeWithBuild ( ) ;
245
+ changeCompilerVersion ( host ) ;
246
+ builder . buildAllProjects ( ) ;
247
+ host . assertDiagnosticMessages (
248
+ // TODO:: This should build all instead
249
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
250
+ [ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/core/tsconfig.json" , "src/core/anotherModule.ts" , "src/core/anotherModule.js" ] ,
251
+ [ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/logic/tsconfig.json" , "src/logic/index.ts" , "src/logic/index.js" ] ,
252
+ [ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , "src/tests/tsconfig.json" , "src/tests/index.ts" , "src/tests/index.js" ]
253
+ ) ;
254
+ } ) ;
250
255
} ) ;
251
256
252
257
describe ( "downstream-blocked compilations" , ( ) => {
0 commit comments