Skip to content
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

Empty rerun file exits running no scenarios (#1302) #1568

Merged
merged 8 commits into from
Jun 4, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO

* Progress bar formatter now reports total step count correctly ([#1579](https://github.com/cucumber/cucumber-js/issues/1579)
[#1669](https://github.com/cucumber/cucumber-js/pull/1669))
* Rerun functionality will now run nothing if the rerun file is empty from the previous run ([#1302](https://github.com/cucumber/cucumber-js/issues/1302) [#1568](https://github.com/cucumber/cucumber-js/pull/1568))
* All messages now emitted with project-relative `uri`s
([#1534](https://github.com/cucumber/cucumber-js/issues/1534)
[#1672](https://github.com/cucumber/cucumber-js/pull/1672))
Expand Down
14 changes: 3 additions & 11 deletions features/rerun_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,11 @@ Feature: Rerun Formatter
When I run cucumber-js with `@rerun.txt`
Then it runs the scenario "C - passing"

Scenario: empty rerun file
Scenario: empty rerun file exits without running any scenarios
Given an empty file named "@rerun.txt"
When I run cucumber-js with `@rerun.txt`
Then it fails
And it runs the scenarios:
| NAME |
| A - passing |
| A - failing |
| A - ambiguous |
| B - passing |
| B - pending |
| C - passing |
| C - undefined |
Then it passes
aurelien-reeves marked this conversation as resolved.
Show resolved Hide resolved
And it runs 0 scenarios

Scenario: rerun with fail fast outputs all skipped scenarios
When I run cucumber-js with `--fail-fast --format rerun:@rerun.txt`
Expand Down
4 changes: 2 additions & 2 deletions src/cli/configuration_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ export default class ConfigurationBuilder {
if (filename[0] === '@') {
const filePath = path.join(this.cwd, arg)
const content = await fs.readFile(filePath, 'utf8')
return _.chain(content).split('\n').map(_.trim).compact().value()
return _.chain(content).split('\n').map(_.trim).value()
}
return [arg]
})
const featurePaths = _.flatten(nestedFeaturePaths)
if (featurePaths.length > 0) {
return featurePaths
return _.compact(featurePaths)
aurelien-reeves marked this conversation as resolved.
Show resolved Hide resolved
}
}
return ['features/**/*.{feature,feature.md}']
Expand Down
72 changes: 72 additions & 0 deletions src/cli/configuration_builder_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,78 @@ describe('Configuration', () => {
})
})

describe('path to an empty rerun file', () => {
it('returns empty featurePaths and support code paths', async function () {
// Arrange
const cwd = await buildTestWorkingDirectory()

const relativeRerunPath = '@empty_rerun.txt'
const rerunPath = path.join(cwd, '@empty_rerun.txt')
await fsExtra.outputFile(rerunPath, '')
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
expect(pickleFilterOptions.featurePaths).to.eql([])
expect(supportCodePaths).to.eql([])
})
})

describe('path to an rerun file with new line', () => {
it('returns empty featurePaths and support code paths', async function () {
// Arrange
const cwd = await buildTestWorkingDirectory()

const relativeRerunPath = '@empty_rerun.txt'
const rerunPath = path.join(cwd, '@empty_rerun.txt')
await fsExtra.outputFile(rerunPath, '\n')
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
expect(pickleFilterOptions.featurePaths).to.eql([])
expect(supportCodePaths).to.eql([])
})
})

describe('path to a rerun file with one new line character', () => {
it('returns empty featurePaths and support code paths', async function () {
// Arrange
const cwd = await buildTestWorkingDirectory()

const relativeRerunPath = '@empty_rerun.txt'
const rerunPath = path.join(cwd, '@empty_rerun.txt')
await fsExtra.outputFile(rerunPath, '\n\n')
const argv = baseArgv.concat([relativeRerunPath])

// Act
const {
featurePaths,
pickleFilterOptions,
supportCodePaths,
} = await ConfigurationBuilder.build({ argv, cwd })

// Assert
expect(featurePaths).to.eql([])
expect(pickleFilterOptions.featurePaths).to.eql([])
expect(supportCodePaths).to.eql([])
})
})

describe('formatters', () => {
it('adds a default', async function () {
// Arrange
Expand Down
20 changes: 12 additions & 8 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,18 @@ export default class Cli {
relativeTo: this.cwd,
}
)
const pickleIds = await parseGherkinMessageStream({
cwd: this.cwd,
eventBroadcaster,
eventDataCollector,
gherkinMessageStream,
order: configuration.order,
pickleFilter: new PickleFilter(configuration.pickleFilterOptions),
})
let pickleIds: string[] = []

if (configuration.featurePaths.length > 0) {
pickleIds = await parseGherkinMessageStream({
cwd: this.cwd,
eventBroadcaster,
eventDataCollector,
gherkinMessageStream,
order: configuration.order,
pickleFilter: new PickleFilter(configuration.pickleFilterOptions),
})
}
emitSupportCodeMessages({
eventBroadcaster,
supportCodeLibrary,
Expand Down