File |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Errors |
Total detected |
Total undetected |
Total mutants |
|
---|---|---|---|---|---|---|---|---|---|---|
InputFileResolver.js |
|
67/68 | 67 | 1 | 0 | 0 | 0 | 67 | 1 | 68 |
"use strict";
var fileUtils_1 = require('./utils/fileUtils');
var _ = require('lodash');
var log4js = require('log4js');
var log = log4js.getLogger('InputFileResolver');
var DEFAULT_INPUT_FILE_PROPERTIES = { mutated: false, included: true };
var InputFileResolver = (function () 0{
}{
function InputFileResolver(mutate, allFileExpressions) 1{
}{
this.mutateFileExpressions = 2mutate && []mutate || [];
this.inputFileDescriptors = allFileExpressions.map(function (maybePattern) 3{
}{
if (4false5trueInputFileResolver.isInputFileDescriptor(maybePattern)) 6{
}{
return maybePattern;
}
else 7{
}{
return _.assign({ pattern: maybePattern }, DEFAULT_INPUT_FILE_PROPERTIES);
}
});
}
InputFileResolver.prototype.resolve = function () 8{
}{
var mutateFilePromise = this.resolveMutateFileGlobs();
return this.resolveInputFileGlobs().then(function (allInputFiles) 9{
}{ return mutateFilePromise.then(function (additionalMutateFiles) 10{
}{
InputFileResolver.markAdditionalFilesToMutate(allInputFiles, additionalMutateFiles);
InputFileResolver.warnAboutNoFilesToMutate(allInputFiles);
return allInputFiles;
}); });
};
InputFileResolver.markAdditionalFilesToMutate = function (allInputFiles, additionalMutateFiles) 11{
}{
var errors = [];
additionalMutateFiles.forEach(function (mutateFile) 12{
}{
if (13true14false!allInputFiles.filter(function (inputFile) 15{
}{ return 16inputFile.path !== mutateFileinputFile.path === mutateFile; }).length) 17{
}{
errors.push(18'Could not find mutate file "' + mutateFile - '" in list of files.'19'Could not find mutate file "' - mutateFile"Could not find mutate file \"" + mutateFile + "\" in list of files.");
}
});
if (20true21errors.length >= 022false23errors.length <= 0errors.length > 0) 24{
}{
throw new Error(errors.join(' '));
}
allInputFiles.forEach(function (file) 25{
}{ return file.mutated = 26additionalMutateFiles.some(function (mutateFile) {
return mutateFile === file.path;
}) && file.mutatedadditionalMutateFiles.some(function (mutateFile) 27{
}{ return 28mutateFile !== file.pathmutateFile === file.path; }) || file.mutated; });
};
InputFileResolver.warnAboutNoFilesToMutate = function (allInputFiles) 29{
}{
var mutateFiles = allInputFiles.filter(function (file) 30{
}{ return file.mutated; });
if (31false32truemutateFiles.length) 33{
}{
log.info(34'Found ' + mutateFiles.length - ' file(s) to be mutated.'35'Found ' - mutateFiles.length"Found " + mutateFiles.length + " file(s) to be mutated.");
}
else 36{
}{
log.warn("No files marked to be mutated, stryker will perform a dry-run without actually mutating anything.");
}
};
InputFileResolver.reportEmptyGlobbingExpression = function (expression) 37{
}{
log.warn(38'Globbing expression "' + expression - '" did not result in any files.'39'Globbing expression "' - expression"Globbing expression \"" + expression + "\" did not result in any files.");
};
InputFileResolver.isInputFileDescriptor = function (maybeInputFileDescriptor) 40{
}{
if (41true42false_.isObject(maybeInputFileDescriptor)) 43{
}{
if (44false45true46Object.keys(maybeInputFileDescriptor).indexOf('pattern') >= -147Object.keys(maybeInputFileDescriptor).indexOf('pattern') <= -1Object.keys(maybeInputFileDescriptor).indexOf('pattern') > 48+1-1) 49{
}{
return true;
}
else 50{
}{
throw Error(51'File descriptor ' + JSON.stringify(maybeInputFileDescriptor) - ' is missing mandatory property \'pattern\'.'52'File descriptor ' - JSON.stringify(maybeInputFileDescriptor)"File descriptor " + JSON.stringify(maybeInputFileDescriptor) + " is missing mandatory property 'pattern'.");
}
}
else 53{
}{
return false;
}
};
InputFileResolver.prototype.resolveMutateFileGlobs = function () 54{
}{
return Promise.all(this.mutateFileExpressions.map(InputFileResolver.resolveFileGlob))
.then(function (files) 55{
}{ return _.flatten(files); });
};
InputFileResolver.prototype.resolveInputFileGlobs = function () 56{
}{
return Promise.all(this.inputFileDescriptors.map(function (descriptor) 57{
}{ return InputFileResolver.resolveFileGlob(descriptor.pattern)
.then(function (sourceFiles) 58{
}{ return sourceFiles.map(function (sourceFile) 59{
}{ return InputFileResolver.createInputFile(sourceFile, descriptor); }); }); })).then(function (promises) 60{
}{ return _.flatten(promises); });
};
InputFileResolver.createInputFile = function (path, descriptor) 61{
}{
var inputFile = _.assign({ path: path }, DEFAULT_INPUT_FILE_PROPERTIES, descriptor);
delete inputFile['pattern'];
return inputFile;
};
InputFileResolver.resolveFileGlob = function (expression) 62{
}{
var _this = this;
return fileUtils_1.glob(expression).then(function (files) 63{
}{
if (64false65files.length !== 066truefiles.length === 0) 67{
}{
_this.reportEmptyGlobbingExpression(expression);
}
fileUtils_1.normalize(files);
return files;
});
};
return InputFileResolver;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = InputFileResolver;
//# sourceMappingURL=InputFileResolver.js.map