2015-02-20 20:44:23 -05:00
|
|
|
var Q = require('q');
|
|
|
|
var glob = require('glob');
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
var util = require('./util');
|
|
|
|
|
|
|
|
module.exports = function(gulp, plugins, config) {
|
|
|
|
return function() {
|
2015-06-05 14:06:24 -04:00
|
|
|
if (config.dir) {
|
|
|
|
return run(config.dir);
|
|
|
|
} else {
|
|
|
|
return util.forEachSubDirSequential(config.dest, run);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function run(dir) {
|
|
|
|
var testFiles = [].slice.call(glob.sync('**/*.server.spec.dart', {
|
2015-12-15 20:11:42 -05:00
|
|
|
cwd: dir
|
2015-06-05 14:06:24 -04:00
|
|
|
}));
|
|
|
|
if (testFiles.length == 0) {
|
|
|
|
// No test files found
|
|
|
|
return Q.resolve();
|
|
|
|
}
|
2015-02-20 20:44:23 -05:00
|
|
|
|
2015-06-05 14:06:24 -04:00
|
|
|
var defer = Q.defer();
|
|
|
|
var done = defer.makeNodeResolver();
|
2015-08-11 15:53:01 -04:00
|
|
|
console.log('start tests:', dir);
|
2015-12-15 20:11:42 -05:00
|
|
|
var processSerial = function() {
|
|
|
|
if (testFiles.length == 0) {
|
|
|
|
done();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var file = testFiles.shift();
|
|
|
|
util.processToPromise(spawn('dart', ['-c', file], {
|
|
|
|
stdio: 'inherit',
|
|
|
|
cwd: dir
|
|
|
|
})).then(
|
|
|
|
processSerial,
|
|
|
|
function(error) {
|
|
|
|
done(error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
processSerial();
|
2015-06-05 14:06:24 -04:00
|
|
|
return defer.promise.then(function() {
|
|
|
|
console.log('end tests');
|
|
|
|
});
|
|
|
|
}
|
2015-02-20 20:44:23 -05:00
|
|
|
};
|