Skip to content

Commit 8ccf0af

Browse files
committed
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.
1 parent 45684a8 commit 8ccf0af

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/harness/loggedIO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace Playback {
159159
}
160160

161161
const canonicalizeForHarness = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux
162-
function sanitizeTestFilePath(name: string) {
162+
export function sanitizeTestFilePath(name: string) {
163163
const path = ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", canonicalizeForHarness);
164164
if (ts.startsWith(path, "/")) {
165165
return path.substring(1);

src/harness/rwcRunner.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ namespace RWC {
7070
opts.options.noEmitOnError = false;
7171
});
7272

73+
let tsconfigFile: IOLogFile;
7374
runWithIOLog(ioLog, oldIO => {
7475
let fileNames = opts.fileNames;
7576

76-
const tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
77+
tsconfigFile = ts.forEach(ioLog.filesRead, f => isTsConfigFile(f) ? f : undefined);
7778
if (tsconfigFile) {
7879
const tsconfigFileContents = getHarnessCompilerInputUnit(tsconfigFile.path);
7980
tsconfigFiles.push({ unitName: tsconfigFile.path, content: tsconfigFileContents.content });
@@ -155,6 +156,11 @@ namespace RWC {
155156
compilerResult = output.result;
156157
});
157158

159+
if (!tsconfigFile) {
160+
const files = inputFiles.map(f => Playback.sanitizeTestFilePath(f.unitName));
161+
Harness.IO.writeFile(`internal/cases/rwc/${baseName}/read/tsconfig.json`, JSON.stringify({ compilerOptions, files }));
162+
}
163+
158164
function getHarnessCompilerInputUnit(fileName: string): Harness.Compiler.TestFile {
159165
const unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
160166
let content: string;

0 commit comments

Comments
 (0)