From c927b48dbff0b4b8b8be476140284fad4d69dfbe Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 25 May 2022 10:28:09 -0700 Subject: [PATCH] Improve diff of virtualFileSystemWithWatch.ts Undo mistaken move of changeToHostTrackingWrittenFiles and getTsBuildProjectFile, which might still not be enough. --- src/harness/virtualFileSystemWithWatch.ts | 42 +++++++++++------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index 7d7f405b9bd..dd83741e8f4 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -279,27 +279,6 @@ interface Array { length: number; [n: number]: T; }` } } - export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: ESMap; }; - - export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) { - const host = inputHost as TestServerHostTrackingWrittenFiles; - const originalWriteFile = host.writeFile; - host.writtenFiles = new Map(); - host.writeFile = (fileName, content) => { - originalWriteFile.call(host, fileName, content); - const path = host.toFullPath(fileName); - host.writtenFiles.set(path, (host.writtenFiles.get(path) || 0) + 1); - }; - return host; - } - - export function getTsBuildProjectFile(project: string, file: string): File { - return { - path: getTsBuildProjectFilePath(project, file), - content: Harness.IO.readFile(`${Harness.IO.getWorkspaceRoot()}/tests/projects/${project}/${file}`)! - }; - } - export const timeIncrements = 1000; export class TestServerHost extends VirtualServerBaseHost implements server.ServerHost { @@ -691,8 +670,29 @@ interface Array { length: number; [n: number]: T; }` if (baselinedOutput) baseline.push(baselinedOutput.join("")); } + export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: ESMap; }; + + export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) { + const host = inputHost as TestServerHostTrackingWrittenFiles; + const originalWriteFile = host.writeFile; + host.writtenFiles = new Map(); + host.writeFile = (fileName, content) => { + originalWriteFile.call(host, fileName, content); + const path = host.toFullPath(fileName); + host.writtenFiles.set(path, (host.writtenFiles.get(path) || 0) + 1); + }; + return host; + } + export const tsbuildProjectsLocation = "/user/username/projects"; export function getTsBuildProjectFilePath(project: string, file: string) { return `${tsbuildProjectsLocation}/${project}/${file}`; } + + export function getTsBuildProjectFile(project: string, file: string): File { + return { + path: getTsBuildProjectFilePath(project, file), + content: Harness.IO.readFile(`${Harness.IO.getWorkspaceRoot()}/tests/projects/${project}/${file}`)! + }; + } }