Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/parallel_cucumber/formatters/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ var Formatter = function(options) {
self._out.write(data, 'utf8');
};

self._rewriteReport = function (data) {
if (options.outFilePath) {
FS.writeFile(options.outFilePath, data, function (err) {
if (err) {
throw err;
}
});
}
};

self.end = function(callback) {
if (self._outNeedsClosing) {
self._outNeedsClosing = false;
Expand Down
1 change: 1 addition & 0 deletions lib/parallel_cucumber/formatters/json_formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var JsonFormatter = function(options) {
Debug('New feature');
self._features.push(currentFeature);
}
self._rewriteReport(JSON.stringify(self._features));
};

self.end = function(callback) {
Expand Down
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() : [];
// If profile.tags is defined and not empty than split tags string into array
var tags = profile.tags && profile.tags[0] ? profile.tags[0].split(',') : [];
var env = profile.env || {};

env.PARALLEL_CUCUMBER_PROFILE = profileName;

function addTask() {
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) {
addTask();
} 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) {
addTask();
}
});
}
});
});
Expand Down