From 46eeee6b5e44304a9954bbc878a022a1062fa0f9 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Fri, 5 Jun 2015 11:06:24 -0700 Subject: [PATCH] feat(build): add `test.unit.dartvm` for a faster roundtrip of dartvm tests --- gulpfile.js | 27 ++++++++++ tools/build/run_server_dart_tests.js | 78 +++++++++++++++------------- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 371f0afa29..95f9eb340f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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) { runJasmineTests(['dist/tools/**/*.spec.js', 'tools/**/*.spec.js'], done); }); diff --git a/tools/build/run_server_dart_tests.js b/tools/build/run_server_dart_tests.js index 92dec045f9..84f4801faa 100644 --- a/tools/build/run_server_dart_tests.js +++ b/tools/build/run_server_dart_tests.js @@ -8,41 +8,47 @@ var util = require('./util'); module.exports = function(gulp, plugins, config) { return function() { - return util.forEachSubDirSequential( - config.dest, - function(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(); - util.processToPromise(spawn('dart', ['-c', relativeMasterTestFile], { - stdio: 'inherit', - cwd: dir - })).then( - function() { done(); }, - function(error) { done(error); } - ); - return defer.promise; - } - ); + if (config.dir) { + return run(config.dir); + } else { + return util.forEachSubDirSequential(config.dest, run); + } }; + + 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'); + }); + } };