Skip to content

Trim paths from @rerun files #660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 23, 2016
Merged
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
18 changes: 18 additions & 0 deletions features/rerun_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,21 @@ Feature: Rerun Formatter
| A - ambiguous |
| B - pending |
| C - undefined |

Scenario: rerun file with trailing new line
Given a file named "@rerun.txt" with:
"""
features/c.feature:2

"""
When I run cucumber.js with `-f json @rerun.txt`
Then the exit status should be 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check which scenarios ran.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

And the json output has the scenarios with names
| NAME |
| C - passing |

Scenario: empty rerun file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change in behavior. Previously an empty rerun file also ran all the feature files in the current directory

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this change in functionality.

Given an empty file named "@rerun.txt"
When I run cucumber.js with `-f json @rerun.txt`
Then the exit status should be 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check that no scenarios run.

And the json output has no scenarios
5 changes: 5 additions & 0 deletions features/step_definitions/file_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ var cliSteps = function cliSteps() {
fsExtra.outputFile(absoluteFilePath, fileContent, callback);
});

this.Given(/^an empty file named "(.*)"$/, function(filePath, callback) {
var absoluteFilePath = path.join(this.tmpDir, filePath);
fsExtra.outputFile(absoluteFilePath, '', callback);
});

this.Given(/^a directory named "(.*)"$/, function(filePath, callback) {
var absoluteFilePath = path.join(this.tmpDir, filePath);
fsExtra.mkdirp(absoluteFilePath, callback);
Expand Down
13 changes: 13 additions & 0 deletions features/step_definitions/json_output_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ var jsonOutputSteps = function jsonOutputSteps() {
});
assert.deepEqual(expectedNames, actualNames);
});

this.Then(/^the json output has no scenarios$/, function () {
var features = JSON.parse(this.lastRun.stdout);
var hasScenario = false;
features.forEach(function(feature) {
feature.elements.forEach(function(element){
if (element.type === 'scenario') {
hasScenario = true;
}
});
});
assert.equal(false, hasScenario);
});

this.Then(/^the json output's first scenario has the description "([^"]*)"$/, function (description) {
var features = JSON.parse(this.lastRun.stdout);
Expand Down
3 changes: 2 additions & 1 deletion lib/cucumber/cli/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ function Configuration(options, args) {
var filename = path.basename(arg);
if (filename[0] === '@') {
var content = fs.readFileSync(arg, 'utf8');
unexpandedFeaturePaths = unexpandedFeaturePaths.concat(content.split('\n'));
var paths = _.chain(content).split('\n').map(_.trim).compact().value();
unexpandedFeaturePaths = unexpandedFeaturePaths.concat(paths);
} else {
unexpandedFeaturePaths.push(arg);
}
Expand Down