Skip to content

Commit 4ba7446

Browse files
committed
Emit the line, col information into the rwc runner error baselines
1 parent 2913725 commit 4ba7446

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/harness/harness.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,6 @@ module Harness {
571571
this.lastErrors = [];
572572
}
573573

574-
public emitAllDeclarations() {
575-
// NEWTODO: Do something here?
576-
}
577-
578574
public reportCompilationErrors() {
579575
return this.lastErrors;
580576
}
@@ -764,7 +760,8 @@ module Harness {
764760
}
765761

766762
export function getMinimalDiagnostic(err: ts.Diagnostic): MinimalDiagnostic {
767-
return { filename: err.file && err.file.filename, start: err.start, end: err.start + err.length, line: 0, character: 0, message: err.messageText };
763+
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
764+
return { filename: err.file && err.file.filename, start: err.start, end: err.start + err.length, line: errorLineInfo.line, character: errorLineInfo.character, message: err.messageText };
768765
}
769766

770767
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],

src/harness/rwcRunner.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ module RWC {
102102
getSourceFile: (fileName, languageVersion) => {
103103
var fileContents: string;
104104
try {
105-
fileContents = sys.readFile(fileName);
105+
if (libPath === fileName) {
106+
fileContents = Harness.IO.readFile(Harness.libFolder + "lib.d.ts");
107+
}
108+
else {
109+
fileContents = sys.readFile(fileName);
110+
}
106111
}
107112
catch (e) {
108113
// Leave fileContents undefined;
@@ -134,9 +139,14 @@ module RWC {
134139

135140
// Load the files
136141
inputList.forEach((item: string) => {
137-
var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(item));
142+
var resolvedPath = libPath === item ? item : Harness.Path.switchToForwardSlashes(sys.resolvePath(item));
138143
try {
139-
var content = sys.readFile(resolvedPath);
144+
if (libPath === item) {
145+
var content = Harness.IO.readFile(Harness.libFolder + "lib.d.ts");
146+
}
147+
else {
148+
var content = sys.readFile(resolvedPath);
149+
}
140150
}
141151
catch (e) {
142152
// Leave content undefined.
@@ -148,13 +158,16 @@ module RWC {
148158

149159
// Emit the results
150160
harnessCompiler.emitAll(emitterIOHost);
151-
harnessCompiler.emitAllDeclarations();
152-
153161
var compilationErrors = harnessCompiler.reportCompilationErrors();
154162

155163
// Create an error baseline
156164
compilationErrors.forEach(err => {
157-
errors += err.filename + ' line ' + err.line + ': ' + err.message + '\r\n';
165+
if (err.filename) {
166+
errors += err.filename + ' (' + err.line + "," + err.character + "): " + err.message + '\r\n';
167+
}
168+
else {
169+
errors += err.message + '\r\n';
170+
}
158171
});
159172
});
160173
});
@@ -165,13 +178,13 @@ module RWC {
165178

166179
it('has the expected emitted code', () => {
167180
Harness.Baseline.runBaseline('has the expected emitted code', baseName + '.output.js', () => {
168-
return collateOutputs(emitterIOHost, fn => fn.substr(fn.length - '.js'.length) === '.js', s => SyntacticCleaner.clean(s));
181+
return collateOutputs(emitterIOHost, fn => Harness.Compiler.isJS(fn), s => SyntacticCleaner.clean(s));
169182
}, false, baselineOpts);
170183
});
171184

172185
it('has the expected declaration file content', () => {
173186
Harness.Baseline.runBaseline('has the expected declaration file content', baseName + '.d.ts', () => {
174-
var result = collateOutputs(emitterIOHost, fn => fn.substr(fn.length - '.d.ts'.length) === '.d.ts');
187+
var result = collateOutputs(emitterIOHost, fn => Harness.Compiler.isDTS(fn));
175188
return result.length > 0 ? result : null;
176189
}, false, baselineOpts);
177190
});

0 commit comments

Comments
 (0)