Merge pull request #668 from Microsoft/harnessMessageConsistency2

Changed Harness Output
This commit is contained in:
Daniel Rosenwasser
2014-09-12 14:41:46 -07:00
2239 changed files with 33106 additions and 14389 deletions

View File

@@ -156,10 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
}
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[],
otherFiles: { unitName: string; content: string }[],
result: Harness.Compiler.CompilerResult
) {
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[], otherFiles: { unitName: string; content: string }[], result: Harness.Compiler.CompilerResult) {
return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors);
}
@@ -168,7 +165,7 @@ class CompilerBaselineRunner extends RunnerBase {
if (this.errors) {
Harness.Baseline.runBaseline('Correct errors for ' + fileName, justName.replace(/\.ts$/, '.errors.txt'), (): string => {
if (result.errors.length === 0) return null;
return getErrorBaseline(toBeCompiled, otherFiles, result);
});
}

View File

@@ -807,9 +807,7 @@ module Harness {
return errorOutput;
}
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],
diagnostics: HarnessDiagnostic[]
) {
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
var outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
@@ -820,13 +818,13 @@ module Harness {
.split('\n')
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
.filter(s => s.length > 0)
.map(s => '!!! ' + s);
.map(s => '!!! ' + error.category + " TS" + error.code + ": " + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
}
// Report glovbal errors:
// Report global errors
var globalErrors = diagnostics.filter(err => !err.filename);
globalErrors.forEach(err => outputErrorText(err));
@@ -896,7 +894,8 @@ module Harness {
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
return outputLines.join('\r\n');
return minimalDiagnosticsToString(diagnostics) +
sys.newLine + sys.newLine + outputLines.join('\r\n');
}
/* TODO: Delete?
@@ -917,7 +916,7 @@ module Harness {
export function recreate(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) {
}
/** 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) */
/** 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) */
var harnessCompiler: HarnessCompiler;
/** Returns the singleton harness compiler instance for generating and running tests.

View File

@@ -4,7 +4,7 @@
// Test case is json of below type in tests/cases/project/
interface ProjectRunnerTestCase {
scenario: string;
projectRoot: string; // project where it lives - this also is the current dictory when compiling
projectRoot: string; // project where it lives - this also is the current directory when compiling
inputFiles: string[]; // list of input files to be given to program
out?: string; // --out
outDir?: string; // --outDir
@@ -22,7 +22,7 @@ interface ProjectRunnerTestCase {
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
// Apart from actual test case the results of the resolution
resolvedInputFiles: string[]; // List of files that were asked to read by compiler
emittedFiles: string[]; // List of files that wre emitted by the compiler
emittedFiles: string[]; // List of files that were emitted by the compiler
}
interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.GeneratedFile {
@@ -69,7 +69,7 @@ class ProjectRunner extends RunnerBase {
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
}
catch (e) {
assert(false, "Testcase: " + testCaseFileName + " doesnt not contain valid json format: " + e.message);
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
}
var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
@@ -87,7 +87,7 @@ class ProjectRunner extends RunnerBase {
}
// When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/
// We have these two separate locations because when compairing baselines the baseline verifier will delete the existing file
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
// so lets keep these two locations separate
function getProjectOutputFolder(filename: string, moduleKind: ts.ModuleKind) {
@@ -228,7 +228,7 @@ class ProjectRunner extends RunnerBase {
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), false);
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
// If the generated output file recides in the parent folder or is rooted path,
// If the generated output file resides in the parent folder or is rooted path,
// we need to instead create files that can live in the project reference folder
// but make sure extension of these files matches with the filename the compiler asked to write
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
@@ -299,13 +299,11 @@ class ProjectRunner extends RunnerBase {
return { unitName: sourceFile.filename, content: sourceFile.text };
});
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
var errors = Harness.Compiler.minimalDiagnosticsToString(diagnostics);
errors += sys.newLine + sys.newLine + Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
return errors;
return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
}
describe('Compiling project for ' + testCase.scenario +': testcase ' + testCaseFileName, () => {
describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => {
function verifyCompilerResults(compilerResult: BatchCompileProjectTestCaseResult) {
function getCompilerResolutionInfo() {
var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = {

View File

@@ -152,9 +152,7 @@ module RWC {
return null;
}
return Harness.Compiler.minimalDiagnosticsToString(compilerResult.errors) +
sys.newLine + sys.newLine +
Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
}, false, baselineOpts);
});