feat(build): add `test.unit.dartvm` for a faster roundtrip of dartvm tests

This commit is contained in:
Tobias Bosch 2015-06-05 11:06:24 -07:00
parent 529805508a
commit 46eeee6b5e
2 changed files with 69 additions and 36 deletions

View File

@ -497,6 +497,33 @@ gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function (neverDon
}); });
gulp.task('test.unit.dartvm', function (done) {
runSequence(
'build/tree.dart',
'build/pubspec.dart',
'!build/change_detect.dart',
'!test.unit.dartvm/run',
function(error) {
// if initial build failed (likely due to build or formatting step) then exit
// otherwise karma server doesn't start and we can't continue running properly
if (error) {
done(error);
return;
}
watch('modules/angular2/**', { ignoreInitial: true }, [
'!build/tree.dart',
'!test.unit.dartvm/run'
]);
}
);
});
gulp.task('!test.unit.dartvm/run', runServerDartTests(gulp, gulpPlugins, {
dir: 'dist/dart/angular2'
}));
gulp.task('test.unit.tools/ci', function(done) { gulp.task('test.unit.tools/ci', function(done) {
runJasmineTests(['dist/tools/**/*.spec.js', 'tools/**/*.spec.js'], done); runJasmineTests(['dist/tools/**/*.spec.js', 'tools/**/*.spec.js'], done);
}); });

View File

@ -8,41 +8,47 @@ var util = require('./util');
module.exports = function(gulp, plugins, config) { module.exports = function(gulp, plugins, config) {
return function() { return function() {
return util.forEachSubDirSequential( if (config.dir) {
config.dest, return run(config.dir);
function(dir) { } else {
var testDir = path.join(dir, 'test'); return util.forEachSubDirSequential(config.dest, run);
var relativeMasterTestFile = 'test/_all_tests.dart'; }
var testFiles = [].slice.call(glob.sync('**/*.server.spec.dart', {
cwd: testDir
}));
if (testFiles.length == 0) {
// No test files found
return Q.resolve();
}
var header = ['library _all_tests;', ''];
var main = ['main() {'];
testFiles.forEach(function(fileName, index) {
header.push('import "' + fileName + '" as test_' + index + ';');
main.push(' test_' + index + '.main();');
});
header.push('');
main.push('}');
var absMasterTestFile = path.join(dir, relativeMasterTestFile);
fs.writeFileSync(absMasterTestFile, header.concat(main).join('\n'));
var defer = Q.defer();
var done = defer.makeNodeResolver();
util.processToPromise(spawn('dart', ['-c', relativeMasterTestFile], {
stdio: 'inherit',
cwd: dir
})).then(
function() { done(); },
function(error) { done(error); }
);
return defer.promise;
}
);
}; };
function run(dir) {
var testDir = path.join(dir, 'test');
var relativeMasterTestFile = 'test/_all_tests.dart';
var testFiles = [].slice.call(glob.sync('**/*.server.spec.dart', {
cwd: testDir
}));
if (testFiles.length == 0) {
// No test files found
return Q.resolve();
}
var header = ['library _all_tests;', ''];
var main = ['main() {'];
testFiles.forEach(function(fileName, index) {
header.push('import "' + fileName + '" as test_' + index + ';');
main.push(' test_' + index + '.main();');
});
header.push('');
main.push('}');
var absMasterTestFile = path.join(dir, relativeMasterTestFile);
fs.writeFileSync(absMasterTestFile, header.concat(main).join('\n'));
var defer = Q.defer();
var done = defer.makeNodeResolver();
console.log('start tests');
util.processToPromise(spawn('dart', ['-c', relativeMasterTestFile], {
stdio: 'inherit',
cwd: dir
})).then(
function() { done(); },
function(error) { done(error); }
);
return defer.promise.then(function() {
console.log('end tests');
});
}
}; };