From ea1790e889c0ac8d89f71db2c53663208cc248b6 Mon Sep 17 00:00:00 2001 From: Henk van den Brink Date: Tue, 30 Sep 2014 09:40:56 +0200 Subject: [PATCH] feat(config): Option to exclude test for specific capability Add the option to exclude spec files for a specific capability. This way you can ignore spec files for one capability only. For example if the test is known to fail in the capability. Closes #1230 --- docs/referenceConf.js | 2 +- lib/taskScheduler.js | 4 ++-- spec/unit/taskScheduler_test.js | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/referenceConf.js b/docs/referenceConf.js index fe78e19c1..2c606ab21 100644 --- a/docs/referenceConf.js +++ b/docs/referenceConf.js @@ -111,7 +111,7 @@ exports.config = { // Additional spec files to be run on this capability only. specs: ['spec/chromeOnlySpec.js'], - //Exclude spec files for this capability. + // Spec files to be excluded on this capability only. exclude: ['spec/doNotRunInChromeSpec.js'] }, diff --git a/lib/taskScheduler.js b/lib/taskScheduler.js index 703dca990..2ba64b78b 100644 --- a/lib/taskScheduler.js +++ b/lib/taskScheduler.js @@ -55,11 +55,11 @@ var TaskScheduler = function(config) { capabilitySpecs = capabilitySpecs.concat(capabilitySpecificSpecs); } - if(capability.exclude) { + if (capability.exclude) { var capabilitySpecExcludes = ConfigParser.resolveFilePatterns( capability.exclude, true, config.configDir); capabilitySpecs = ConfigParser.resolveFilePatterns( - capabilitySpecs).filter(function (path) { + capabilitySpecs).filter(function(path) { return capabilitySpecExcludes.indexOf(path) < 0; }); } diff --git a/spec/unit/taskScheduler_test.js b/spec/unit/taskScheduler_test.js index f80bb7b47..034f68bf4 100644 --- a/spec/unit/taskScheduler_test.js +++ b/spec/unit/taskScheduler_test.js @@ -221,4 +221,26 @@ describe('the task scheduler', function() { expect(scheduler.numTasksRemaining()).toEqual(0); }); + + it('should exclude capability-specific specs', function() { + var toAdd = { + specs: [ + 'spec/unit/data/fakespecA.js', + 'spec/unit/data/fakespecB.js' + ], + multiCapabilities: [{ + 'browserName': 'chrome', + exclude: 'spec/unit/data/fakespecB.js' + }] + }; + var config = new ConfigParser().addConfig(toAdd).getConfig(); + var scheduler = new TaskScheduler(config); + + var task = scheduler.nextTask(); + expect(task.capability.browserName).toEqual('chrome'); + expect(task.specs.length).toEqual(1); + + expect(scheduler.numTasksRemaining()).toEqual(0); + }); + });