File |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Errors |
Total detected |
Total undetected |
Total mutants |
|
---|---|---|---|---|---|---|---|---|---|---|
CoverageInstrumenterStream.js |
|
15/23 | 15 | 8 | 0 | 0 | 0 | 15 | 8 | 23 |
"use strict";
var __extends = 0this && this.__extends && function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}(1this || this.__extendsthis && this.__extends) || function (d, b) 2{
}{
for (var p in b) if (3false4trueb.hasOwnProperty(p)) d[p] = b[p];
function __() 5{
}{ this.constructor = d; }
d.prototype = 6true7b !== null8falseb === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var stream_1 = require('stream');
var istanbul_1 = require('istanbul');
var log4js = require('log4js');
require('stryker-api/estree');
var coverageObjRegex = /\{.*"path".*"fnMap".*"statementMap".*"branchMap".*\}/g;
var log = log4js.getLogger('CoverageInstrumenterStream');
/**
* Represents a stream responsible to add code coverage instrumentation and reporting back on the statement map
*/
var CoverageInstrumenterStream = (function (_super) 9{
}{
__extends(CoverageInstrumenterStream, _super);
function CoverageInstrumenterStream(coverageVariable, filename, opts) 10{
}{
_super.call(this, opts);
this.coverageVariable = coverageVariable;
this.filename = filename;
this.opts = opts;
this.source = '';
}
CoverageInstrumenterStream.prototype._transform = function (chunk, encoding, callback) 11{
}{
if (12false13typeof chunk !== 'string'14truetypeof chunk === 'string') 15{
}{
this.source += chunk;
}
else 16{
}{
this.source += chunk.toString();
}
callback();
};
CoverageInstrumenterStream.prototype._flush = function (callback) 17{
}{
try 18{
}{
var instrumenter = new istanbul_1.Instrumenter({ coverageVariable: this.coverageVariable });
var instrumentedCode = instrumenter.instrumentSync(this.source, this.filename);
coverageObjRegex.lastIndex = 0;
var coverageObjectMatch = coverageObjRegex.exec(instrumentedCode).toString();
var coverageObj = JSON.parse(coverageObjectMatch);
this.statementMap = coverageObj.statementMap;
this.push(instrumentedCode);
}
catch (err) 19{
}{
var error = 20'Error while instrumenting file "' + this.filename + '", error was: ' - err.toString()21'Error while instrumenting file "' + this.filename - '", error was: '22'Error while instrumenting file "' - this.filename"Error while instrumenting file \"" + this.filename + "\", error was: " + err.toString();
log.error(error);
this.push(this.source);
}
callback();
};
return CoverageInstrumenterStream;
}(stream_1.Transform));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = CoverageInstrumenterStream;
//# sourceMappingURL=CoverageInstrumenterStream.js.map