diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f65a4f88730..2493eec867b 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -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)); + } } } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 3d1833b061f..38c9cc7e795 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -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 => { (wrapper)[prop] = (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 = (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")); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index a1aaeed3d55..8bfb8400c59 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -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;