From d09e5508e2a1ea9af7eef534bf98a137430610cf Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 17 Jul 2014 18:14:13 -0700 Subject: [PATCH] Report global errors and re-enable assert for the number of errors reported --- src/harness/compilerRunner.ts | 28 ++++++++++++------- .../reference/parser509698.errors.txt | 8 ++++++ .../typeCheckTypeArgument.errors.txt | 8 ++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 3f3c1d5f0d5..4834fc817d0 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -118,9 +118,25 @@ class CompilerBaselineRunner extends RunnerBase { otherFiles: { unitName: string; content: string }[], result: Harness.Compiler.CompilerResult ) { + 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) { + 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) + .filter(s => s.length > 0) + .map(s => '!!! ' + s); + errLines.forEach(e => outputLines.push(e)); + + totalErrorsReported++; + } + + // Report glovbal errors: + var globalErrors = result.errors.filter(err => !err.filename); + globalErrors.forEach(err => outputErrorText(err)); // 'merge' the lines of each input file with any errors associated with it toBeCompiled.concat(otherFiles).forEach(inputFile => { @@ -130,8 +146,6 @@ class CompilerBaselineRunner extends RunnerBase { return errFn && errFn === inputFile.unitName; }); - // Add this to the number of errors we've seen so far - totalErrorsReported += fileErrors.length; // Header outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ===='); @@ -176,12 +190,7 @@ class CompilerBaselineRunner extends RunnerBase { // Just like above, we need to do a split on a string instead of on a regex // because the JS engine does regexes wrong - var errLines = RunnerBase.removeFullPaths(err.message) - .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); - errLines.forEach(e => outputLines.push(e)); + outputErrorText(err); markedErrorCount++; } } @@ -193,8 +202,7 @@ class CompilerBaselineRunner extends RunnerBase { }); // Verify we didn't miss any errors in total - // NEWTODO: Re-enable this -- somehow got broken - // assert.equal(totalErrorsReported, result.errors.length, 'total number of errors'); + assert.equal(totalErrorsReported, result.errors.length, 'total number of errors'); return outputLines.join('\r\n'); } diff --git a/tests/baselines/reference/parser509698.errors.txt b/tests/baselines/reference/parser509698.errors.txt index ded1a87c9f3..8a8b23d44e4 100644 --- a/tests/baselines/reference/parser509698.errors.txt +++ b/tests/baselines/reference/parser509698.errors.txt @@ -1,3 +1,11 @@ +!!! 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'. ==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ==== ///