grunt-parallel-spec-runner
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "grunt-parallel-spec-runner", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Plugin used to configure and launch multiple spec ", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/RallySoftware/grunt-parallel-spec-runner.git", |
@@ -13,3 +13,3 @@ /* | ||
var SpecRunner = function(){ | ||
var SpecRunner = function(options){ | ||
var started = false, | ||
@@ -25,15 +25,4 @@ allDone = false, | ||
var config = arguments[0] || {}, | ||
target = config.target, | ||
debug = config.debug || false, | ||
verbose = config.verbose || false, | ||
specs = config.specs || [], | ||
keepalive = config.keepalive || false, | ||
isolatedSpecs = config.isolatedSpecs || [], | ||
isolateAllSpecs = config.isolateAllSpecs || false, | ||
maxRunners = +config.maxRunners > 0 ? +config.maxRunners : 4, | ||
maxSpecFilesPerRunner = +config.maxSpecFilesPerRunner > 0 ? +config.maxSpecFilesPerRunner : Math.ceil(specs.length / maxRunners); | ||
if(isolateAllSpecs){ | ||
maxSpecFilesPerRunner = 1; | ||
if(options.isolateAllSpecs){ | ||
options.maxSpecFilesPerRunner = 1; | ||
}; | ||
@@ -48,6 +37,6 @@ | ||
var appendAdditionalOptions = function(args){ | ||
if(debug){ | ||
if(options.debug){ | ||
args.push('--debug'); | ||
} | ||
if(verbose){ | ||
if(options.verbose){ | ||
args.push('--verbose'); | ||
@@ -59,4 +48,4 @@ } | ||
var buildSpecRunners = function(){ | ||
specs.forEach(function(path) { | ||
if(isolatedSpecs.indexOf(path) == -1){ | ||
options.specs.forEach(function(path) { | ||
if(options.isolatedSpecs.indexOf(path) == -1){ | ||
buildSpecRunner(path); | ||
@@ -66,5 +55,5 @@ } | ||
if(isolatedSpecs.length > 0){ | ||
maxSpecFilesPerRunner = 1; | ||
isolatedSpecs.forEach(function(path) { | ||
if(options.isolatedSpecs.length > 0){ | ||
options.maxSpecFilesPerRunner = 1; | ||
options.isolatedSpecs.forEach(function(path) { | ||
grunt.verbose.writeln('Isolating spec: ' + path); | ||
@@ -89,3 +78,3 @@ if(specRunners[specRunnerIndex] && specRunners[specRunnerIndex].specs.length > 0){ | ||
specRunners[specRunnerIndex].specs.push(path); | ||
if(specRunners[specRunnerIndex].specs.length >= maxSpecFilesPerRunner){ | ||
if(specRunners[specRunnerIndex].specs.length >= options.maxSpecFilesPerRunner){ | ||
specRunnerIndex++; | ||
@@ -103,4 +92,3 @@ } | ||
var targetName = 'jasmine:' + target + ':build:' + specRunner.file + ':' + specRunner.specs.join(','); | ||
grunt.verbose.writeln('target:' + targetName); | ||
var targetName = 'jasmine:' + options.target + ':build:' + specRunner.file + ':' + specRunner.specs.join(','); | ||
var spawnOptions = | ||
@@ -119,3 +107,3 @@ { | ||
var i = setInterval(function(){ | ||
while(activeRunners <= maxRunners && specRunnerQueue.length > 0){ | ||
while(activeRunners <= options.maxSpecRunners && specRunnerQueue.length > 0){ | ||
launchSpecRunner(specRunnerQueue.pop()) | ||
@@ -148,6 +136,6 @@ } | ||
opts: {stdio: 'inherit'}, | ||
args: ['webdriver_jasmine_runner:' + target + ':' + specRunner.file] | ||
args: ['webdriver_jasmine_runner:' + options.target + ':' + specRunner.file] | ||
} | ||
appendAdditionalOptions(opts.args); | ||
if(keepalive){ | ||
if(options.keepalive){ | ||
opts.args.push('--keepalive'); | ||
@@ -170,3 +158,3 @@ } | ||
var cleanUp = function(){ | ||
if(!keepalive) { | ||
if(!options.keepalive) { | ||
specRunners.forEach(function(specRunner){ | ||
@@ -190,3 +178,2 @@ grunt.file.delete(specRunner.file); | ||
buildSpecRunners(); | ||
//writeSpecRunners(); | ||
launchSpecRunners(); | ||
@@ -203,29 +190,33 @@ waitForDone(); | ||
var config = { | ||
target: grunt.task.current.target, | ||
var options = this.options({ | ||
specs: [], | ||
excludedSpecs: [], | ||
isolatedSpecs: [], | ||
target: this.target, | ||
debug: grunt.option('debug') || false, | ||
verbose: grunt.option('verbose') || false, | ||
keepalive: grunt.option('keepalive') || false, | ||
maxRunners: grunt.option('maxRunners') > 0 ? +grunt.option('maxRunners') : 4, | ||
maxSpecFilesPerRunner: grunt.option('maxSpecFilesPerRunner'), | ||
isolateAllSpecs: grunt.option('isolateAllSpecs') || false, | ||
maxSpecRunners: grunt.option('maxSpecRunners') > 0 ? +grunt.option('maxSpecRunners') : 4, | ||
isolateAllSpecs: grunt.option('isolateAllSpecs') || false | ||
}); | ||
options.specs = grunt.file.expand({filter: 'isFile'}, options.specs); | ||
options.excludedSpecs = grunt.file.expand({filter: 'isFile'}, options.excludedSpecs); | ||
options.isolatedSpecs = grunt.file.expand({filter: 'isFile'}, options.isolatedSpecs); | ||
//TODO: specs should be on the parallel_spec_runner apsdkp options... rather that looking at another task config like this. | ||
excludedSpecs: grunt.file.expand({filter: 'isFile'}, grunt.config('parallel_spec_runner.' + grunt.task.current.target + '.options.excludedSpecs') || []), | ||
isolatedSpecs: grunt.file.expand({filter: 'isFile'}, grunt.config('parallel_spec_runner.' + grunt.task.current.target + '.options.isolatedSpecs') || []), | ||
specs: grunt.file.expand({filter: 'isFile'}, grunt.config('jasmine.options.specs') || []) | ||
}; | ||
if(config.excludedSpecs.length > 0){ | ||
config.specs = config.specs.filter(function(path){ | ||
var keep = config.excludedSpecs.indexOf(path) == -1; | ||
if(!keep){ | ||
if(options.excludedSpecs.length > 0){ | ||
options.specs = options.specs.filter(function(path){ | ||
if(options.excludedSpecs.indexOf(path) != -1){ | ||
grunt.verbose.writeln('Excluding spec: ' + path); | ||
return false; | ||
} | ||
return keep; | ||
return true; | ||
}); | ||
} | ||
//Use the user defined number of spec files per runner, or split the spec files among the available runners | ||
options.maxSpecFilesPerRunner = +grunt.option('maxSpecFilesPerRunner') > 0 ? +grunt.option('maxSpecFilesPerRunner') | ||
: Math.ceil(options.specs.length / options.maxSpecRunners); | ||
var done = this.async(), me = this; | ||
var specRunner = new SpecRunner(config), | ||
var specRunner = new SpecRunner(options), | ||
i = setInterval(function () { | ||
@@ -240,3 +231,3 @@ if (specRunner.isDone()) { | ||
done(me.errorCount == 0); | ||
if (config.keepalive) { | ||
if (options.keepalive) { | ||
grunt.task.run('express-keepalive'); | ||
@@ -243,0 +234,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
12343
294