@@ -113,9 +113,11 @@ interface Symbol {
113113}
114114` ;
115115
116+ /**
117+ * Load project from disk into /src folder
118+ */
116119 export function loadProjectFromDisk (
117120 root : string ,
118- time ?: vfs . FileSystemOptions [ "time" ] ,
119121 libContentToAppend ?: string
120122 ) : vfs . FileSystem {
121123 const resolver = vfs . createResolver ( Harness . IO ) ;
@@ -125,22 +127,22 @@ interface Symbol {
125127 } ,
126128 cwd : "/" ,
127129 meta : { defaultLibLocation : "/lib" } ,
128- time
129130 } ) ;
130131 addLibAndMakeReadonly ( fs , libContentToAppend ) ;
131132 return fs ;
132133 }
133134
135+ /**
136+ * All the files must be in /src
137+ */
134138 export function loadProjectFromFiles (
135139 files : vfs . FileSet ,
136- time ?: vfs . FileSystemOptions [ "time" ] ,
137140 libContentToAppend ?: string
138141 ) : vfs . FileSystem {
139142 const fs = new vfs . FileSystem ( /*ignoreCase*/ true , {
140143 files,
141144 cwd : "/" ,
142145 meta : { defaultLibLocation : "/lib" } ,
143- time
144146 } ) ;
145147 addLibAndMakeReadonly ( fs , libContentToAppend ) ;
146148 return fs ;
@@ -152,6 +154,26 @@ interface Symbol {
152154 fs . makeReadonly ( ) ;
153155 }
154156
157+ /**
158+ * Gets the FS mountuing existing fs's /src and /lib folder
159+ */
160+ export function getFsWithTime ( baseFs : vfs . FileSystem ) {
161+ const { time, tick } = getTime ( ) ;
162+ const host = new fakes . System ( baseFs ) as any as vfs . FileSystemResolverHost ;
163+ host . getWorkspaceRoot = notImplemented ;
164+ const resolver = vfs . createResolver ( host ) ;
165+ const fs = new vfs . FileSystem ( /*ignoreCase*/ true , {
166+ files : {
167+ [ "/src" ] : new vfs . Mount ( "/src" , resolver ) ,
168+ [ "/lib" ] : new vfs . Mount ( "/lib" , resolver )
169+ } ,
170+ cwd : "/" ,
171+ meta : { defaultLibLocation : "/lib" } ,
172+ time
173+ } ) ;
174+ return { fs, time, tick } ;
175+ }
176+
155177 export function verifyOutputsPresent ( fs : vfs . FileSystem , outputs : readonly string [ ] ) {
156178 for ( const output of outputs ) {
157179 assert ( fs . existsSync ( output ) , `Expect file ${ output } to exist` ) ;
@@ -257,22 +279,24 @@ interface Symbol {
257279 }
258280
259281 export interface VerifyTsBuildInput extends TscCompile {
260- tick : ( ) => void ;
261282 incrementalScenarios : TscIncremental [ ] ;
262283 }
263284
264285 export function verifyTscIncrementalEdits ( {
265- subScenario, fs, tick , scenario, commandLineArgs,
286+ subScenario, fs, scenario, commandLineArgs,
266287 baselineSourceMap, modifyFs, baselineReadFileCalls,
267288 incrementalScenarios
268289 } : VerifyTsBuildInput ) {
269290 describe ( `tsc --b ${ scenario } :: ${ subScenario } ` , ( ) => {
291+ let tick : ( ) => void ;
270292 let sys : TscCompileSystem ;
271293 before ( ( ) => {
294+ let baseFs : vfs . FileSystem ;
295+ ( { fs : baseFs , tick } = getFsWithTime ( fs ( ) ) ) ;
272296 sys = tscCompile ( {
273297 scenario,
274298 subScenario,
275- fs,
299+ fs : ( ) => baseFs . makeReadonly ( ) ,
276300 commandLineArgs,
277301 modifyFs : fs => {
278302 if ( modifyFs ) modifyFs ( fs ) ;
@@ -285,6 +309,7 @@ interface Symbol {
285309 } ) ;
286310 after ( ( ) => {
287311 sys = undefined ! ;
312+ tick = undefined ! ;
288313 } ) ;
289314 describe ( "initialBuild" , ( ) => {
290315 verifyTscBaseline ( ( ) => sys ) ;
0 commit comments