each spec bundle has its own folder now

Co-authored-by: rubenmoya <ruben@carto.com>
pull/13575/head
Román Jiménez 7 years ago
parent 7f856fca20
commit abadca301c

@ -390,7 +390,7 @@ module.exports = function (grunt) {
'invalidate'
]);
grunt.registerTask('affected', 'Generate only affected specs', function (option) {
grunt.registerTask('generate_builder_specs', 'Generate only builder specs', function (option) {
requireWebpackTask().affected.call(this, option, grunt);
});
@ -422,14 +422,14 @@ module.exports = function (grunt) {
'beforeDefault',
'js_editor',
'jasmine:cartodbui',
'affected',
'generate_builder_specs',
'bootstrap_webpack_builder_specs',
'webpack:builder_specs',
'jasmine:affected',
'jasmine:builder',
'generate_dashboard_specs',
'bootstrap_webpack_builder_specs',
'webpack:builder_specs',
'jasmine:affected',
'bootstrap_webpack_dashboard_specs',
'webpack:dashboard_specs',
'jasmine:dashboard',
'lint'
]);
@ -437,11 +437,11 @@ module.exports = function (grunt) {
* `grunt test:browser` compile all Builder specs and launch a webpage in the browser.
*/
grunt.registerTask('test:browser', 'Build all Builder specs', [
'affected',
'generate_builder_specs',
'bootstrap_webpack_builder_specs',
'webpack:builder_specs',
'jasmine:affected:build',
'connect:specs',
'jasmine:builder:build',
'connect:specs_builder',
'watch:js_affected'
]);
@ -450,10 +450,10 @@ module.exports = function (grunt) {
*/
grunt.registerTask('dashboard_specs', 'Build only dashboard specs', [
'generate_dashboard_specs',
'bootstrap_webpack_builder_specs',
'webpack:builder_specs',
'jasmine:affected:build',
'connect:specs',
'bootstrap_webpack_dashboard_specs',
'webpack:dashboard_specs',
'jasmine:dashboard:build',
'connect:specs_dashboard',
'watch:dashboard_specs'
]);

@ -1,3 +1,15 @@
const DEFAULT_CONFIG = {
livereload: false,
hostname: '0.0.0.0', // to be able to access the server not only from localhost
base: {
path: '.'
}
};
function generateConfig (cfg) {
return Object.assign({}, DEFAULT_CONFIG, cfg);
}
module.exports = {
task: function () {
return {
@ -24,16 +36,18 @@ module.exports = {
}
},
// Watching the specs during development
specs: {
options: {
specs_dashboard: {
options: generateConfig({
port: 8090,
open: 'http://localhost:8090/_SpecRunner_dashboard.html'
})
},
specs_builder: {
options: generateConfig({
port: 8088,
livereload: false,
open: 'http://localhost:8088/builder_specs.html',
hostname: '0.0.0.0', // to be able to access the server not only from localhost
base: {
path: '.'
}
}
open: 'http://localhost:8088/_SpecRunner_builder.html'
})
}
};
}

@ -1,5 +1,26 @@
var js_files = require('../files/js_files');
const DEFAULT_CONFIG = {
browser: 'phantomjs',
headless: true,
timeout: 20000,
keepRunner: true,
// grunt:test (CI) always generates a server on port 8088
host: 'http://localhost:8088',
summary: true,
display: 'short',
helpers: js_files._spec_helpers3,
reportSlowerThan: 2000,
vendor: [
'node_modules/source-map-support/browser-source-map-support.js',
'lib/assets/test/spec/deep-insights/install-source-map-support.js',
'node_modules/jasmine-ajax/lib/mock-ajax.js',
'node_modules/underscore/underscore-min.js'
]
};
const getJasmineConfig = (config) => (Object.assign({}, DEFAULT_CONFIG, config));
module.exports = {
cartodbui: {
src: js_files.all.concat([
@ -21,26 +42,23 @@ module.exports = {
}
},
affected: {
options: {
browser: 'phantomjs',
headless: true,
timeout: 20000,
keepRunner: true,
outfile: '_SpecRunner-affected.html',
host: 'http://localhost:8088',
summary: true,
display: 'short',
helpers: js_files._spec_helpers3,
reportSlowerThan: 2000,
dashboard: {
options: getJasmineConfig({
outfile: '_SpecRunner_dashboard.html',
specs: [
'.grunt/vendor.affected-specs.js',
'.grunt/main.affected-specs.js'
],
vendor: [
'node_modules/jasmine-ajax/lib/mock-ajax.js',
'node_modules/underscore/underscore-min.js'
'.grunt/dashboard_specs/vendor.affected-specs.js',
'.grunt/dashboard_specs/main.affected-specs.js'
]
}
})
},
builder: {
options: getJasmineConfig({
outfile: '_SpecRunner_builder.html',
specs: [
'.grunt/builder_specs/vendor.affected-specs.js',
'.grunt/builder_specs/main.affected-specs.js'
]
})
}
};

@ -1,18 +1,20 @@
var path = require('path');
var webpack = require('webpack');
/*
This function will be called with the config name (dashboard_specs, builder_spec) so
you have a change to customize webpack for each bundle.
*/
module.exports = {
task: function () {
var cfg = {};
cfg.builder_specs = {
task: function (config) {
return {
entry: {
main: [
// To be filled by grunt
]
},
output: {
path: path.resolve(path.resolve('.'), '.grunt'),
path: path.resolve(path.resolve('.'), '.grunt', config),
filename: '[name].affected-specs.js'
},
resolve: {
@ -38,7 +40,9 @@ module.exports = {
loader: 'babel-loader',
include: [
path.resolve(path.resolve('.'), 'lib/assets/javascripts/carto-node'),
path.resolve(path.resolve('.'), 'lib/assets/test/spec/carto-node')
path.resolve(path.resolve('.'), 'lib/assets/test/spec/carto-node'),
path.resolve(path.resolve('.'), 'lib/assets/test/spec/dashboard'),
path.resolve(path.resolve('.'), 'lib/assets/javascripts/dashboard')
],
options: {
presets: [
@ -84,7 +88,5 @@ module.exports = {
fs: 'empty'
}
};
return cfg;
}
};

@ -4,7 +4,7 @@ var colors = require('colors');
var pretty = require('prettysize');
var glob = require('glob');
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin;
var cfg = require('./webpack.config.js').task();
var configGenerator = require('./webpack.config.js').task;
var compiler = {};
var affectedSpecs = [];
@ -40,11 +40,8 @@ var affected = function (option, grunt) {
* dashboard - To be used as part of a 'registerTask' Grunt definition
*/
var dashboard = function (option, grunt) {
var done = this.async();
var allSpecs = glob.sync(paths.dashboard_specs);
console.log(colors.yellow('All specs. ' + allSpecs.length + ' specs found.'));
affectedSpecs = [].concat(allSpecs);
done();
affectedSpecs = glob.sync(paths.dashboard_specs);
console.log(colors.yellow('All specs. ' + affectedSpecs.length + ' specs found.'));
};
var bootstrap = function (config, grunt) {
@ -52,15 +49,13 @@ var bootstrap = function (config, grunt) {
throw new Error('Please provide subconfiguration key for webpack.');
}
if (!cfg[config]) {
throw new Error(config + ' section needed in webpack.config.js');
}
const cfg = configGenerator(config);
cfg[config].entry = function () {
cfg.entry = function () {
return affectedSpecs;
};
compiler[config] = webpack(cfg[config]);
compiler[config] = webpack(cfg);
cache[config] = {};
compiler[config].apply(new webpack.CachePlugin(cache[config]));

Loading…
Cancel
Save