@@ -95,7 +95,7 @@ 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 ( ) {
98
+ function createSolutionInWatchMode ( allFiles : ReadonlyArray < File > ) {
99
99
const host = createWatchedSystem ( allFiles , { currentDirectory : projectsLocation } ) ;
100
100
createSolutionBuilderWithWatch ( host , [ `${ project } /${ SubProject . tests } ` ] ) ;
101
101
verifyWatches ( host ) ;
@@ -114,7 +114,7 @@ namespace ts.tscWatch {
114
114
}
115
115
116
116
it ( "creates solution in watch mode" , ( ) => {
117
- createSolutionInWatchMode ( ) ;
117
+ createSolutionInWatchMode ( allFiles ) ;
118
118
} ) ;
119
119
120
120
describe ( "validates the changes and watched files" , ( ) => {
@@ -124,82 +124,99 @@ namespace ts.tscWatch {
124
124
content : `export const newFileConst = 30;`
125
125
} ;
126
126
127
- function createSolutionInWatchModeToVerifyChanges ( additionalFiles ?: ReadonlyArray < [ SubProject , string ] > ) {
128
- const host = createSolutionInWatchMode ( ) ;
129
- return { host, verifyChangeWithFile, verifyChangeAfterTimeout, verifyWatches } ;
127
+ function verifyProjectChanges ( allFiles : ReadonlyArray < File > ) {
128
+ function createSolutionInWatchModeToVerifyChanges ( additionalFiles ?: ReadonlyArray < [ SubProject , string ] > ) {
129
+ const host = createSolutionInWatchMode ( allFiles ) ;
130
+ return { host, verifyChangeWithFile, verifyChangeAfterTimeout, verifyWatches } ;
130
131
131
- function verifyChangeWithFile ( fileName : string , content : string ) {
132
- const outputFileStamps = getOutputFileStamps ( host , additionalFiles ) ;
133
- host . writeFile ( fileName , content ) ;
134
- verifyChangeAfterTimeout ( outputFileStamps ) ;
135
- }
132
+ function verifyChangeWithFile ( fileName : string , content : string ) {
133
+ const outputFileStamps = getOutputFileStamps ( host , additionalFiles ) ;
134
+ host . writeFile ( fileName , content ) ;
135
+ verifyChangeAfterTimeout ( outputFileStamps ) ;
136
+ }
136
137
137
- function verifyChangeAfterTimeout ( outputFileStamps : OutputFileStamp [ ] ) {
138
- host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds core
139
- const changedCore = getOutputFileStamps ( host , additionalFiles ) ;
140
- verifyChangedFiles ( changedCore , outputFileStamps , [
141
- ...getOutputFileNames ( SubProject . core , "anotherModule" ) , // This should not be written really
142
- ...getOutputFileNames ( SubProject . core , "index" ) ,
143
- ...( additionalFiles ? getOutputFileNames ( SubProject . core , newFileWithoutExtension ) : emptyArray )
144
- ] ) ;
145
- host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds logic
146
- const changedLogic = getOutputFileStamps ( host , additionalFiles ) ;
147
- verifyChangedFiles ( changedLogic , changedCore , [
148
- ...getOutputFileNames ( SubProject . logic , "index" ) // Again these need not be written
149
- ] ) ;
150
- host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds tests
151
- const changedTests = getOutputFileStamps ( host , additionalFiles ) ;
152
- verifyChangedFiles ( changedTests , changedLogic , [
153
- ...getOutputFileNames ( SubProject . tests , "index" ) // Again these need not be written
154
- ] ) ;
155
- host . checkTimeoutQueueLength ( 0 ) ;
156
- checkOutputErrorsIncremental ( host , emptyArray ) ;
157
- verifyWatches ( ) ;
158
- }
138
+ function verifyChangeAfterTimeout ( outputFileStamps : OutputFileStamp [ ] ) {
139
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds core
140
+ const changedCore = getOutputFileStamps ( host , additionalFiles ) ;
141
+ verifyChangedFiles ( changedCore , outputFileStamps , [
142
+ ...getOutputFileNames ( SubProject . core , "anotherModule" ) , // This should not be written really
143
+ ...getOutputFileNames ( SubProject . core , "index" ) ,
144
+ ...( additionalFiles ? getOutputFileNames ( SubProject . core , newFileWithoutExtension ) : emptyArray )
145
+ ] ) ;
146
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds logic
147
+ const changedLogic = getOutputFileStamps ( host , additionalFiles ) ;
148
+ verifyChangedFiles ( changedLogic , changedCore , [
149
+ ...getOutputFileNames ( SubProject . logic , "index" ) // Again these need not be written
150
+ ] ) ;
151
+ host . checkTimeoutQueueLengthAndRun ( 1 ) ; // Builds tests
152
+ const changedTests = getOutputFileStamps ( host , additionalFiles ) ;
153
+ verifyChangedFiles ( changedTests , changedLogic , [
154
+ ...getOutputFileNames ( SubProject . tests , "index" ) // Again these need not be written
155
+ ] ) ;
156
+ host . checkTimeoutQueueLength ( 0 ) ;
157
+ checkOutputErrorsIncremental ( host , emptyArray ) ;
158
+ verifyWatches ( ) ;
159
+ }
159
160
160
- function verifyWatches ( ) {
161
- checkWatchedFiles ( host , additionalFiles ? testProjectExpectedWatchedFiles . concat ( newFile . path ) : testProjectExpectedWatchedFiles ) ;
162
- checkWatchedDirectories ( host , emptyArray , /*recursive*/ false ) ;
163
- checkWatchedDirectories ( host , [ projectPath ( SubProject . core ) , projectPath ( SubProject . logic ) ] , /*recursive*/ true ) ;
161
+ function verifyWatches ( ) {
162
+ checkWatchedFiles ( host , additionalFiles ? testProjectExpectedWatchedFiles . concat ( newFile . path ) : testProjectExpectedWatchedFiles ) ;
163
+ checkWatchedDirectories ( host , emptyArray , /*recursive*/ false ) ;
164
+ checkWatchedDirectories ( host , [ projectPath ( SubProject . core ) , projectPath ( SubProject . logic ) ] , /*recursive*/ true ) ;
165
+ }
164
166
}
165
- }
166
167
167
- it ( "change builds changes and reports found errors message" , ( ) => {
168
- const { host, verifyChangeWithFile, verifyChangeAfterTimeout } = createSolutionInWatchModeToVerifyChanges ( ) ;
169
- verifyChange ( `${ core [ 1 ] . content }
168
+ it ( "change builds changes and reports found errors message" , ( ) => {
169
+ const { host, verifyChangeWithFile, verifyChangeAfterTimeout } = createSolutionInWatchModeToVerifyChanges ( ) ;
170
+ verifyChange ( `${ core [ 1 ] . content }
170
171
export class someClass { }` ) ;
171
172
172
- // Another change requeues and builds it
173
- verifyChange ( core [ 1 ] . content ) ;
173
+ // Another change requeues and builds it
174
+ verifyChange ( core [ 1 ] . content ) ;
174
175
175
- // Two changes together report only single time message: File change detected. Starting incremental compilation...
176
- const outputFileStamps = getOutputFileStamps ( host ) ;
177
- const change1 = `${ core [ 1 ] . content }
176
+ // Two changes together report only single time message: File change detected. Starting incremental compilation...
177
+ const outputFileStamps = getOutputFileStamps ( host ) ;
178
+ const change1 = `${ core [ 1 ] . content }
178
179
export class someClass { }` ;
179
- host . writeFile ( core [ 1 ] . path , change1 ) ;
180
- host . writeFile ( core [ 1 ] . path , `${ change1 }
180
+ host . writeFile ( core [ 1 ] . path , change1 ) ;
181
+ host . writeFile ( core [ 1 ] . path , `${ change1 }
181
182
export class someClass2 { }` ) ;
182
- verifyChangeAfterTimeout ( outputFileStamps ) ;
183
+ verifyChangeAfterTimeout ( outputFileStamps ) ;
183
184
184
- function verifyChange ( coreContent : string ) {
185
- verifyChangeWithFile ( core [ 1 ] . path , coreContent ) ;
186
- }
187
- } ) ;
185
+ function verifyChange ( coreContent : string ) {
186
+ verifyChangeWithFile ( core [ 1 ] . path , coreContent ) ;
187
+ }
188
+ } ) ;
188
189
189
- it ( "builds when new file is added, and its subsequent updates" , ( ) => {
190
- const additinalFiles : ReadonlyArray < [ SubProject , string ] > = [ [ SubProject . core , newFileWithoutExtension ] ] ;
191
- const { verifyChangeWithFile } = createSolutionInWatchModeToVerifyChanges ( additinalFiles ) ;
192
- verifyChange ( newFile . content ) ;
190
+ it ( "builds when new file is added, and its subsequent updates" , ( ) => {
191
+ const additinalFiles : ReadonlyArray < [ SubProject , string ] > = [ [ SubProject . core , newFileWithoutExtension ] ] ;
192
+ const { verifyChangeWithFile } = createSolutionInWatchModeToVerifyChanges ( additinalFiles ) ;
193
+ verifyChange ( newFile . content ) ;
193
194
194
- // Another change requeues and builds it
195
- verifyChange ( `${ newFile . content }
195
+ // Another change requeues and builds it
196
+ verifyChange ( `${ newFile . content }
196
197
export class someClass2 { }` ) ;
197
198
198
- function verifyChange ( newFileContent : string ) {
199
- verifyChangeWithFile ( newFile . path , newFileContent ) ;
200
- }
199
+ function verifyChange ( newFileContent : string ) {
200
+ verifyChangeWithFile ( newFile . path , newFileContent ) ;
201
+ }
202
+ } ) ;
203
+ }
204
+
205
+ describe ( "with simple project reference graph" , ( ) => {
206
+ verifyProjectChanges ( allFiles ) ;
201
207
} ) ;
202
208
209
+ describe ( "with circular project reference" , ( ) => {
210
+ const [ coreTsconfig , ...otherCoreFiles ] = core ;
211
+ const circularCoreConfig : File = {
212
+ path : coreTsconfig . path ,
213
+ content : JSON . stringify ( {
214
+ compilerOptions : { composite : true , declaration : true } ,
215
+ references : [ { path : "../tests" , circular : true } ]
216
+ } )
217
+ } ;
218
+ verifyProjectChanges ( [ libFile , circularCoreConfig , ...otherCoreFiles , ...logic , ...tests ] ) ;
219
+ } ) ;
203
220
} ) ;
204
221
205
222
it ( "watches config files that are not present" , ( ) => {
0 commit comments