chore(build): refactor test.unit.cjs to use the broccoli pipeline
This change solves several problems: - the broccoli pipeline is used to compile the node/cjs tree upon any change to the modules/ directory - jasmine tests run in a new process removing the need to clean up environment after each test - since we transpile only those test files that are actually needed for node/cjs build, we transpile less and don't need to filter out tests
This commit is contained in:
parent
427f0d021c
commit
725f909ff8
49
gulpfile.js
49
gulpfile.js
|
@ -1,5 +1,6 @@
|
||||||
var autoprefixer = require('gulp-autoprefixer');
|
var autoprefixer = require('gulp-autoprefixer');
|
||||||
var format = require('gulp-clang-format');
|
var format = require('gulp-clang-format');
|
||||||
|
var fork = require('child_process').fork;
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var gulpPlugins = require('gulp-load-plugins')();
|
var gulpPlugins = require('gulp-load-plugins')();
|
||||||
var sass = require('gulp-sass');
|
var sass = require('gulp-sass');
|
||||||
|
@ -8,6 +9,7 @@ var runSequence = require('run-sequence');
|
||||||
var madge = require('madge');
|
var madge = require('madge');
|
||||||
var merge = require('merge');
|
var merge = require('merge');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var Q = require('q');
|
||||||
|
|
||||||
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
|
||||||
var clean = require('./tools/build/clean');
|
var clean = require('./tools/build/clean');
|
||||||
|
@ -465,27 +467,38 @@ gulp.task('test.unit.cjs/ci', function () {
|
||||||
gulp.task('test.unit.cjs', ['build.js.cjs'], function () {
|
gulp.task('test.unit.cjs', ['build.js.cjs'], function () {
|
||||||
//Run tests once
|
//Run tests once
|
||||||
runSequence('test.unit.cjs/ci', function() {});
|
runSequence('test.unit.cjs/ci', function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
function runNodeJasmineTests() {
|
||||||
|
var doneDeferred = Q.defer();
|
||||||
|
var jasmineProcess = fork('./tools/traceur-jasmine', ['dist/js/cjs/angular2/test/**/*_spec.js'], {
|
||||||
|
stdio: 'inherit'
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmineProcess.on('close', function (code) {
|
||||||
|
doneDeferred.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
return doneDeferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('test.unit.cjs/ci', runNodeJasmineTests);
|
||||||
|
|
||||||
|
gulp.task('test.unit.cjs', ['build.broccoli.tools'], function (done) {
|
||||||
|
//Run tests once
|
||||||
|
var nodeBroccoliBuilder = getBroccoli().forNodeTree();
|
||||||
|
|
||||||
|
|
||||||
|
nodeBroccoliBuilder.doBuild().then(function() {
|
||||||
|
gulp.start('build/linknodemodules.js.cjs');
|
||||||
|
return runNodeJasmineTests();
|
||||||
|
}).then(function() {
|
||||||
//Watcher to transpile file changed
|
//Watcher to transpile file changed
|
||||||
gulp.watch(CONFIG.transpile.src.js.concat(['modules/**/*.cjs']), function(event) {
|
gulp.watch('modules/**', function(event) {
|
||||||
var relPath = path.relative(__dirname, event.path).replace(/\\/g, "/");
|
console.log("fs changes detected", event);
|
||||||
gulp.src(relPath)
|
nodeBroccoliBuilder.doBuild().then(runNodeJasmineTests);
|
||||||
.pipe(gulpPlugins.rename({extname: '.'+ 'js'}))
|
|
||||||
.pipe(gulpTraceur(CONFIG.transpile.options.js.cjs, file2moduleName))
|
|
||||||
.pipe(transformCJSTests())
|
|
||||||
.pipe(gulp.dest(CONFIG.dest.js.cjs + path.dirname(relPath.replace("modules", ""))));
|
|
||||||
});
|
});
|
||||||
//Watcher to run tests when dist/js/cjs/angular2 is updated by the first watcher (after clearing the node cache)
|
|
||||||
gulp.watch(CONFIG.dest.js.cjs + '/angular2/**/*.js', function(event) {
|
|
||||||
for (var id in require.cache) {
|
|
||||||
if (id.replace(/\\/g, "/").indexOf(CONFIG.dest.js.cjs) > -1) {
|
|
||||||
delete require.cache[id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
global.assert = undefined; // https://github.com/angular/angular/issues/1340
|
|
||||||
runSequence('test.unit.cjs/ci', function() {});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
|
@ -621,7 +634,7 @@ gulp.task('broccoli.js.cjs', ['build.broccoli.tools'], function() {
|
||||||
gulp.task('build.js.cjs', function(done) {
|
gulp.task('build.js.cjs', function(done) {
|
||||||
runSequence(
|
runSequence(
|
||||||
'broccoli.js.cjs',
|
'broccoli.js.cjs',
|
||||||
['build/linknodemodules.js.cjs'],
|
'build/linknodemodules.js.cjs',
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
"lodash": "^2.4.1",
|
"lodash": "^2.4.1",
|
||||||
"madge": "^0.5.0",
|
"madge": "^0.5.0",
|
||||||
"merge": "^1.2.0",
|
"merge": "^1.2.0",
|
||||||
|
"minijasminenode2": "^1.0.0",
|
||||||
"minimatch": "^2.0.1",
|
"minimatch": "^2.0.1",
|
||||||
"minimist": "1.1.x",
|
"minimist": "1.1.x",
|
||||||
"parse5": "1.3.2",
|
"parse5": "1.3.2",
|
||||||
|
|
|
@ -19,7 +19,14 @@ module.exports = function makeNodeTree() {
|
||||||
|
|
||||||
var modulesTree = new Funnel('modules', {
|
var modulesTree = new Funnel('modules', {
|
||||||
include: ['angular2/**', 'benchpress/**', 'rtts_assert/**', '**/e2e_test/**'],
|
include: ['angular2/**', 'benchpress/**', 'rtts_assert/**', '**/e2e_test/**'],
|
||||||
exclude: ['angular2/src/core/zone/vm_turn_zone.es6']
|
exclude: [
|
||||||
|
'angular2/src/core/zone/vm_turn_zone.es6',
|
||||||
|
'angular2/test/core/application_spec.js',
|
||||||
|
'angular2/test/core/testability/**',
|
||||||
|
'angular2/test/core/zone/**',
|
||||||
|
'angular2/test/render/**',
|
||||||
|
'angular2/test/forms/integration_spec.js'
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var nodeTree = new TraceurCompiler(modulesTree, '.js', '.map', {
|
var nodeTree = new TraceurCompiler(modulesTree, '.js', '.map', {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var glob = require('glob');
|
||||||
|
var minijasminenode2 = require('minijasminenode2');
|
||||||
|
var path = require('path');
|
||||||
|
// Require traceur to exposes $traceurRuntime on global context so that CJS files can run
|
||||||
|
require('traceur/bin/traceur-runtime.js');
|
||||||
|
|
||||||
|
glob(process.argv[2], function (error, specFiles) {
|
||||||
|
minijasminenode2.executeSpecs({
|
||||||
|
includeStackTrace: true,
|
||||||
|
defaultTimeoutInterval: 1000,
|
||||||
|
showColors: process.argv.indexOf('--no-color') === -1,
|
||||||
|
specs: specFiles
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue