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 = [ ...@@ -114,15 +114,7 @@ var runAndConfigFiles = [
// do not include tests or libraries // do not include tests or libraries
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
module.exports = function (config) { module.exports = function (config) {
var commonConfig = configModule.getConfig(config), var commonConfig = configModule.getConfig(config),
......
...@@ -102,15 +102,7 @@ var runAndConfigFiles = [ ...@@ -102,15 +102,7 @@ var runAndConfigFiles = [
// do not include tests or libraries // do not include tests or libraries
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
module.exports = function (config) { module.exports = function (config) {
var commonConfig = configModule.getConfig(config), var commonConfig = configModule.getConfig(config),
......
// Common configuration for Karma // Common configuration for Karma
/* jshint node: true */ /* jshint node: true */
/*jshint -W079 */
'use strict'; 'use strict';
var path = require('path'); var path = require('path');
var _ = require('underscore');
var appRoot = path.join(__dirname, '../../../../'); var appRoot = path.join(__dirname, '../../../../');
/** /**
...@@ -100,6 +102,25 @@ function junitSettings(config) { ...@@ -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) { var getConfig = function (config, useRequireJs) {
useRequireJs = useRequireJs === undefined ? true : useRequireJs; useRequireJs = useRequireJs === undefined ? true : useRequireJs;
...@@ -216,5 +237,6 @@ var getConfig = function (config, useRequireJs) { ...@@ -216,5 +237,6 @@ var getConfig = function (config, useRequireJs) {
module.exports = { module.exports = {
getConfig: getConfig, getConfig: getConfig,
getPreprocessorObject: getPreprocessorObject,
appRoot: appRoot appRoot: appRoot
}; };
...@@ -80,8 +80,10 @@ var fixtureFiles = [ ...@@ -80,8 +80,10 @@ var fixtureFiles = [
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = (function () {
var preprocessFiles = {}; var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) { _.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file; var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage']; preprocessFiles[pattern] = ['coverage'];
}); });
......
...@@ -74,8 +74,10 @@ var runAndConfigFiles = [ ...@@ -74,8 +74,10 @@ var runAndConfigFiles = [
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = (function () {
var preprocessFiles = {}; var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) { _.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file; var pattern = _.isObject(file) ? file.pattern : file;
pattern = path.join(configModule.appRoot, '/common/static/' + pattern);
preprocessFiles[pattern] = ['coverage']; preprocessFiles[pattern] = ['coverage'];
}); });
......
...@@ -128,15 +128,7 @@ var runAndConfigFiles = [ ...@@ -128,15 +128,7 @@ var runAndConfigFiles = [
// do not include tests or libraries // do not include tests or libraries
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
module.exports = function (config) { module.exports = function (config) {
var commonConfig = configModule.getConfig(config), var commonConfig = configModule.getConfig(config),
......
...@@ -80,15 +80,7 @@ var fixtureFiles = [ ...@@ -80,15 +80,7 @@ var fixtureFiles = [
// do not include tests or libraries // do not include tests or libraries
// (these files will be instrumented by Istanbul) // (these files will be instrumented by Istanbul)
var preprocessors = (function () { var preprocessors = configModule.getPreprocessorObject(_.flatten([sourceFiles, specFiles]));
var preprocessFiles = {};
_.flatten([sourceFiles, specFiles]).forEach(function (file) {
var pattern = _.isObject(file) ? file.pattern : file;
preprocessFiles[pattern] = ['coverage'];
});
return preprocessFiles;
}());
module.exports = function (config) { module.exports = function (config) {
var commonConfig = configModule.getConfig(config, false), 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