@@ -66,7 +66,22 @@ namespace ts {
66
66
interface ReadonlyArray<T> {}
67
67
declare const console: { log(msg: any): void; };` ;
68
68
69
- export function loadProjectFromDisk ( root : string , time ?: vfs . FileSystemOptions [ "time" ] ) : vfs . FileSystem {
69
+ export const symbolLibContent = `
70
+ interface SymbolConstructor {
71
+ readonly species: symbol;
72
+ readonly toStringTag: symbol;
73
+ }
74
+ declare var Symbol: SymbolConstructor;
75
+ interface Symbol {
76
+ readonly [Symbol.toStringTag]: string;
77
+ }
78
+ ` ;
79
+
80
+ export function loadProjectFromDisk (
81
+ root : string ,
82
+ time ?: vfs . FileSystemOptions [ "time" ] ,
83
+ libContentToAppend ?: string
84
+ ) : vfs . FileSystem {
70
85
const resolver = vfs . createResolver ( Harness . IO ) ;
71
86
const fs = new vfs . FileSystem ( /*ignoreCase*/ true , {
72
87
files : {
@@ -76,10 +91,29 @@ declare const console: { log(msg: any): void; };`;
76
91
meta : { defaultLibLocation : "/lib" } ,
77
92
time
78
93
} ) ;
94
+ addLibAndMakeReadonly ( fs , libContentToAppend ) ;
95
+ return fs ;
96
+ }
97
+
98
+ export function loadProjectFromFiles (
99
+ files : vfs . FileSet ,
100
+ time ?: vfs . FileSystemOptions [ "time" ] ,
101
+ libContentToAppend ?: string
102
+ ) : vfs . FileSystem {
103
+ const fs = new vfs . FileSystem ( /*ignoreCase*/ true , {
104
+ files,
105
+ cwd : "/" ,
106
+ meta : { defaultLibLocation : "/lib" } ,
107
+ time
108
+ } ) ;
109
+ addLibAndMakeReadonly ( fs , libContentToAppend ) ;
110
+ return fs ;
111
+ }
112
+
113
+ function addLibAndMakeReadonly ( fs : vfs . FileSystem , libContentToAppend ?: string ) {
79
114
fs . mkdirSync ( "/lib" ) ;
80
- fs . writeFileSync ( "/lib/lib.d.ts" , libContent ) ;
115
+ fs . writeFileSync ( "/lib/lib.d.ts" , libContentToAppend ? ` ${ libContent } ${ libContentToAppend } ` : libContent ) ;
81
116
fs . makeReadonly ( ) ;
82
- return fs ;
83
117
}
84
118
85
119
export function verifyOutputsPresent ( fs : vfs . FileSystem , outputs : readonly string [ ] ) {
@@ -163,7 +197,7 @@ declare const console: { log(msg: any): void; };`;
163
197
fs : vfs . FileSystem ;
164
198
tick : ( ) => void ;
165
199
rootNames : ReadonlyArray < string > ;
166
- expectedMapFileNames : ReadonlyArray < string > ;
200
+ expectedMapFileNames ? : ReadonlyArray < string > ;
167
201
expectedBuildInfoFilesForSectionBaselines ?: ReadonlyArray < BuildInfoSectionBaselineFiles > ;
168
202
modifyFs : ( fs : vfs . FileSystem ) => void ;
169
203
}
@@ -185,7 +219,7 @@ declare const console: { log(msg: any): void; };`;
185
219
return originalReadFile . call ( host , path ) ;
186
220
} ;
187
221
builder . build ( ) ;
188
- generateSourceMapBaselineFiles ( fs , expectedMapFileNames ) ;
222
+ if ( expectedMapFileNames ) generateSourceMapBaselineFiles ( fs , expectedMapFileNames ) ;
189
223
generateBuildInfoSectionBaselineFiles ( fs , expectedBuildInfoFilesForSectionBaselines || emptyArray ) ;
190
224
fs . makeReadonly ( ) ;
191
225
return { fs, actualReadFileMap, host, builder } ;
@@ -232,9 +266,10 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
232
266
tick : ( ) => void ;
233
267
proj : string ;
234
268
rootNames : ReadonlyArray < string > ;
235
- expectedMapFileNames : ReadonlyArray < string > ;
269
+ /** map file names to generate baseline of */
270
+ expectedMapFileNames ?: ReadonlyArray < string > ;
236
271
expectedBuildInfoFilesForSectionBaselines ?: ReadonlyArray < BuildInfoSectionBaselineFiles > ;
237
- lastProjectOutputJs : string ;
272
+ lastProjectOutput : string ;
238
273
initialBuild : BuildState ;
239
274
outputFiles ?: ReadonlyArray < string > ;
240
275
incrementalDtsChangedBuild ?: BuildState ;
@@ -246,7 +281,7 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
246
281
247
282
export function verifyTsbuildOutput ( {
248
283
scenario, projFs, time, tick, proj, rootNames, outputFiles, baselineOnly, verifyDiagnostics,
249
- expectedMapFileNames, expectedBuildInfoFilesForSectionBaselines, lastProjectOutputJs ,
284
+ expectedMapFileNames, expectedBuildInfoFilesForSectionBaselines, lastProjectOutput ,
250
285
initialBuild, incrementalDtsChangedBuild, incrementalDtsUnchangedBuild, incrementalHeaderChangedBuild
251
286
} : VerifyTsBuildInput ) {
252
287
describe ( `tsc --b ${ proj } :: ${ scenario } ` , ( ) => {
@@ -295,7 +330,7 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
295
330
let beforeBuildTime : number ;
296
331
let afterBuildTime : number ;
297
332
before ( ( ) => {
298
- beforeBuildTime = fs . statSync ( lastProjectOutputJs ) . mtimeMs ;
333
+ beforeBuildTime = fs . statSync ( lastProjectOutput ) . mtimeMs ;
299
334
tick ( ) ;
300
335
newFs = fs . shadow ( ) ;
301
336
tick ( ) ;
@@ -307,7 +342,7 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
307
342
expectedBuildInfoFilesForSectionBaselines,
308
343
modifyFs : incrementalModifyFs ,
309
344
} ) ) ;
310
- afterBuildTime = newFs . statSync ( lastProjectOutputJs ) . mtimeMs ;
345
+ afterBuildTime = newFs . statSync ( lastProjectOutput ) . mtimeMs ;
311
346
} ) ;
312
347
after ( ( ) => {
313
348
newFs = undefined ! ;
@@ -337,7 +372,6 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt
337
372
fs : newFs . shadow ( ) ,
338
373
tick,
339
374
rootNames,
340
- expectedMapFileNames : emptyArray ,
341
375
modifyFs : fs => {
342
376
// Delete output files
343
377
for ( const outputFile of expectedOutputFiles ) {
0 commit comments