Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/compiler/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ module ts {
}

function reportDiagnostic(diagnostic: Diagnostic) {
var output = "";

if (diagnostic.file) {
var loc = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
sys.write(diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): " + diagnostic.messageText + sys.newLine);
}
else {
sys.write(diagnostic.messageText + sys.newLine);

output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): ";
}

var category = DiagnosticCategory[diagnostic.category].toLowerCase();
output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 'category' need to be localized?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


sys.write(output);
}

function reportDiagnostics(diagnostics: Diagnostic[]) {
Expand Down
44 changes: 27 additions & 17 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ module Harness {
private compileOptions: ts.CompilerOptions;
private settings: Harness.TestCaseParser.CompilerSetting[] = [];

private lastErrors: MinimalDiagnostic[];
private lastErrors: HarnessDiagnostic[];

public reset() {
this.inputFiles = [];
Expand Down Expand Up @@ -750,7 +750,7 @@ module Harness {
emitResult = checker.emitFiles();
}

var errors: MinimalDiagnostic[] = [];
var errors: HarnessDiagnostic[] = [];
program.getDiagnostics().concat(checker.getDiagnostics()).concat(emitResult ? emitResult.errors : []).forEach(err => {
// TODO: new compiler formats errors after this point to add . and newlines so we'll just do it manually for now
errors.push(getMinimalDiagnostic(err));
Expand All @@ -768,35 +768,43 @@ module Harness {
}
}

export function getMinimalDiagnostic(err: ts.Diagnostic): MinimalDiagnostic {
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
return { filename: err.file && err.file.filename, start: err.start, end: err.start + err.length, line: errorLineInfo.line, character: errorLineInfo.character, message: err.messageText };
return {
filename: err.file && err.file.filename,
start: err.start,
end: err.start + err.length,
line: errorLineInfo.line,
character: errorLineInfo.character,
message: err.messageText,
category: ts.DiagnosticCategory[err.category].toLowerCase(),
code: err.code
};
}

export function minimalDiagnosticsToString(diagnostics: MinimalDiagnostic[]) {
// This is copied from tsc.ts's reportError to replicate what tsc does
var errors = "";
export function minimalDiagnosticsToString(diagnostics: HarnessDiagnostic[]) {
// This is basically copied from tsc.ts's reportError to replicate what tsc does
var errorOutput = "";
ts.forEach(diagnostics, diagnotic => {
if (diagnotic.filename) {
errors += diagnotic.filename + "(" + diagnotic.line + "," + diagnotic.character + "): " + diagnotic.message + sys.newLine;
}
else {
errors += diagnotic.message + sys.newLine;
errorOutput += diagnotic.filename + "(" + diagnotic.line + "," + diagnotic.character + "): ";
}

errorOutput += diagnotic.category + " TS" + diagnotic.code + ": " + diagnotic.message + sys.newLine;
});

return errors;
return errorOutput;
}

export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],
diagnostics: MinimalDiagnostic[]
diagnostics: HarnessDiagnostic[]
) {

var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
var totalErrorsReported = 0;

function outputErrorText(error: Harness.Compiler.MinimalDiagnostic) {
function outputErrorText(error: Harness.Compiler.HarnessDiagnostic) {
var errLines = RunnerBase.removeFullPaths(error.message)
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
Expand Down Expand Up @@ -916,13 +924,15 @@ module Harness {
//harnessCompiler.compileString(code, unitName, callback);
}

export interface MinimalDiagnostic {
export interface HarnessDiagnostic {
filename: string;
start: number;
end: number;
line: number;
character: number;
message: string;
category: string;
code: number;
}

export interface GeneratedFile {
Expand Down Expand Up @@ -950,13 +960,13 @@ module Harness {
/** Contains the code and errors of a compilation and some helper methods to check its status. */
export class CompilerResult {
public files: GeneratedFile[] = [];
public errors: MinimalDiagnostic[] = [];
public errors: HarnessDiagnostic[] = [];
public declFilesCode: GeneratedFile[] = [];
public sourceMaps: GeneratedFile[] = [];
public sourceMapRecord: string;

/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
constructor(fileResults: GeneratedFile[], errors: MinimalDiagnostic[], sourceMapRecordLines: string[]) {
constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], sourceMapRecordLines: string[]) {
var lines: string[] = [];

fileResults.forEach(emittedFile => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
decl.ts(1,26): Cannot find external module './foo/bar.js'.
decl.ts(2,26): Cannot find external module 'baz'.
decl.ts(3,26): Cannot find external module './baz'.
decl.ts(1,26): error TS2307: Cannot find external module './foo/bar.js'.
decl.ts(2,26): error TS2307: Cannot find external module 'baz'.
decl.ts(3,26): error TS2307: Cannot find external module './baz'.


==== decl.ts (3 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
decl.ts(1,26): Cannot find external module './foo/bar.js'.
decl.ts(2,26): Cannot find external module 'baz'.
decl.ts(3,26): Cannot find external module './baz'.
decl.ts(1,26): error TS2307: Cannot find external module './foo/bar.js'.
decl.ts(2,26): error TS2307: Cannot find external module 'baz'.
decl.ts(3,26): error TS2307: Cannot find external module './baz'.


==== decl.ts (3 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
in2.d.ts(1,8): Duplicate identifier 'a'.
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.


==== decl.d.ts (0 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
in2.d.ts(1,8): Duplicate identifier 'a'.
in2.d.ts(1,8): error TS2300: Duplicate identifier 'a'.


==== decl.d.ts (0 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
internal2.ts(2,2): Import declarations in an internal module cannot reference an external module.
internal2.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== internal2.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
internal2.ts(2,2): Import declarations in an internal module cannot reference an external module.
internal2.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== internal2.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Option mapRoot cannot be specified without specifying sourcemap option.
Option sourceRoot cannot be specified without specifying sourcemap option.
error TS5038: Option mapRoot cannot be specified without specifying sourcemap option.
error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option.


!!! Option mapRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Option mapRoot cannot be specified without specifying sourcemap option.
Option sourceRoot cannot be specified without specifying sourcemap option.
error TS5038: Option mapRoot cannot be specified without specifying sourcemap option.
error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option.


!!! Option mapRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Option mapRoot cannot be specified without specifying sourcemap option.
error TS5038: Option mapRoot cannot be specified without specifying sourcemap option.


!!! Option mapRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Option mapRoot cannot be specified without specifying sourcemap option.
error TS5038: Option mapRoot cannot be specified without specifying sourcemap option.


!!! Option mapRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test1.ts(2,2): Import declarations in an internal module cannot reference an external module.
test1.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test1.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test1.ts(2,2): Import declarations in an internal module cannot reference an external module.
test1.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test1.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test1.ts(3,2): Import declarations in an internal module cannot reference an external module.
test1.ts(3,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test1.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test1.ts(3,2): Import declarations in an internal module cannot reference an external module.
test1.ts(3,2): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test1.ts (1 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Cannot find global type 'Array'.
Cannot find global type 'Boolean'.
Cannot find global type 'Function'.
Cannot find global type 'IArguments'.
Cannot find global type 'Number'.
Cannot find global type 'Object'.
Cannot find global type 'RegExp'.
Cannot find global type 'String'.
test.ts(3,8): Cannot find name 'Array'.
error TS2318: Cannot find global type 'Array'.
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'IArguments'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
error TS2318: Cannot find global type 'String'.
test.ts(3,8): error TS2304: Cannot find name 'Array'.


!!! Cannot find global type 'Array'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Cannot find global type 'Array'.
Cannot find global type 'Boolean'.
Cannot find global type 'Function'.
Cannot find global type 'IArguments'.
Cannot find global type 'Number'.
Cannot find global type 'Object'.
Cannot find global type 'RegExp'.
Cannot find global type 'String'.
test.ts(3,8): Cannot find name 'Array'.
error TS2318: Cannot find global type 'Array'.
error TS2318: Cannot find global type 'Boolean'.
error TS2318: Cannot find global type 'Function'.
error TS2318: Cannot find global type 'IArguments'.
error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
error TS2318: Cannot find global type 'String'.
test.ts(3,8): error TS2304: Cannot find name 'Array'.


!!! Cannot find global type 'Array'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
testGlo.ts(2,5): Import declarations in an internal module cannot reference an external module.
testGlo.ts(21,5): Import declarations in an internal module cannot reference an external module.
testGlo.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
testGlo.ts(21,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== testGlo.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
testGlo.ts(2,5): Import declarations in an internal module cannot reference an external module.
testGlo.ts(21,5): Import declarations in an internal module cannot reference an external module.
testGlo.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
testGlo.ts(21,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== testGlo.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test.ts(5,5): Import declarations in an internal module cannot reference an external module.
test.ts(24,5): Import declarations in an internal module cannot reference an external module.
test.ts(5,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(24,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test.ts(5,5): Import declarations in an internal module cannot reference an external module.
test.ts(24,5): Import declarations in an internal module cannot reference an external module.
test.ts(5,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(24,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test.ts(2,5): Import declarations in an internal module cannot reference an external module.
test.ts(42,5): Import declarations in an internal module cannot reference an external module.
test.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(42,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test.ts(2,5): Import declarations in an internal module cannot reference an external module.
test.ts(42,5): Import declarations in an internal module cannot reference an external module.
test.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(42,5): error TS1147: Import declarations in an internal module cannot reference an external module.


==== test.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
m'ain.d.ts(1,1): File 'li.ts' not found.
m'ain.d.ts(1,1): error TS6053: File 'li.ts' not found.


==== li'b/class'A.d.ts (0 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
m'ain.d.ts(1,1): File 'li.ts' not found.
m'ain.d.ts(1,1): error TS6053: File 'li.ts' not found.


==== li'b/class'A.d.ts (0 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Option sourceRoot cannot be specified without specifying sourcemap option.
error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option.


!!! Option sourceRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Option sourceRoot cannot be specified without specifying sourcemap option.
error TS5039: Option sourceRoot cannot be specified without specifying sourcemap option.


!!! Option sourceRoot cannot be specified without specifying sourcemap option.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main.ts(2,1): File 'nonExistingFile1.ts' not found.
main.ts(3,1): File 'nonExistingFile2.ts' not found.
main.ts(2,1): error TS6053: File 'nonExistingFile1.ts' not found.
main.ts(3,1): error TS6053: File 'nonExistingFile2.ts' not found.


==== main.ts (2 errors) ====
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
main.ts(2,1): File 'nonExistingFile1.ts' not found.
main.ts(3,1): File 'nonExistingFile2.ts' not found.
main.ts(2,1): error TS6053: File 'nonExistingFile1.ts' not found.
main.ts(3,1): error TS6053: File 'nonExistingFile2.ts' not found.


==== main.ts (2 errors) ====
Expand Down