Skip to content

Commit 325cdef

Browse files
Merge pull request #668 from Microsoft/harnessMessageConsistency2
Changed Harness Output
2 parents c277db0 + 9f7782d commit 325cdef

File tree

2,239 files changed

+33106
-14389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,239 files changed

+33106
-14389
lines changed

src/harness/compilerRunner.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {
156156
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
157157
}
158158

159-
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[],
160-
otherFiles: { unitName: string; content: string }[],
161-
result: Harness.Compiler.CompilerResult
162-
) {
159+
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[], otherFiles: { unitName: string; content: string }[], result: Harness.Compiler.CompilerResult) {
163160
return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors);
164161
}
165162

@@ -168,7 +165,7 @@ class CompilerBaselineRunner extends RunnerBase {
168165
if (this.errors) {
169166
Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => {
170167
if (result.errors.length === 0) return null;
171-
168+
172169
return getErrorBaseline(toBeCompiled, otherFiles, result);
173170
});
174171
}

src/harness/harness.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,7 @@ module Harness {
807807
return errorOutput;
808808
}
809809

810-
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],
811-
diagnostics: HarnessDiagnostic[]
812-
) {
810+
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
813811

814812
var outputLines: string[] = [];
815813
// Count up all the errors we find so we don't miss any
@@ -820,13 +818,13 @@ module Harness {
820818
.split('\n')
821819
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
822820
.filter(s => s.length > 0)
823-
.map(s => '!!! ' + s);
821+
.map(s => '!!! ' + error.category + " TS" + error.code + ": " + s);
824822
errLines.forEach(e => outputLines.push(e));
825823

826824
totalErrorsReported++;
827825
}
828826

829-
// Report glovbal errors:
827+
// Report global errors
830828
var globalErrors = diagnostics.filter(err => !err.filename);
831829
globalErrors.forEach(err => outputErrorText(err));
832830

@@ -896,7 +894,8 @@ module Harness {
896894
// Verify we didn't miss any errors in total
897895
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
898896

899-
return outputLines.join('\r\n');
897+
return minimalDiagnosticsToString(diagnostics) +
898+
sys.newLine + sys.newLine + outputLines.join('\r\n');
900899
}
901900

902901
/* TODO: Delete?
@@ -917,7 +916,7 @@ module Harness {
917916
export function recreate(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) {
918917
}
919918

920-
/** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a testcase (i.e., describe/it) */
919+
/** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */
921920
var harnessCompiler: HarnessCompiler;
922921

923922
/** Returns the singleton harness compiler instance for generating and running tests.

src/harness/projectsRunner.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Test case is json of below type in tests/cases/project/
55
interface ProjectRunnerTestCase {
66
scenario: string;
7-
projectRoot: string; // project where it lives - this also is the current dictory when compiling
7+
projectRoot: string; // project where it lives - this also is the current directory when compiling
88
inputFiles: string[]; // list of input files to be given to program
99
out?: string; // --out
1010
outDir?: string; // --outDir
@@ -22,7 +22,7 @@ interface ProjectRunnerTestCase {
2222
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
2323
// Apart from actual test case the results of the resolution
2424
resolvedInputFiles: string[]; // List of files that were asked to read by compiler
25-
emittedFiles: string[]; // List of files that wre emitted by the compiler
25+
emittedFiles: string[]; // List of files that were emitted by the compiler
2626
}
2727

2828
interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.GeneratedFile {
@@ -69,7 +69,7 @@ class ProjectRunner extends RunnerBase {
6969
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
7070
}
7171
catch (e) {
72-
assert(false, "Testcase: " + testCaseFileName + " doesnt not contain valid json format: " + e.message);
72+
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
7373
}
7474
var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
7575

@@ -87,7 +87,7 @@ class ProjectRunner extends RunnerBase {
8787
}
8888

8989
// When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/
90-
// We have these two separate locations because when compairing baselines the baseline verifier will delete the existing file
90+
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
9191
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
9292
// so lets keep these two locations separate
9393
function getProjectOutputFolder(filename: string, moduleKind: ts.ModuleKind) {
@@ -228,7 +228,7 @@ class ProjectRunner extends RunnerBase {
228228

229229
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), false);
230230
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
231-
// If the generated output file recides in the parent folder or is rooted path,
231+
// If the generated output file resides in the parent folder or is rooted path,
232232
// we need to instead create files that can live in the project reference folder
233233
// but make sure extension of these files matches with the filename the compiler asked to write
234234
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
@@ -299,13 +299,11 @@ class ProjectRunner extends RunnerBase {
299299
return { unitName: sourceFile.filename, content: sourceFile.text };
300300
});
301301
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
302-
var errors = Harness.Compiler.minimalDiagnosticsToString(diagnostics);
303-
errors += sys.newLine + sys.newLine + Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
304302

305-
return errors;
303+
return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
306304
}
307305

308-
describe('Compiling project for ' + testCase.scenario +': testcase ' + testCaseFileName, () => {
306+
describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => {
309307
function verifyCompilerResults(compilerResult: BatchCompileProjectTestCaseResult) {
310308
function getCompilerResolutionInfo() {
311309
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {

src/harness/rwcRunner.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ module RWC {
152152
return null;
153153
}
154154

155-
return Harness.Compiler.minimalDiagnosticsToString(compilerResult.errors) +
156-
sys.newLine + sys.newLine +
157-
Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
155+
return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
158156
}, false, baselineOpts);
159157
});
160158

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts(1,13): error TS1110: Type expected.
2+
3+
14
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts (1 errors) ====
25
var v = (a: ) => {
36
~
4-
!!! Type expected.
7+
!!! error TS1110: Type expected.
58

69
};
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed.
2+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'.
3+
4+
15
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts (2 errors) ====
26
var v = (a: b,) => {
37
~
4-
!!! Trailing comma not allowed.
8+
!!! error TS1009: Trailing comma not allowed.
59
~
6-
!!! Cannot find name 'b'.
10+
!!! error TS2304: Cannot find name 'b'.
711

812
};
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,12): error TS1005: ',' expected.
2+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1005: ';' expected.
3+
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,10): error TS2304: Cannot find name 'a'.
4+
5+
16
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (3 errors) ====
27
var v = (a): => {
38
~
4-
!!! ',' expected.
9+
!!! error TS1005: ',' expected.
510
~~
6-
!!! ';' expected.
11+
!!! error TS1005: ';' expected.
712
~
8-
!!! Cannot find name 'a'.
13+
!!! error TS2304: Cannot find name 'a'.
914

1015
};
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
tests/cases/compiler/ArrowFunctionExpression1.ts(1,10): error TS2369: A parameter property is only allowed in a constructor implementation.
2+
3+
14
==== tests/cases/compiler/ArrowFunctionExpression1.ts (1 errors) ====
25
var v = (public x: string) => { };
36
~~~~~~~~~~~~~~~~
4-
!!! A parameter property is only allowed in a constructor implementation.
7+
!!! error TS2369: A parameter property is only allowed in a constructor implementation.

tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.errors.txt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(10,19): error TS2304: Cannot find name 'T'.
2+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(20,12): error TS2304: Cannot find name 'T'.
3+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(22,23): error TS2304: Cannot find name 'T'.
4+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(35,26): error TS2304: Cannot find name 'T'.
5+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(46,15): error TS2304: Cannot find name 'T'.
6+
7+
18
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts (5 errors) ====
29
// all expected to be errors
310

@@ -10,7 +17,7 @@
1017
module clodule1 {
1118
function f(x: T) { }
1219
~
13-
!!! Cannot find name 'T'.
20+
!!! error TS2304: Cannot find name 'T'.
1421
}
1522

1623
class clodule2<T>{
@@ -22,11 +29,11 @@
2229
module clodule2 {
2330
var x: T;
2431
~
25-
!!! Cannot find name 'T'.
32+
!!! error TS2304: Cannot find name 'T'.
2633

2734
class D<U extends T>{
2835
~
29-
!!! Cannot find name 'T'.
36+
!!! error TS2304: Cannot find name 'T'.
3037
id: string;
3138
value: U;
3239
}
@@ -41,7 +48,7 @@
4148
module clodule3 {
4249
export var y = { id: T };
4350
~
44-
!!! Cannot find name 'T'.
51+
!!! error TS2304: Cannot find name 'T'.
4552
}
4653

4754
class clodule4<T>{
@@ -54,7 +61,7 @@
5461
class D {
5562
name: T;
5663
~
57-
!!! Cannot find name 'T'.
64+
!!! error TS2304: Cannot find name 'T'.
5865
}
5966
}
6067

tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts(10,21): error TS2300: Duplicate identifier 'fn'.
2+
3+
14
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
25
class clodule<T> {
36
id: string;
@@ -10,7 +13,7 @@
1013
// error: duplicate identifier expected
1114
export function fn<T>(x: T, y: T): T {
1215
~~
13-
!!! Duplicate identifier 'fn'.
16+
!!! error TS2300: Duplicate identifier 'fn'.
1417
return x;
1518
}
1619
}

0 commit comments

Comments
 (0)