@@ -9,113 +9,53 @@ namespace ts {
9
9
projFs = undefined ! ; // Release the contents
10
10
} ) ;
11
11
12
- it ( "verify that it builds correctly" , ( ) => {
13
- const allExpectedOutputs = [
14
- "/src/dist/other/other.js" , "/src/dist/other/other.d.ts" ,
15
- "/src/dist/main/a.js" , "/src/dist/main/a.d.ts" ,
16
- "/src/dist/main/b.js" , "/src/dist/main/b.d.ts"
17
- ] ;
18
- const fs = projFs . shadow ( ) ;
19
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
20
- const builder = createSolutionBuilder ( host , [ "/src/src/main" , "/src/src/other" ] , { } ) ;
21
- builder . build ( ) ;
22
- host . assertDiagnosticMessages ( /*empty*/ ) ;
23
- verifyOutputsPresent ( fs , allExpectedOutputs ) ;
12
+ verifyTsc ( {
13
+ scenario : "projectReferenceWithRootDirInParent" ,
14
+ subScenario : "builds correctly" ,
15
+ fs : ( ) => projFs ,
16
+ commandLineArgs : [ "--b" , "/src/src/main" , "/src/src/other" ] ,
24
17
} ) ;
25
18
26
- it ( "verify that it reports error for same .tsbuildinfo file because no rootDir in the base" , ( ) => {
27
- const allExpectedOutputs = [
28
- "/src/dist/other.js" , "/src/dist/other.d.ts" ,
29
- "/src/dist/tsconfig.tsbuildinfo"
30
- ] ;
31
- const missingOutputs = [
32
- "/src/dist/a.js" , "/src/dist/a.d.ts" ,
33
- "/src/dist/b.js" , "/src/dist/b.d.ts"
34
- ] ;
35
- const fs = projFs . shadow ( ) ;
36
- replaceText ( fs , "/src/tsconfig.base.json" , `"rootDir": "./src/",` , "" ) ;
37
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
38
- const builder = createSolutionBuilder ( host , [ "/src/src/main" ] , { verbose : true } ) ;
39
- builder . build ( ) ;
40
- host . assertDiagnosticMessages (
41
- getExpectedDiagnosticForProjectsInBuild ( "src/src/other/tsconfig.json" , "src/src/main/tsconfig.json" ) ,
42
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/other/tsconfig.json" , "src/dist/other.js" ] ,
43
- [ Diagnostics . Building_project_0 , "/src/src/other/tsconfig.json" ] ,
44
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/main/tsconfig.json" , "src/dist/a.js" ] ,
45
- [ Diagnostics . Building_project_0 , "/src/src/main/tsconfig.json" ] ,
46
- {
47
- message : [ Diagnostics . Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1 , "/src/dist/tsconfig.tsbuildinfo" , "/src/src/other" ] ,
48
- location : expectedLocationIndexOf ( fs , "/src/src/main/tsconfig.json" , `{ "path": "../other" }` ) ,
49
- }
50
- ) ;
51
- verifyOutputsPresent ( fs , allExpectedOutputs ) ;
52
- verifyOutputsAbsent ( fs , missingOutputs ) ;
19
+ verifyTsc ( {
20
+ scenario : "projectReferenceWithRootDirInParent" ,
21
+ subScenario : "reports error for same tsbuildinfo file because no rootDir in the base" ,
22
+ fs : ( ) => projFs ,
23
+ commandLineArgs : [ "--b" , "/src/src/main" , "--verbose" ] ,
24
+ modifyFs : fs => replaceText ( fs , "/src/tsconfig.base.json" , `"rootDir": "./src/",` , "" ) ,
53
25
} ) ;
54
26
55
- it ( "verify that it reports error for same .tsbuildinfo file" , ( ) => {
56
- const allExpectedOutputs = [
57
- "/src/dist/other.js" , "/src/dist/other.d.ts" ,
58
- "/src/dist/tsconfig.tsbuildinfo"
59
- ] ;
60
- const missingOutputs = [
61
- "/src/dist/a.js" , "/src/dist/a.d.ts" ,
62
- "/src/dist/b.js" , "/src/dist/b.d.ts"
63
- ] ;
64
- const fs = projFs . shadow ( ) ;
65
- fs . writeFileSync ( "/src/src/main/tsconfig.json" , JSON . stringify ( {
66
- compilerOptions : { composite : true , outDir : "../../dist/" } ,
67
- references : [ { path : "../other" } ]
68
- } ) ) ;
69
- fs . writeFileSync ( "/src/src/other/tsconfig.json" , JSON . stringify ( {
70
- compilerOptions : { composite : true , outDir : "../../dist/" } ,
71
- } ) ) ;
72
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
73
- const builder = createSolutionBuilder ( host , [ "/src/src/main" ] , { verbose : true } ) ;
74
- builder . build ( ) ;
75
- host . assertDiagnosticMessages (
76
- getExpectedDiagnosticForProjectsInBuild ( "src/src/other/tsconfig.json" , "src/src/main/tsconfig.json" ) ,
77
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/other/tsconfig.json" , "src/dist/other.js" ] ,
78
- [ Diagnostics . Building_project_0 , "/src/src/other/tsconfig.json" ] ,
79
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/main/tsconfig.json" , "src/dist/a.js" ] ,
80
- [ Diagnostics . Building_project_0 , "/src/src/main/tsconfig.json" ] ,
81
- {
82
- message : [ Diagnostics . Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1 , "/src/dist/tsconfig.tsbuildinfo" , "/src/src/other" ] ,
83
- location : expectedLocationIndexOf ( fs , "/src/src/main/tsconfig.json" , `{"path":"../other"}` ) ,
84
- }
85
- ) ;
86
- verifyOutputsPresent ( fs , allExpectedOutputs ) ;
87
- verifyOutputsAbsent ( fs , missingOutputs ) ;
27
+ verifyTsc ( {
28
+ scenario : "projectReferenceWithRootDirInParent" ,
29
+ subScenario : "reports error for same tsbuildinfo file" ,
30
+ fs : ( ) => projFs ,
31
+ commandLineArgs : [ "--b" , "/src/src/main" , "--verbose" ] ,
32
+ modifyFs : fs => {
33
+ fs . writeFileSync ( "/src/src/main/tsconfig.json" , JSON . stringify ( {
34
+ compilerOptions : { composite : true , outDir : "../../dist/" } ,
35
+ references : [ { path : "../other" } ]
36
+ } ) ) ;
37
+ fs . writeFileSync ( "/src/src/other/tsconfig.json" , JSON . stringify ( {
38
+ compilerOptions : { composite : true , outDir : "../../dist/" } ,
39
+ } ) ) ;
40
+ } ,
88
41
} ) ;
89
42
90
- it ( "verify that it reports no error when .tsbuildinfo differ" , ( ) => {
91
- const allExpectedOutputs = [
92
- "/src/dist/other.js" , "/src/dist/other.d.ts" ,
93
- "/src/dist/tsconfig.main.tsbuildinfo" ,
94
- "/src/dist/a.js" , "/src/dist/a.d.ts" ,
95
- "/src/dist/b.js" , "/src/dist/b.d.ts" ,
96
- "/src/dist/tsconfig.other.tsbuildinfo"
97
- ] ;
98
- const fs = projFs . shadow ( ) ;
99
- fs . renameSync ( "/src/src/main/tsconfig.json" , "/src/src/main/tsconfig.main.json" ) ;
100
- fs . renameSync ( "/src/src/other/tsconfig.json" , "/src/src/other/tsconfig.other.json" ) ;
101
- fs . writeFileSync ( "/src/src/main/tsconfig.main.json" , JSON . stringify ( {
102
- compilerOptions : { composite : true , outDir : "../../dist/" } ,
103
- references : [ { path : "../other/tsconfig.other.json" } ]
104
- } ) ) ;
105
- fs . writeFileSync ( "/src/src/other/tsconfig.other.json" , JSON . stringify ( {
106
- compilerOptions : { composite : true , outDir : "../../dist/" } ,
107
- } ) ) ;
108
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
109
- const builder = createSolutionBuilder ( host , [ "/src/src/main/tsconfig.main.json" ] , { verbose : true } ) ;
110
- builder . build ( ) ;
111
- host . assertDiagnosticMessages (
112
- getExpectedDiagnosticForProjectsInBuild ( "src/src/other/tsconfig.other.json" , "src/src/main/tsconfig.main.json" ) ,
113
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/other/tsconfig.other.json" , "src/dist/other.js" ] ,
114
- [ Diagnostics . Building_project_0 , "/src/src/other/tsconfig.other.json" ] ,
115
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , "src/src/main/tsconfig.main.json" , "src/dist/a.js" ] ,
116
- [ Diagnostics . Building_project_0 , "/src/src/main/tsconfig.main.json" ]
117
- ) ;
118
- verifyOutputsPresent ( fs , allExpectedOutputs ) ;
43
+ verifyTsc ( {
44
+ scenario : "projectReferenceWithRootDirInParent" ,
45
+ subScenario : "reports no error when tsbuildinfo differ" ,
46
+ fs : ( ) => projFs ,
47
+ commandLineArgs : [ "--b" , "/src/src/main/tsconfig.main.json" , "--verbose" ] ,
48
+ modifyFs : fs => {
49
+ fs . renameSync ( "/src/src/main/tsconfig.json" , "/src/src/main/tsconfig.main.json" ) ;
50
+ fs . renameSync ( "/src/src/other/tsconfig.json" , "/src/src/other/tsconfig.other.json" ) ;
51
+ fs . writeFileSync ( "/src/src/main/tsconfig.main.json" , JSON . stringify ( {
52
+ compilerOptions : { composite : true , outDir : "../../dist/" } ,
53
+ references : [ { path : "../other/tsconfig.other.json" } ]
54
+ } ) ) ;
55
+ fs . writeFileSync ( "/src/src/other/tsconfig.other.json" , JSON . stringify ( {
56
+ compilerOptions : { composite : true , outDir : "../../dist/" } ,
57
+ } ) ) ;
58
+ } ,
119
59
} ) ;
120
60
} ) ;
121
61
}
0 commit comments