Add tsconfig.json for RWC projects that lack them.

This should make all RWC projects browseable with an editor on Windows
(except two, see below). On Linux it still works pretty well if you
are willing to lowercase the imports of the file you're interested in.

Many RWC projects already have tsconfig.json files, but this change
creates one for projects that don't -- *after* running their respective RWC
test. That's because all the information is most easily available at
that time, and you probably won't need it until then anyway.

Note that two RWC projects use relative paths in their list of stored files
and don't work with this simple scheme. I'll look at that next, but if I
can't figure it out in the next hour or two, I'd prefer to merge this
since it's immediately useful for all the other projects.
This commit is contained in:
Nathan Shively-Sanders
2017-10-26 15:05:56 -07:00
parent 45684a8175
commit 8ccf0af3ac
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -159,7 +159,7 @@ namespace Playback {
}
const canonicalizeForHarness = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux
function sanitizeTestFilePath(name: string) {
export function sanitizeTestFilePath(name: string) {
const path = ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", canonicalizeForHarness);
if (ts.startsWith(path, "/")) {
return path.substring(1);
+7 -1
View File
@@ -70,10 +70,11 @@ namespace RWC {
opts.options.noEmitOnError = false;
});
let tsconfigFile: IOLogFile;
runWithIOLog(ioLog, oldIO => {
let fileNames = opts.fileNames;
const tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
if (tsconfigFile) {
const tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
tsconfigFiles.push({ unitName: tsconfigFile.path, content: tsconfigFileContents.content });
@@ -155,6 +156,11 @@ namespace RWC {
compilerResult = output.result;
});
if (!tsconfigFile) {
const files = inputFiles.map(f => Playback.sanitizeTestFilePath(f.unitName));
Harness.IO.writeFile(`internal/cases/rwc/${baseName}/read/tsconfig.json`, JSON.stringify({ compilerOptions, files }));
}
function getHarnessCompilerInputUnit(fileName: string): Harness.Compiler.TestFile {
const unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
let content: string;