mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Refactor for simpler tests
This commit is contained in:
1 parent
03fa5b3a98
commit
460f2a898c
6 files changed
+32
-79
No files matched your search
@@ -14,18 +14,6 @@ interface String { charAt: any; }
|
||||
interface Array<T> { length: number; [n: number]: T; }`
|
||||
};
|
||||
|
||||
export const safeList = {
|
||||
path: "/safeList.json" as Path,
|
||||
content: JSON.stringify({
|
||||
commander: "commander",
|
||||
express: "express",
|
||||
jquery: "jquery",
|
||||
lodash: "lodash",
|
||||
moment: "moment",
|
||||
chroma: "chroma-js"
|
||||
})
|
||||
};
|
||||
|
||||
function getExecutingFilePathFromLibFile(): string {
|
||||
return combinePaths(getDirectoryPath(libFile.path), "tsc.js");
|
||||
}
|
||||
@@ -43,11 +31,11 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
|
||||
export function createWatchedSystem(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
return new TestServerHost(/*withSafelist*/ false, fileOrFolderList, params);
|
||||
return new TestServerHost(fileOrFolderList, params);
|
||||
}
|
||||
|
||||
export function createServerHost(fileOrFolderList: readonly FileOrFolderOrSymLink[], params?: TestServerHostCreationParameters): TestServerHost {
|
||||
const host = new TestServerHost(/*withSafelist*/ true, fileOrFolderList, params);
|
||||
const host = new TestServerHost(fileOrFolderList, params);
|
||||
// Just like sys, patch the host to use writeFile
|
||||
patchWriteFileEnsuringDirectory(host);
|
||||
return host;
|
||||
@@ -338,7 +326,6 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
private readonly inodes?: ESMap<Path, number>;
|
||||
watchDirectory: HostWatchDirectory;
|
||||
constructor(
|
||||
public withSafeList: boolean,
|
||||
fileOrFolderorSymLinkList: readonly FileOrFolderOrSymLink[],
|
||||
{
|
||||
useCaseSensitiveFileNames, executingFilePath, currentDirectory,
|
||||
@@ -430,7 +417,6 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
|
||||
private reloadFS(fileOrFolderOrSymLinkList: readonly FileOrFolderOrSymLink[]) {
|
||||
Debug.assert(this.fs.size === 0);
|
||||
fileOrFolderOrSymLinkList = fileOrFolderOrSymLinkList.concat(this.withSafeList ? safeList : []);
|
||||
const filesOrFoldersToLoad: readonly FileOrFolderOrSymLink[] = !this.windowsStyleRoot ? fileOrFolderOrSymLinkList :
|
||||
fileOrFolderOrSymLinkList.map<FileOrFolderOrSymLink>(f => {
|
||||
const result = clone(f);
|
||||
@@ -438,39 +424,7 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
return result;
|
||||
});
|
||||
for (const fileOrDirectory of filesOrFoldersToLoad) {
|
||||
const path = this.toFullPath(fileOrDirectory.path);
|
||||
// If its a change
|
||||
const currentEntry = this.fs.get(path);
|
||||
if (currentEntry) {
|
||||
if (isFsFile(currentEntry)) {
|
||||
if (isFile(fileOrDirectory)) {
|
||||
// Update file
|
||||
if (currentEntry.content !== fileOrDirectory.content) {
|
||||
this.modifyFile(fileOrDirectory.path, fileOrDirectory.content);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// TODO: Changing from file => folder/Symlink
|
||||
}
|
||||
}
|
||||
else if (isFsSymLink(currentEntry)) {
|
||||
// TODO: update symlinks
|
||||
}
|
||||
else {
|
||||
// Folder
|
||||
if (isFile(fileOrDirectory)) {
|
||||
// TODO: Changing from folder => file
|
||||
}
|
||||
else {
|
||||
// Folder update: Nothing to do.
|
||||
currentEntry.modifiedTime = this.now();
|
||||
this.invokeFsWatches(currentEntry.fullPath, "change");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.ensureFileOrFolder(fileOrDirectory);
|
||||
}
|
||||
this.ensureFileOrFolder(fileOrDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@ namespace ts.tscWatch {
|
||||
commandLineArgs: ["-b", "-w", "-verbose"],
|
||||
sys: () => createWatchedSystem(
|
||||
[
|
||||
libFile,
|
||||
{ path: libFile.path, content: libContent },
|
||||
{ path: `${projectRoot}/a.js`, content: "" },
|
||||
{ path: `${projectRoot}/b.ts`, content: "" },
|
||||
{ path: `${projectRoot}/tsconfig.json`, content: JSON.stringify({ compilerOptions: { allowJs: true, noEmit: true } }) },
|
||||
{ path: libFile.path, content: libContent }
|
||||
],
|
||||
{ currentDirectory: projectRoot }
|
||||
),
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ts.tscWatch {
|
||||
scenario: "forceConsistentCasingInFileNames",
|
||||
subScenario,
|
||||
commandLineArgs: ["--w", "--p", tsconfig.path],
|
||||
sys: () => createWatchedSystem([loggerFile, anotherFile, tsconfig, libFile, tsconfig]),
|
||||
sys: () => createWatchedSystem([loggerFile, anotherFile, tsconfig, libFile]),
|
||||
changes
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace ts.projectSystem {
|
||||
installTypingHost: server.ServerHost,
|
||||
readonly typesRegistry = new Map<string, MapLike<string>>(),
|
||||
log?: TI.Log) {
|
||||
super(installTypingHost, globalTypingsCacheLocation, TestFSWithWatch.safeList.path, customTypesMap.path, throttleLimit, log);
|
||||
super(installTypingHost, globalTypingsCacheLocation, "/safeList.json" as Path, customTypesMap.path, throttleLimit, log);
|
||||
}
|
||||
|
||||
protected postExecActions: PostExecAction[] = [];
|
||||
|
||||
+13
-13
@@ -27,16 +27,16 @@ declare const console: { log(msg: any): void; };
|
||||
/a/lib/tsc.js -b -w -verbose --incremental
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:25 AM[0m] Starting compilation in watch mode...
|
||||
[[90m12:00:23 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
[[90m12:00:26 AM[0m] Projects in this build:
|
||||
[[90m12:00:24 AM[0m] Projects in this build:
|
||||
* tsconfig.json
|
||||
|
||||
[[90m12:00:27 AM[0m] Project 'tsconfig.json' is out of date because oldest output 'a.js' is older than newest input 'b.ts'
|
||||
[[90m12:00:25 AM[0m] Project 'tsconfig.json' is out of date because oldest output 'a.js' is older than newest input 'b.ts'
|
||||
|
||||
[[90m12:00:28 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:26 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:33 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:31 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
@@ -130,13 +130,13 @@ Input::
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:37 AM[0m] File change detected. Starting incremental compilation...
|
||||
[[90m12:00:35 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[[90m12:00:38 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
[[90m12:00:36 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
|
||||
[[90m12:00:39 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:37 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:40 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:38 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
@@ -178,13 +178,13 @@ const x = 10;
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:44 AM[0m] File change detected. Starting incremental compilation...
|
||||
[[90m12:00:42 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[[90m12:00:45 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
[[90m12:00:43 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
|
||||
[[90m12:00:46 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:44 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:53 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:51 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -27,16 +27,16 @@ declare const console: { log(msg: any): void; };
|
||||
/a/lib/tsc.js -b -w -verbose
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:25 AM[0m] Starting compilation in watch mode...
|
||||
[[90m12:00:23 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
[[90m12:00:26 AM[0m] Projects in this build:
|
||||
[[90m12:00:24 AM[0m] Projects in this build:
|
||||
* tsconfig.json
|
||||
|
||||
[[90m12:00:27 AM[0m] Project 'tsconfig.json' is out of date because oldest output 'a.js' is older than newest input 'b.ts'
|
||||
[[90m12:00:25 AM[0m] Project 'tsconfig.json' is out of date because oldest output 'a.js' is older than newest input 'b.ts'
|
||||
|
||||
[[90m12:00:28 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:26 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:29 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:27 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
@@ -82,13 +82,13 @@ Input::
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:33 AM[0m] File change detected. Starting incremental compilation...
|
||||
[[90m12:00:31 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[[90m12:00:34 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
[[90m12:00:32 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
|
||||
[[90m12:00:35 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:33 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:36 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:34 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
@@ -130,13 +130,13 @@ const x = 10;
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:40 AM[0m] File change detected. Starting incremental compilation...
|
||||
[[90m12:00:38 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[[90m12:00:41 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
[[90m12:00:39 AM[0m] Project 'tsconfig.json' is out of date because output file 'b.js' does not exist
|
||||
|
||||
[[90m12:00:42 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
[[90m12:00:40 AM[0m] Building project '/user/username/projects/myproject/tsconfig.json'...
|
||||
|
||||
[[90m12:00:43 AM[0m] Found 0 errors. Watching for file changes.
|
||||
[[90m12:00:41 AM[0m] Found 0 errors. Watching for file changes.
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user