Skip to content

Commit

Permalink
Added test for noEmitOnError
Browse files Browse the repository at this point in the history
  • Loading branch information
DickvdBrink committed Oct 29, 2014
1 parent e4f5756 commit 4c1397b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/harness/compilerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ class CompilerBaselineRunner extends RunnerBase {
it('Correct sourcemap content for ' + fileName, () => {
if (options.sourceMap) {
Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.ts$/, '.sourcemap.txt'), () => {
return result.getSourceMapRecord();
var record = result.getSourceMapRecord();
if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) {
// Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required.
return null;
}
return record;
});
}
});
Expand Down Expand Up @@ -246,6 +251,12 @@ class CompilerBaselineRunner extends RunnerBase {
}

Harness.Baseline.runBaseline('Correct Sourcemap output for ' + fileName, justName.replace(/\.ts/, '.js.map'), () => {
if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) {
// We need to return null here or the runBaseLine will actually create a empty file.
// Baselining isn't required here because there is no output.
return null;
}

var sourceMapCode = '';
for (var i = 0; i < result.sourceMaps.length; i++) {
sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n';
Expand Down
6 changes: 5 additions & 1 deletion src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ module Harness {
}
break;

case 'noemitonerror':
options.noEmitOnError = !!setting.value;
break;

case 'noresolve':
options.noResolve = !!setting.value;
break;
Expand Down Expand Up @@ -1145,7 +1149,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines

// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];

function extractCompilerSettings(content: string): CompilerSetting[] {

Expand Down
9 changes: 9 additions & 0 deletions tests/baselines/reference/noEmitOnError.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tests/cases/compiler/noEmitOnError.ts(2,5): error TS2323: Type 'string' is not assignable to type 'number'.


==== tests/cases/compiler/noEmitOnError.ts (1 errors) ====

var x: number = "";
~
!!! error TS2323: Type 'string' is not assignable to type 'number'.

5 changes: 5 additions & 0 deletions tests/cases/compiler/noEmitOnError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @noemitonerror: true
// @sourcemap: true
// @declaration: true

var x: number = "";

0 comments on commit 4c1397b

Please sign in to comment.