definition-tester
Version:
DefinitelyTyped repository testing infrastructure
57 lines • 2.35 kB
JavaScript
;
var __extends = (this && 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 __());
};
var path = require('path');
var mc = require('manticore');
var Promise = require('bluebird');
var util = require('../util/util');
var TestResult_1 = require('../test/TestResult');
var TestSuiteBase_1 = require('../suite/TestSuiteBase');
var TSLintSuite = (function (_super) {
__extends(TSLintSuite, _super);
function TSLintSuite(options) {
_super.call(this, options, 'Linting', 'Found some lint');
}
TSLintSuite.prototype.start = function (targetFiles, testCallback) {
var _this = this;
this.pool = mc.createPool({
worker: require.resolve('./TSLintWorker'),
concurrent: this.options.concurrent,
paralel: 2,
attempts: 3
});
return util.readJSON(this.options.tslintConfig).then(function (config) {
_this.tslint = {
configuration: config,
formatter: path.resolve(_this.options.testerPath, 'src', 'lint', 'TSLintFormatter')
};
return _super.prototype.start.call(_this, targetFiles, testCallback);
});
};
TSLintSuite.prototype.runTest = function (targetFile) {
var _this = this;
return this.pool.run('lint', {
filePath: targetFile.fullPath,
options: this.tslint
}).then(function (res) {
var testResult = new TestResult_1.default();
testResult.hostedBy = _this;
testResult.targetFile = targetFile;
if (!res) {
testResult.diagnostics = [("bad result for " + targetFile.fullPath)];
}
else if (res.failureCount > 0 && res.output) {
testResult.diagnostics = [res.output];
}
_this.testResults.push(testResult);
return Promise.resolve(testResult);
});
};
return TSLintSuite;
}(TestSuiteBase_1.default));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = TSLintSuite;
//# sourceMappingURL=TSLintSuite.js.map