Skip to content

Commit

Permalink
Task formation algorithm was fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkNaumenko committed Jun 20, 2018
1 parent 6449387 commit 3bf66d0
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions lib/parallel_cucumber/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,34 +225,39 @@ var Runtime = function (configuration) {
self._getFeatureFileObjects(featureFilePath).forEach(function (featureFile) {
Object.keys(options.profiles).forEach(function (profileName) {
var profile = options.profiles[profileName];
// Clone the array using slice()
var tags = profile.tags ? profile.tags.slice() : [];
// Divide a tag string into array elements if it exists
var tags = profile.tags && profile.tags[0] ? profile.tags[0].split(',') : [];
var env = profile.env || {};

env.PARALLEL_CUCUMBER_PROFILE = profileName;

function createAndPushTask() {
tasks.push({
taskIndex: taskCount++,
profileName: profileName,
featureFilePath: featureFile.path,
supportCodePaths: options.supportCodePaths,
tags: profile.tags || [],
env: env,
retryCount: 0
});
}

var matchTags = true;
tags.forEach(function (tag) {
if (matchTags) {
if (tags.length === 0) {
createAndPushTask();
} else {
tags.forEach(function (tag) {
if (tag.indexOf('~') === 0) {
matchTags = featureFile.tags.indexOf(tag.substring(1)) === -1;
}
else {
matchTags = featureFile.tags.indexOf(tag) > -1;
}
}
});
if (matchTags) {
var task = {
taskIndex: taskCount++,
profileName: profileName,
featureFilePath: featureFile.path,
supportCodePaths: options.supportCodePaths,
tags: tags,
env: env,
retryCount: 0
};
tasks.push(task);
if (matchTags) {
createAndPushTask();
}
});
}
});
});
Expand Down

0 comments on commit 3bf66d0

Please sign in to comment.