1
1
namespace ts {
2
2
let currentTime = 100 ;
3
+
4
+ function getExpectedDiagnosticForProjectsInBuild ( ...projects : string [ ] ) : fakes . ExpectedDiagnostic {
5
+ return [ Diagnostics . Projects_in_this_build_Colon_0 , projects . map ( p => "\r\n * " + p ) . join ( "" ) ] ;
6
+ }
7
+
3
8
export namespace Sample1 {
4
9
tick ( ) ;
5
10
const projFs = loadProjectFromDisk ( "tests/projects/sample1" ) ;
@@ -67,7 +72,11 @@ namespace ts {
67
72
const host = new fakes . SolutionBuilderHost ( fs ) ;
68
73
const builder = createSolutionBuilder ( host , [ "/src/tests" ] , { dry : true , force : false , verbose : false } ) ;
69
74
builder . buildAllProjects ( ) ;
70
- host . assertDiagnosticMessages ( Diagnostics . A_non_dry_build_would_build_project_0 , Diagnostics . A_non_dry_build_would_build_project_0 , Diagnostics . A_non_dry_build_would_build_project_0 ) ;
75
+ host . assertDiagnosticMessages (
76
+ [ Diagnostics . A_non_dry_build_would_build_project_0 , "/src/core/tsconfig.json" ] ,
77
+ [ Diagnostics . A_non_dry_build_would_build_project_0 , "/src/logic/tsconfig.json" ] ,
78
+ [ Diagnostics . A_non_dry_build_would_build_project_0 , "/src/tests/tsconfig.json" ]
79
+ ) ;
71
80
72
81
// Check for outputs to not be written. Not an exhaustive list
73
82
for ( const output of allExpectedOutputs ) {
@@ -86,7 +95,11 @@ namespace ts {
86
95
host . clearDiagnostics ( ) ;
87
96
builder = createSolutionBuilder ( host , [ "/src/tests" ] , { dry : true , force : false , verbose : false } ) ;
88
97
builder . buildAllProjects ( ) ;
89
- host . assertDiagnosticMessages ( Diagnostics . Project_0_is_up_to_date , Diagnostics . Project_0_is_up_to_date , Diagnostics . Project_0_is_up_to_date ) ;
98
+ host . assertDiagnosticMessages (
99
+ [ Diagnostics . Project_0_is_up_to_date , "/src/core/tsconfig.json" ] ,
100
+ [ Diagnostics . Project_0_is_up_to_date , "/src/logic/tsconfig.json" ] ,
101
+ [ Diagnostics . Project_0_is_up_to_date , "/src/tests/tsconfig.json" ]
102
+ ) ;
90
103
} ) ;
91
104
} ) ;
92
105
@@ -146,13 +159,15 @@ namespace ts {
146
159
host . clearDiagnostics ( ) ;
147
160
builder . resetBuildContext ( ) ;
148
161
builder . buildAllProjects ( ) ;
149
- host . assertDiagnosticMessages ( Diagnostics . Projects_in_this_build_Colon_0 ,
150
- Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist ,
151
- Diagnostics . Building_project_0 ,
152
- Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist ,
153
- Diagnostics . Building_project_0 ,
154
- Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist ,
155
- Diagnostics . Building_project_0 ) ;
162
+ host . assertDiagnosticMessages (
163
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
164
+ [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/core/tsconfig.json" , "src/core/anotherModule.js" ] ,
165
+ [ Diagnostics . Building_project_0 , "/src/core/tsconfig.json" ] ,
166
+ [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/logic/tsconfig.json" , "src/logic/index.js" ] ,
167
+ [ Diagnostics . Building_project_0 , "/src/logic/tsconfig.json" ] ,
168
+ [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/tests/tsconfig.json" , "src/tests/index.js" ] ,
169
+ [ Diagnostics . Building_project_0 , "/src/tests/tsconfig.json" ]
170
+ ) ;
156
171
tick ( ) ;
157
172
} ) ;
158
173
@@ -161,10 +176,12 @@ namespace ts {
161
176
host . clearDiagnostics ( ) ;
162
177
builder . resetBuildContext ( ) ;
163
178
builder . buildAllProjects ( ) ;
164
- host . assertDiagnosticMessages ( Diagnostics . Projects_in_this_build_Colon_0 ,
165
- Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 ,
166
- Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 ,
167
- Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 ) ;
179
+ host . assertDiagnosticMessages (
180
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
181
+ [ 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" ] ,
182
+ [ 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" ] ,
183
+ [ 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" ]
184
+ ) ;
168
185
tick ( ) ;
169
186
} ) ;
170
187
@@ -175,11 +192,13 @@ namespace ts {
175
192
builder . resetBuildContext ( ) ;
176
193
builder . buildAllProjects ( ) ;
177
194
178
- host . assertDiagnosticMessages ( Diagnostics . Projects_in_this_build_Colon_0 ,
179
- Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 ,
180
- Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 ,
181
- Diagnostics . Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2 ,
182
- Diagnostics . Building_project_0 ) ;
195
+ host . assertDiagnosticMessages (
196
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
197
+ [ 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" ] ,
198
+ [ 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" ] ,
199
+ [ 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" ] ,
200
+ [ Diagnostics . Building_project_0 , "/src/tests/tsconfig.json" ]
201
+ ) ;
183
202
tick ( ) ;
184
203
} ) ;
185
204
@@ -190,13 +209,15 @@ namespace ts {
190
209
builder . resetBuildContext ( ) ;
191
210
builder . buildAllProjects ( ) ;
192
211
193
- host . assertDiagnosticMessages ( Diagnostics . Projects_in_this_build_Colon_0 ,
194
- Diagnostics . Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2 ,
195
- Diagnostics . Building_project_0 ,
196
- Diagnostics . Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies ,
197
- Diagnostics . Updating_output_timestamps_of_project_0 ,
198
- Diagnostics . Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies ,
199
- Diagnostics . Updating_output_timestamps_of_project_0 ) ;
212
+ host . assertDiagnosticMessages (
213
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
214
+ [ Diagnostics . Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2 , "src/core/tsconfig.json" , "src/core/anotherModule.js" , "src/core/index.ts" ] ,
215
+ [ Diagnostics . Building_project_0 , "/src/core/tsconfig.json" ] ,
216
+ [ Diagnostics . Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies , "src/logic/tsconfig.json" ] ,
217
+ [ Diagnostics . Updating_output_timestamps_of_project_0 , "/src/logic/tsconfig.json" ] ,
218
+ [ Diagnostics . Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies , "src/tests/tsconfig.json" ] ,
219
+ [ Diagnostics . Updating_output_timestamps_of_project_0 , "/src/tests/tsconfig.json" ]
220
+ ) ;
200
221
} ) ;
201
222
} ) ;
202
223
@@ -210,14 +231,14 @@ namespace ts {
210
231
replaceText ( fs , "/src/logic/index.ts" , "c.multiply(10, 15)" , `c.muitply()` ) ;
211
232
builder . buildAllProjects ( ) ;
212
233
host . assertDiagnosticMessages (
213
- Diagnostics . Projects_in_this_build_Colon_0 ,
214
- Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist ,
215
- Diagnostics . Building_project_0 ,
216
- Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist ,
217
- Diagnostics . Building_project_0 ,
218
- Diagnostics . Property_0_does_not_exist_on_type_1 ,
219
- Diagnostics . Project_0_can_t_be_built_because_its_dependency_1_has_errors ,
220
- Diagnostics . Skipping_build_of_project_0_because_its_dependency_1_has_errors
234
+ getExpectedDiagnosticForProjectsInBuild ( "src/core/tsconfig.json" , "src/logic/tsconfig.json" , "src/tests/tsconfig.json" ) ,
235
+ [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/core/tsconfig.json" , "src/core/anotherModule.js" ] ,
236
+ [ Diagnostics . Building_project_0 , "/src/core/tsconfig.json" ] ,
237
+ [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/logic/tsconfig.json" , "src/logic/index.js" ] ,
238
+ [ Diagnostics . Building_project_0 , "/src/logic/tsconfig.json" ] ,
239
+ [ Diagnostics . Property_0_does_not_exist_on_type_1 , "muitply" , `typeof import("/src/core/index")` ] ,
240
+ [ Diagnostics . Project_0_can_t_be_built_because_its_dependency_1_has_errors , "src/tests/tsconfig.json" , "src/logic" ] ,
241
+ [ Diagnostics . Skipping_build_of_project_0_because_its_dependency_1_has_errors , "/src/tests/tsconfig.json" , "/src/logic" ]
221
242
) ;
222
243
} ) ;
223
244
} ) ;
@@ -281,12 +302,12 @@ export class cNew {}`);
281
302
const projFs = loadProjectFromDisk ( "tests/projects/resolveJsonModuleAndComposite" ) ;
282
303
const allExpectedOutputs = [ "/src/tests/dist/src/index.js" , "/src/tests/dist/src/index.d.ts" , "/src/tests/dist/src/hello.json" ] ;
283
304
284
- function verifyProjectWithResolveJsonModule ( configFile : string , ...expectedDiagnosticMessages : DiagnosticMessage [ ] ) {
305
+ function verifyProjectWithResolveJsonModule ( configFile : string , ...expectedDiagnosticMessages : fakes . ExpectedDiagnostic [ ] ) {
285
306
const fs = projFs . shadow ( ) ;
286
307
verifyProjectWithResolveJsonModuleWithFs ( fs , configFile , allExpectedOutputs , ...expectedDiagnosticMessages ) ;
287
308
}
288
309
289
- function verifyProjectWithResolveJsonModuleWithFs ( fs : vfs . FileSystem , configFile : string , allExpectedOutputs : ReadonlyArray < string > , ...expectedDiagnosticMessages : DiagnosticMessage [ ] ) {
310
+ function verifyProjectWithResolveJsonModuleWithFs ( fs : vfs . FileSystem , configFile : string , allExpectedOutputs : ReadonlyArray < string > , ...expectedDiagnosticMessages : fakes . ExpectedDiagnostic [ ] ) {
290
311
const host = new fakes . SolutionBuilderHost ( fs ) ;
291
312
const builder = createSolutionBuilder ( host , [ configFile ] , { dry : false , force : false , verbose : false } ) ;
292
313
builder . buildAllProjects ( ) ;
@@ -300,7 +321,10 @@ export class cNew {}`);
300
321
}
301
322
302
323
it ( "with resolveJsonModule and include only" , ( ) => {
303
- verifyProjectWithResolveJsonModule ( "/src/tests/tsconfig_withInclude.json" , Diagnostics . File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern ) ;
324
+ verifyProjectWithResolveJsonModule ( "/src/tests/tsconfig_withInclude.json" , [
325
+ Diagnostics . File_0_is_not_in_project_file_list_Projects_must_list_all_files_or_use_an_include_pattern ,
326
+ "/src/tests/src/hello.json"
327
+ ] ) ;
304
328
} ) ;
305
329
306
330
it ( "with resolveJsonModule and include of *.json along with other include" , ( ) => {
@@ -415,7 +439,7 @@ export default hello.hello`);
415
439
"/src/c.ts"
416
440
] ;
417
441
418
- function verifyBuild ( modifyDiskLayout : ( fs : vfs . FileSystem ) => void , allExpectedOutputs : ReadonlyArray < string > , expectedDiagnostics : DiagnosticMessage [ ] , expectedFileTraces : ReadonlyArray < string > ) {
442
+ function verifyBuild ( modifyDiskLayout : ( fs : vfs . FileSystem ) => void , allExpectedOutputs : ReadonlyArray < string > , expectedFileTraces : ReadonlyArray < string > , ... expectedDiagnostics : fakes . ExpectedDiagnostic [ ] ) {
419
443
const fs = projFs . shadow ( ) ;
420
444
const host = new fakes . SolutionBuilderHost ( fs ) ;
421
445
modifyDiskLayout ( fs ) ;
@@ -442,11 +466,11 @@ export const b = new A();`);
442
466
}
443
467
444
468
it ( "verify that it builds correctly" , ( ) => {
445
- verifyBuild ( noop , allExpectedOutputs , emptyArray , expectedFileTraces ) ;
469
+ verifyBuild ( noop , allExpectedOutputs , expectedFileTraces ) ;
446
470
} ) ;
447
471
448
472
it ( "verify that it builds correctly when the referenced project uses different module resolution" , ( ) => {
449
- verifyBuild ( fs => modifyFsBTsToNonRelativeImport ( fs , "classic" ) , allExpectedOutputs , emptyArray , expectedFileTraces ) ;
473
+ verifyBuild ( fs => modifyFsBTsToNonRelativeImport ( fs , "classic" ) , allExpectedOutputs , expectedFileTraces ) ;
450
474
} ) ;
451
475
452
476
it ( "verify that it build reports error about module not found with node resolution with external module name" , ( ) => {
@@ -458,10 +482,25 @@ export const b = new A();`);
458
482
] ;
459
483
verifyBuild ( fs => modifyFsBTsToNonRelativeImport ( fs , "node" ) ,
460
484
allExpectedOutputs ,
461
- [ Diagnostics . Cannot_find_module_0 ] ,
462
- expectedFileTraces ) ;
485
+ expectedFileTraces ,
486
+ [ Diagnostics . Cannot_find_module_0 , "a" ] ,
487
+ ) ;
463
488
} ) ;
464
489
} ) ;
490
+
491
+ it ( "unittests:: tsbuild - when tsconfig extends the missing file" , ( ) => {
492
+ const projFs = loadProjectFromDisk ( "tests/projects/missingExtendedConfig" ) ;
493
+ const fs = projFs . shadow ( ) ;
494
+ const host = new fakes . SolutionBuilderHost ( fs ) ;
495
+ const builder = createSolutionBuilder ( host , [ "/src/tsconfig.json" ] , { } ) ;
496
+ builder . buildAllProjects ( ) ;
497
+ host . assertDiagnosticMessages (
498
+ [ Diagnostics . The_specified_path_does_not_exist_Colon_0 , "/src/foobar.json" ] ,
499
+ [ Diagnostics . No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2 , "/src/tsconfig.first.json" , "[\"**/*\"]" , "[]" ] ,
500
+ [ Diagnostics . The_specified_path_does_not_exist_Colon_0 , "/src/foobar.json" ] ,
501
+ [ Diagnostics . No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2 , "/src/tsconfig.second.json" , "[\"**/*\"]" , "[]" ]
502
+ ) ;
503
+ } ) ;
465
504
}
466
505
467
506
export namespace OutFile {
@@ -564,7 +603,7 @@ export const b = new A();`);
564
603
565
604
host . clearDiagnostics ( ) ;
566
605
builder . buildAllProjects ( ) ;
567
- host . assertDiagnosticMessages ( Diagnostics . The_files_list_in_config_file_0_is_empty ) ;
606
+ host . assertDiagnosticMessages ( [ Diagnostics . The_files_list_in_config_file_0_is_empty , "/src/no-references/tsconfig.json" ] ) ;
568
607
569
608
// Check for outputs to not be written.
570
609
for ( const output of allExpectedOutputs ) {
0 commit comments