Parallel: run our own specs in parallel

This commit is contained in:
Steve Gravrock
2022-09-17 11:20:26 -07:00
parent 4c8d57e14c
commit 2272f9aead
4 changed files with 40 additions and 8 deletions
+36 -4
View File
@@ -30,9 +30,9 @@ module.exports = function(grunt) {
function() {
verifyNoGlobals(() => require('./lib/jasmine-core.js').noGlobals());
const done = this.async(),
Jasmine = require('jasmine'),
jasmineCore = require('./lib/jasmine-core.js'),
jasmine = new Jasmine({jasmineCore: jasmineCore});
Jasmine = require('jasmine'),
jasmineCore = require('./lib/jasmine-core.js'),
jasmine = new Jasmine({jasmineCore: jasmineCore});
jasmine.loadConfigFile('./spec/support/jasmine.json');
jasmine.exitOnCompletion = false;
@@ -40,12 +40,44 @@ module.exports = function(grunt) {
result => done(result.overallStatus === 'passed'),
err => {
console.error(err);
exit(1);
done(false);
}
);
}
);
grunt.registerTask("execSpecsInParallel",
"Run Jasmine core specs in parallel in Node.js",
function() {
// Need to require this here rather than at the top of the file
// so that we don't break verifyNoGlobals above by loading jasmine-core
// too early
const ParallelRunner = require('jasmine/parallel');
console.log('parallel runner pid:', process.pid);
const done = this.async();
// TODO use this core instead of the one imported by jasmine/parallel
// const jasmineCore = require('./lib/jasmine-core.js');
const runner = new ParallelRunner({
// TODO:
// jasmineCore,
// numWorkers: require('os').cpus().length
});
runner.loadConfigFile('./spec/support/jasmine.json')
.then(() => {
runner.exitOnCompletion = false;
return runner.execute();
}).then(
jasmineDoneInfo => done(jasmineDoneInfo.overallStatus === 'passed'),
err => {
console.error(err);
done(false);
}
);
}
);
grunt.registerTask("execSpecsInNode:performance",
"Run Jasmine performance specs in Node.js",
function() {