@@ -366,18 +366,14 @@ namespace ts {
366366 builder . build ( ) ;
367367 host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
368368 // Verify they exist
369- for ( const output of expectedOutputs ) {
370- assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
371- }
369+ verifyOutputsPresent ( fs , expectedOutputs ) ;
372370 host . clearDiagnostics ( ) ;
373- builder . cleanAllProjects ( ) ;
371+ builder . clean ( ) ;
374372 host . assertDiagnosticMessages ( /*none*/ ) ;
375373 // Verify they are gone
376- for ( const output of expectedOutputs ) {
377- assert ( ! fs . existsSync ( output ) , `Expect file ${ output } to not exist` ) ;
378- }
374+ verifyOutputsAbsent ( fs , expectedOutputs ) ;
379375 // Subsequent clean shouldn't throw / etc
380- builder . cleanAllProjects ( ) ;
376+ builder . clean ( ) ;
381377 } ) ;
382378
383379 it ( "verify buildInfo absence results in new build" , ( ) => {
@@ -392,9 +388,7 @@ namespace ts {
392388 builder . build ( ) ;
393389 host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
394390 // Verify they exist
395- for ( const output of expectedOutputs ) {
396- assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
397- }
391+ verifyOutputsPresent ( fs , expectedOutputs ) ;
398392 // Delete bundle info
399393 host . clearDiagnostics ( ) ;
400394 host . deleteFile ( outputFiles [ project . first ] [ ext . buildinfo ] ) ;
@@ -419,10 +413,8 @@ namespace ts {
419413 builder . build ( ) ;
420414 host . assertDiagnosticMessages ( ...initialExpectedDiagnostics ) ;
421415 // Verify they exist - without tsbuildinfo for third project
422- for ( const output of expectedOutputFiles . slice ( 0 , expectedOutputFiles . length - 2 ) ) {
423- assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
424- }
425- assert . isFalse ( fs . existsSync ( outputFiles [ project . third ] [ ext . buildinfo ] ) , `Expect file ${ outputFiles [ project . third ] [ ext . buildinfo ] } to not exist` ) ;
416+ verifyOutputsPresent ( fs , expectedOutputFiles . slice ( 0 , expectedOutputFiles . length - 2 ) ) ;
417+ verifyOutputsAbsent ( fs , [ outputFiles [ project . third ] [ ext . buildinfo ] ] ) ;
426418 } ) ;
427419
428420 it ( "rebuilds completely when version in tsbuildinfo doesnt match ts version" , ( ) => {
@@ -496,13 +488,23 @@ namespace ts {
496488 const result = builder . build ( sources [ project . second ] [ source . config ] ) ;
497489 host . assertDiagnosticMessages ( /*empty*/ ) ;
498490 // First and Third is not built
499- for ( const output of [ ...outputFiles [ project . first ] , ...outputFiles [ project . third ] ] ) {
500- assert . isFalse ( fs . existsSync ( output ) , `Expect file ${ output } to not exist` ) ;
501- }
491+ verifyOutputsAbsent ( fs , [ ...outputFiles [ project . first ] , ...outputFiles [ project . third ] ] ) ;
502492 // second is built
503- for ( const output of outputFiles [ project . second ] ) {
504- assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
505- }
493+ verifyOutputsPresent ( fs , outputFiles [ project . second ] ) ;
494+ assert . equal ( result , ExitStatus . Success ) ;
495+ } ) ;
496+
497+ it ( "cleans till project specified" , ( ) => {
498+ const fs = outFileFs . shadow ( ) ;
499+ const host = new fakes . SolutionBuilderHost ( fs ) ;
500+ const builder = createSolutionBuilder ( host , { verbose : false } ) ;
501+ builder . build ( ) ;
502+ const result = builder . clean ( sources [ project . second ] [ source . config ] ) ;
503+ host . assertDiagnosticMessages ( /*empty*/ ) ;
504+ // First and Third output for present
505+ verifyOutputsPresent ( fs , [ ...outputFiles [ project . first ] , ...outputFiles [ project . third ] ] ) ;
506+ // second is cleaned
507+ verifyOutputsAbsent ( fs , outputFiles [ project . second ] ) ;
506508 assert . equal ( result , ExitStatus . Success ) ;
507509 } ) ;
508510
@@ -940,9 +942,7 @@ ${internal} enum internalEnum { a, b, c }`);
940942 removeFileExtension ( f ) + Extension . Dts + ".map" ,
941943 ] )
942944 ] ) ;
943- for ( const output of expectedOutputFiles ) {
944- assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
945- }
945+ verifyOutputsPresent ( fs , expectedOutputFiles ) ;
946946 } ) ;
947947 } ) ;
948948}
0 commit comments