mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
add support for tsconfig files in the rwc instrumenter/replay
This commit is contained in:
parent
36acaff6dc
commit
0d126e2ad7
@ -428,6 +428,7 @@ module Harness {
|
||||
args(): string[];
|
||||
getExecutingFilePath(): string;
|
||||
exit(exitCode?: number): void;
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
}
|
||||
export var IO: IO;
|
||||
|
||||
@ -464,6 +465,7 @@ module Harness {
|
||||
export const directoryExists: typeof IO.directoryExists = fso.FolderExists;
|
||||
export const fileExists: typeof IO.fileExists = fso.FileExists;
|
||||
export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
|
||||
export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (directoryExists(path)) {
|
||||
@ -532,6 +534,8 @@ module Harness {
|
||||
export const fileExists: typeof IO.fileExists = fs.existsSync;
|
||||
export const log: typeof IO.log = s => console.log(s);
|
||||
|
||||
export const readDirectory: typeof IO.readDirectory = (path, extension, exclude) => ts.sys.readDirectory(path, extension, exclude);
|
||||
|
||||
export function createDirectory(path: string) {
|
||||
if (!directoryExists(path)) {
|
||||
fs.mkdirSync(path);
|
||||
@ -730,6 +734,10 @@ module Harness {
|
||||
export function writeFile(path: string, contents: string) {
|
||||
Http.writeToServerSync(serverRoot + path, "WRITE", contents);
|
||||
}
|
||||
|
||||
export function readDirectory(path: string, extension?: string, exclude?: string[]) {
|
||||
return listFiles(path).filter(f => !extension || ts.fileExtensionIs(f, extension));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +59,12 @@ interface IOLog {
|
||||
path: string;
|
||||
result?: string;
|
||||
}[];
|
||||
directoriesRead: {
|
||||
path: string,
|
||||
extension: string,
|
||||
exclude: string[],
|
||||
result: string[]
|
||||
}[];
|
||||
}
|
||||
|
||||
interface PlaybackControl {
|
||||
@ -103,6 +109,7 @@ module Playback {
|
||||
arguments: [],
|
||||
currentDirectory: "",
|
||||
filesRead: [],
|
||||
directoriesRead: [],
|
||||
filesWritten: [],
|
||||
filesDeleted: [],
|
||||
filesAppended: [],
|
||||
@ -118,7 +125,7 @@ module Playback {
|
||||
|
||||
function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void;
|
||||
function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void;
|
||||
function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void {
|
||||
function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void {
|
||||
ts.forEach(Object.keys(underlying), prop => {
|
||||
(<any>wrapper)[prop] = (<any>underlying)[prop];
|
||||
});
|
||||
@ -203,6 +210,15 @@ module Playback {
|
||||
},
|
||||
memoize((path) => findResultByPath(wrapper, replayLog.filesRead, path).contents));
|
||||
|
||||
wrapper.readDirectory = recordReplay(wrapper.readDirectory, underlying)(
|
||||
(path, extension, exclude) => {
|
||||
let result = (<ts.System>underlying).readDirectory(path, extension, exclude);
|
||||
let logEntry = { path, extension, exclude, result };
|
||||
recordLog.directoriesRead.push(logEntry);
|
||||
return result;
|
||||
},
|
||||
(path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path));
|
||||
|
||||
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
|
||||
(path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path: path, contents: contents, bom: false }),
|
||||
(path, contents) => noOpReplay("writeFile"));
|
||||
|
||||
@ -19,6 +19,11 @@ module RWC {
|
||||
}
|
||||
}
|
||||
|
||||
function isTsConfigFile(file: { path: string }): boolean {
|
||||
const tsConfigFileName = "tsconfig.json";
|
||||
return file.path.substr(file.path.length - tsConfigFileName.length).toLowerCase() === tsConfigFileName;
|
||||
}
|
||||
|
||||
export function runRWCTest(jsonPath: string) {
|
||||
describe("Testing a RWC project: " + jsonPath, () => {
|
||||
let inputFiles: { unitName: string; content: string; }[] = [];
|
||||
@ -67,8 +72,17 @@ module RWC {
|
||||
runWithIOLog(ioLog, oldIO => {
|
||||
harnessCompiler.reset();
|
||||
|
||||
let fileNames = opts.fileNames;
|
||||
|
||||
let tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
|
||||
if (tsconfigFile) {
|
||||
let tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
|
||||
let configParseResult = ts.parseConfigFile(tsconfigFileContents.content, Harness.IO, ts.getDirectoryPath(tsconfigFile.path));
|
||||
fileNames = configParseResult.fileNames;
|
||||
}
|
||||
|
||||
// Load the files
|
||||
ts.forEach(opts.fileNames, fileName => {
|
||||
ts.forEach(fileNames, fileName => {
|
||||
inputFiles.push(getHarnessCompilerInputUnit(fileName));
|
||||
});
|
||||
|
||||
@ -79,6 +93,10 @@ module RWC {
|
||||
const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path));
|
||||
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
|
||||
|
||||
if (isTsConfigFile(fileRead)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Harness.isLibraryFile(fileRead.path)) {
|
||||
if (inInputList) {
|
||||
continue;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user