Commit 86030267 by Ehtesham Committed by Usman Khalid

making preprocessor files path absolute to have coverage reporter include file only once

parent 51bf39fc
......@@ -114,15 +114,7 @@ var runAndConfigFiles = [
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
......
......@@ -102,15 +102,7 @@ var runAndConfigFiles = [
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
......
// Common configuration for Karma
/* jshint node: true */
/*jshint -W079 */
'use strict';
var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../');
/**
......@@ -100,6 +102,25 @@ function junitSettings(config) {
};
}
var getPreprocessorObject = function (files) {
var preprocessFiles = {};
files.forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
if (pattern.match(/^common\/js/)) {
pattern = path.join(appRoot, '/common/static/' + pattern)
} else if (pattern.match(/^xmodule_js\/common_static/)) {
pattern = path.join(appRoot, '/common/static/' +
pattern.replace(/^xmodule_js\/common_static\//, ''));
}
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
};
var getConfig = function (config, useRequireJs) {
useRequireJs = useRequireJs === undefined ? true : useRequireJs;
......@@ -216,5 +237,6 @@ var getConfig = function (config, useRequireJs) {
module.exports = {
getConfig: getConfig,
getPreprocessorObject: getPreprocessorObject,
appRoot: appRoot
};
......@@ -80,8 +80,10 @@ var fixtureFiles = [
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage'];
});
......
......@@ -74,8 +74,10 @@ var runAndConfigFiles = [
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage'];
});
......
......@@ -128,15 +128,7 @@ var runAndConfigFiles = [
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
module.exports = function (config) {
var commonConfig = configModule.getConfig(config),
......
......@@ -80,15 +80,7 @@ var fixtureFiles = [
// do not include tests or libraries
// (these files will be instrumented by Istanbul)
var preprocessors = (function () {
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
module.exports = function (config) {
var commonConfig = configModule.getConfig(config, false),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment