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 28, 2014
1 parent e4f5756 commit e9df900
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/harness/compilerRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ 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) {
return null;
}
return record;
});
}
});
Expand Down Expand Up @@ -246,6 +250,10 @@ 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) {
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 e9df900

Please sign in to comment.