@@ -56,11 +56,6 @@ namespace ts {
56
56
]
57
57
] ;
58
58
const relSources = sources . map ( ( [ config , sources ] ) => [ relName ( config ) , sources . map ( relName ) ] ) as any as [ Sources , Sources , Sources ] ;
59
- let expectedOutputFiles = [
60
- ...outputFiles [ project . first ] ,
61
- ...outputFiles [ project . second ] ,
62
- ...outputFiles [ project . third ]
63
- ] ;
64
59
let initialExpectedDiagnostics : readonly fakes . ExpectedDiagnostic [ ] = [
65
60
getExpectedDiagnosticForProjectsInBuild ( relSources [ project . first ] [ source . config ] , relSources [ project . second ] [ source . config ] , relSources [ project . third ] [ source . config ] ) ,
66
61
[ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , relSources [ project . first ] [ source . config ] , relOutputFiles [ project . first ] [ ext . js ] ] ,
@@ -75,7 +70,6 @@ namespace ts {
75
70
} ) ;
76
71
after ( ( ) => {
77
72
outFileFs = undefined ! ;
78
- expectedOutputFiles = undefined ! ;
79
73
initialExpectedDiagnostics = undefined ! ;
80
74
} ) ;
81
75
@@ -166,71 +160,37 @@ namespace ts {
166
160
baselineOnly : true
167
161
} ) ;
168
162
169
- it ( "clean projects" , ( ) => {
163
+ function getOutFileFsAfterBuild ( ) {
170
164
const fs = outFileFs . shadow ( ) ;
171
- const expectedOutputs = [
172
- ...outputFiles [ project . first ] ,
173
- ...outputFiles [ project . second ] ,
174
- ...outputFiles [ project . third ]
175
- ] ;
176
165
const host = fakes . SolutionBuilderHost . create ( fs ) ;
177
166
const builder = createSolutionBuilder ( host ) ;
178
167
builder . build ( ) ;
179
- host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
180
- // Verify they exist
181
- verifyOutputsPresent ( fs , expectedOutputs ) ;
182
- host . clearDiagnostics ( ) ;
183
- builder . clean ( ) ;
184
- host . assertDiagnosticMessages ( /*none*/ ) ;
185
- // Verify they are gone
186
- verifyOutputsAbsent ( fs , expectedOutputs ) ;
187
- // Subsequent clean shouldn't throw / etc
188
- builder . clean ( ) ;
189
- } ) ;
190
-
191
- it ( "verify buildInfo absence results in new build" , ( ) => {
192
- const { fs, tick } = getFsWithTime ( outFileFs ) ;
193
- const expectedOutputs = [
194
- ...outputFiles [ project . first ] ,
195
- ...outputFiles [ project . second ] ,
196
- ...outputFiles [ project . third ]
197
- ] ;
198
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
199
- let builder = createSolutionBuilder ( host ) ;
200
- builder . build ( ) ;
201
- host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
202
- // Verify they exist
203
- verifyOutputsPresent ( fs , expectedOutputs ) ;
204
- // Delete bundle info
205
- host . clearDiagnostics ( ) ;
168
+ fs . makeReadonly ( ) ;
169
+ return fs ;
170
+ }
206
171
207
- tick ( ) ;
208
- host . deleteFile ( outputFiles [ project . first ] [ ext . buildinfo ] ) ;
209
- tick ( ) ;
172
+ verifyTscIncrementalEdits ( {
173
+ scenario : "outFile" ,
174
+ subScenario : "clean projects" ,
175
+ fs : getOutFileFsAfterBuild ,
176
+ commandLineArgs : [ "--b" , "/src/third" , "--clean" ] ,
177
+ incrementalScenarios : [ noChangeRun ]
178
+ } ) ;
210
179
211
- builder = createSolutionBuilder ( host ) ;
212
- builder . build ( ) ;
213
- host . assertDiagnosticMessages (
214
- getExpectedDiagnosticForProjectsInBuild ( relSources [ project . first ] [ source . config ] , relSources [ project . second ] [ source . config ] , relSources [ project . third ] [ source . config ] ) ,
215
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , relSources [ project . first ] [ source . config ] , relOutputFiles [ project . first ] [ ext . buildinfo ] ] ,
216
- [ Diagnostics . Building_project_0 , sources [ project . first ] [ source . config ] ] ,
217
- [ Diagnostics . Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2 , relSources [ project . second ] [ source . config ] , relSources [ project . second ] [ source . ts ] [ part . one ] , relOutputFiles [ project . second ] [ ext . js ] ] ,
218
- [ Diagnostics . Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed , relSources [ project . third ] [ source . config ] , "src/first" ] ,
219
- [ Diagnostics . Updating_output_of_project_0 , sources [ project . third ] [ source . config ] ] ,
220
- [ Diagnostics . Updating_unchanged_output_timestamps_of_project_0 , sources [ project . third ] [ source . config ] ] ,
221
- ) ;
180
+ verifyTsc ( {
181
+ scenario : "outFile" ,
182
+ subScenario : "verify buildInfo absence results in new build" ,
183
+ fs : getOutFileFsAfterBuild ,
184
+ commandLineArgs : [ "--b" , "/src/third" , "--verbose" ] ,
185
+ modifyFs : fs => fs . unlinkSync ( outputFiles [ project . first ] [ ext . buildinfo ] ) ,
222
186
} ) ;
223
187
224
- it ( "verify that if incremental is set to false, tsbuildinfo is not generated" , ( ) => {
225
- const fs = outFileFs . shadow ( ) ;
226
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
227
- replaceText ( fs , sources [ project . third ] [ source . config ] , `"composite": true,` , "" ) ;
228
- const builder = createSolutionBuilder ( host ) ;
229
- builder . build ( ) ;
230
- host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
231
- // Verify they exist - without tsbuildinfo for third project
232
- verifyOutputsPresent ( fs , expectedOutputFiles . slice ( 0 , expectedOutputFiles . length - 2 ) ) ;
233
- verifyOutputsAbsent ( fs , [ outputFiles [ project . third ] [ ext . buildinfo ] ] ) ;
188
+ verifyTsc ( {
189
+ scenario : "outFile" ,
190
+ subScenario : "tsbuildinfo is not generated when incremental is set to false" ,
191
+ fs : ( ) => outFileFs ,
192
+ commandLineArgs : [ "--b" , "/src/third" , "--verbose" ] ,
193
+ modifyFs : fs => replaceText ( fs , sources [ project . third ] [ source . config ] , `"composite": true,` , "" ) ,
234
194
} ) ;
235
195
236
196
it ( "rebuilds completely when version in tsbuildinfo doesnt match ts version" , ( ) => {
@@ -747,44 +707,26 @@ ${internal} enum internalEnum { a, b, c }`);
747
707
} ) ;
748
708
} ) ;
749
709
750
- it ( "non module projects without prepend" , ( ) => {
751
- const fs = outFileFs . shadow ( ) ;
752
- // No prepend
753
- replaceText ( fs , sources [ project . third ] [ source . config ] , `{ "path": "../first", "prepend": true }` , `{ "path": "../first" }` ) ;
754
- replaceText ( fs , sources [ project . third ] [ source . config ] , `{ "path": "../second", "prepend": true }` , `{ "path": "../second" }` ) ;
755
-
756
- // Non Modules
757
- replaceText ( fs , sources [ project . first ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
758
- replaceText ( fs , sources [ project . second ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
759
- replaceText ( fs , sources [ project . third ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
760
-
761
- // Own file emit
762
- replaceText ( fs , sources [ project . first ] [ source . config ] , `"outFile": "./bin/first-output.js",` , "" ) ;
763
- replaceText ( fs , sources [ project . second ] [ source . config ] , `"outFile": "../2/second-output.js",` , "" ) ;
764
- replaceText ( fs , sources [ project . third ] [ source . config ] , `"outFile": "./thirdjs/output/third-output.js",` , "" ) ;
765
-
766
- const host = fakes . SolutionBuilderHost . create ( fs ) ;
767
- const builder = createSolutionBuilder ( host ) ;
768
- builder . build ( ) ;
769
- host . assertDiagnosticMessages (
770
- getExpectedDiagnosticForProjectsInBuild ( relSources [ project . first ] [ source . config ] , relSources [ project . second ] [ source . config ] , relSources [ project . third ] [ source . config ] ) ,
771
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , relSources [ project . first ] [ source . config ] , "src/first/first_PART1.js" ] ,
772
- [ Diagnostics . Building_project_0 , sources [ project . first ] [ source . config ] ] ,
773
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , relSources [ project . second ] [ source . config ] , "src/second/second_part1.js" ] ,
774
- [ Diagnostics . Building_project_0 , sources [ project . second ] [ source . config ] ] ,
775
- [ Diagnostics . Project_0_is_out_of_date_because_output_file_1_does_not_exist , relSources [ project . third ] [ source . config ] , "src/third/third_part1.js" ] ,
776
- [ Diagnostics . Building_project_0 , sources [ project . third ] [ source . config ] ]
777
- ) ;
778
- const expectedOutputFiles = flatMap ( sources , ( [ config , ts ] ) => [
779
- removeFileExtension ( config ) + Extension . TsBuildInfo ,
780
- ...flatMap ( ts , f => [
781
- removeFileExtension ( f ) + Extension . Js ,
782
- removeFileExtension ( f ) + Extension . Js + ".map" ,
783
- removeFileExtension ( f ) + Extension . Dts ,
784
- removeFileExtension ( f ) + Extension . Dts + ".map" ,
785
- ] )
786
- ] ) ;
787
- verifyOutputsPresent ( fs , expectedOutputFiles ) ;
710
+ verifyTsc ( {
711
+ scenario : "outFile" ,
712
+ subScenario : "non module projects without prepend" ,
713
+ fs : ( ) => outFileFs ,
714
+ commandLineArgs : [ "--b" , "/src/third" , "--verbose" ] ,
715
+ modifyFs : fs => {
716
+ // No prepend
717
+ replaceText ( fs , sources [ project . third ] [ source . config ] , `{ "path": "../first", "prepend": true }` , `{ "path": "../first" }` ) ;
718
+ replaceText ( fs , sources [ project . third ] [ source . config ] , `{ "path": "../second", "prepend": true }` , `{ "path": "../second" }` ) ;
719
+
720
+ // Non Modules
721
+ replaceText ( fs , sources [ project . first ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
722
+ replaceText ( fs , sources [ project . second ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
723
+ replaceText ( fs , sources [ project . third ] [ source . config ] , `"composite": true,` , `"composite": true, "module": "none",` ) ;
724
+
725
+ // Own file emit
726
+ replaceText ( fs , sources [ project . first ] [ source . config ] , `"outFile": "./bin/first-output.js",` , "" ) ;
727
+ replaceText ( fs , sources [ project . second ] [ source . config ] , `"outFile": "../2/second-output.js",` , "" ) ;
728
+ replaceText ( fs , sources [ project . third ] [ source . config ] , `"outFile": "./thirdjs/output/third-output.js",` , "" ) ;
729
+ } ,
788
730
} ) ;
789
731
} ) ;
790
732
}
0 commit comments