@@ -2,7 +2,7 @@ namespace ts.tscWatch {
2
2
export import libFile = TestFSWithWatch . libFile ;
3
3
function createSolutionBuilder ( system : WatchedSystem , rootNames : ReadonlyArray < string > , defaultOptions ?: BuildOptions ) {
4
4
const host = createSolutionBuilderWithWatchHost ( system ) ;
5
- return ts . createSolutionBuilder ( host , rootNames , defaultOptions || { dry : false , force : false , verbose : false , watch : true } ) ;
5
+ return ts . createSolutionBuilder ( host , rootNames , defaultOptions || { watch : true } ) ;
6
6
}
7
7
8
8
function createSolutionBuilderWithWatch ( host : WatchedSystem , rootNames : ReadonlyArray < string > , defaultOptions ?: BuildOptions ) {
@@ -95,11 +95,11 @@ namespace ts.tscWatch {
95
95
const allFiles : ReadonlyArray < File > = [ libFile , ...core , ...logic , ...tests , ...ui ] ;
96
96
const testProjectExpectedWatchedFiles = [ core [ 0 ] , core [ 1 ] , core [ 2 ] , ...logic , ...tests ] . map ( f => f . path ) ;
97
97
98
- function createSolutionInWatchMode ( allFiles : ReadonlyArray < File > ) {
98
+ function createSolutionInWatchMode ( allFiles : ReadonlyArray < File > , defaultOptions ?: BuildOptions , disableConsoleClears ?: boolean ) {
99
99
const host = createWatchedSystem ( allFiles , { currentDirectory : projectsLocation } ) ;
100
- createSolutionBuilderWithWatch ( host , [ `${ project } /${ SubProject . tests } ` ] ) ;
100
+ createSolutionBuilderWithWatch ( host , [ `${ project } /${ SubProject . tests } ` ] , defaultOptions ) ;
101
101
verifyWatches ( host ) ;
102
- checkOutputErrorsInitial ( host , emptyArray ) ;
102
+ checkOutputErrorsInitial ( host , emptyArray , disableConsoleClears ) ;
103
103
const outputFileStamps = getOutputFileStamps ( host ) ;
104
104
for ( const stamp of outputFileStamps ) {
105
105
assert . isDefined ( stamp [ 1 ] , `${ stamp [ 0 ] } expected to be present` ) ;
@@ -351,32 +351,42 @@ function myFunc() { return 100; }`);
351
351
}
352
352
} ) ;
353
353
354
- it ( "reports errors in all projects on incremental compile" , ( ) => {
355
- const host = createSolutionInWatchMode ( allFiles ) ;
356
- const outputFileStamps = getOutputFileStamps ( host ) ;
354
+ describe ( "reports errors in all projects on incremental compile" , ( ) => {
355
+ function verifyIncrementalErrors ( defaultBuildOptions ?: BuildOptions , disabledConsoleClear ?: boolean ) {
356
+ const host = createSolutionInWatchMode ( allFiles , defaultBuildOptions , disabledConsoleClear ) ;
357
+ const outputFileStamps = getOutputFileStamps ( host ) ;
357
358
358
- host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
359
+ host . writeFile ( logic [ 1 ] . path , `${ logic [ 1 ] . content }
359
360
let y: string = 10;` ) ;
360
361
361
- host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds logic
362
- const changedLogic = getOutputFileStamps ( host ) ;
363
- verifyChangedFiles ( changedLogic , outputFileStamps , emptyArray ) ;
364
- host . checkTimeoutQueueLength ( 0 ) ;
365
- checkOutputErrorsIncremental ( host , [
366
- `sample1/logic/index.ts(8,5): error TS2322: Type '10' is not assignable to type 'string'.\n`
367
- ] ) ;
362
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds logic
363
+ const changedLogic = getOutputFileStamps ( host ) ;
364
+ verifyChangedFiles ( changedLogic , outputFileStamps , emptyArray ) ;
365
+ host . checkTimeoutQueueLength ( 0 ) ;
366
+ checkOutputErrorsIncremental ( host , [
367
+ `sample1/logic/index.ts(8,5): error TS2322: Type '10' is not assignable to type 'string'.\n`
368
+ ] , disabledConsoleClear ) ;
368
369
369
- host . writeFile ( core [ 1 ] . path , `${ core [ 1 ] . content }
370
+ host . writeFile ( core [ 1 ] . path , `${ core [ 1 ] . content }
370
371
let x: string = 10;` ) ;
371
372
372
- host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds core
373
- const changedCore = getOutputFileStamps ( host ) ;
374
- verifyChangedFiles ( changedCore , changedLogic , emptyArray ) ;
375
- host . checkTimeoutQueueLength ( 0 ) ;
376
- checkOutputErrorsIncremental ( host , [
377
- `sample1/core/index.ts(5,5): error TS2322: Type '10' is not assignable to type 'string'.\n` ,
378
- `sample1/logic/index.ts(8,5): error TS2322: Type '10' is not assignable to type 'string'.\n`
379
- ] ) ;
373
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds core
374
+ const changedCore = getOutputFileStamps ( host ) ;
375
+ verifyChangedFiles ( changedCore , changedLogic , emptyArray ) ;
376
+ host . checkTimeoutQueueLength ( 0 ) ;
377
+ checkOutputErrorsIncremental ( host , [
378
+ `sample1/core/index.ts(5,5): error TS2322: Type '10' is not assignable to type 'string'.\n` ,
379
+ `sample1/logic/index.ts(8,5): error TS2322: Type '10' is not assignable to type 'string'.\n`
380
+ ] , disabledConsoleClear ) ;
381
+ }
382
+
383
+ it ( "when preserveWatchOutput is not used" , ( ) => {
384
+ verifyIncrementalErrors ( ) ;
385
+ } ) ;
386
+
387
+ it ( "when preserveWatchOutput is passed on command line" , ( ) => {
388
+ verifyIncrementalErrors ( { preserveWatchOutput : true , watch : true } , /*disabledConsoleClear*/ true ) ;
389
+ } ) ;
380
390
} ) ;
381
391
// TODO: write tests reporting errors but that will have more involved work since file
382
392
} ) ;
0 commit comments