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

Remove Runtime and other deprecated exports #2420

Merged
merged 4 commits into from
Aug 21, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber.

## [Unreleased]
### Removed
- BREAKING CHANGE: Remove previously-deprecated `parseGherkinMessageStream` ([#2420](https://github.com/cucumber/cucumber-js/pull/2420))
- BREAKING CHANGE: Remove previously-deprecated `PickleFilter` ([#2420](https://github.com/cucumber/cucumber-js/pull/2420))
- BREAKING CHANGE: Remove previously-deprecated `Runtime` ([#2420](https://github.com/cucumber/cucumber-js/pull/2420))

## [10.9.0] - 2024-08-13
### Added
Expand Down
10 changes: 10 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [changelog](./CHANGELOG.md).

## 11.0.0

### `parseGherkinMessageStream` and `PickleFilter`

`parseGherkinMessageStream` was a way to process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids. The `PickleFilter` class was used to provide a filter to the aforementioned function. These interfaces included internal implementation details from Cucumber which were difficult to assemble. To adapt, pivot to the `loadSources` function from the [JavaScript API](./docs/javascript_api.md), or raise an issue if you feel your use case isn't catered for.

### `Runtime`

The `Runtime` class was used internally to represent an instance of the serial test case runner. Its interface included internal implementation details from Cucumber which were difficult to assemble. To adapt, pivot to the `runCucumber` function from the [JavaScript API](./docs/javascript_api.md), or raise an issue if you feel your use case isn't catered for.

## 10.0.0

### Configuration files
Expand Down
24 changes: 0 additions & 24 deletions docs/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,6 @@ The `Cli` class is used internally to represent an instance of the command-line

To adapt, pivot to the `runCucumber` function from the [JavaScript API](./javascript_api.md), or raise an issue if you feel your use case isn't catered for.

### `parseGherkinMessageStream`

Deprecated in `8.0.0`, will be removed in `10.0.0` or later.

`parseGherkinMessageStream` is a way to process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids. Its interface includes internal implementation details from Cucumber which are difficult to assemble.

To adapt, pivot to the `loadSources` function from the [JavaScript API](./javascript_api.md), or raise an issue if you feel your use case isn't catered for.

### `PickleFilter`

Deprecated in `8.7.0`, will be removed in `10.0.0` or later.

The `PickleFilter` class is used to provide a filter to the `parseGherkinMessageStream` function above.

To adapt, pivot to the `loadSources` function from the [JavaScript API](./javascript_api.md), or raise an issue if you feel your use case isn't catered for.

### `Runtime`

Deprecated in `8.7.0`, will be removed in `10.0.0` or later.

The `Runtime` class is used internally to represent an instance of the serial test case runner. Its interface includes internal implementation details from Cucumber which are difficult to assemble.

To adapt, pivot to the `runCucumber` function from the [JavaScript API](./javascript_api.md), or raise an issue if you feel your use case isn't catered for.

### publishQuiet

Deprecated in `9.4.0`. Will be removed in `11.0.0` or later.
Expand Down
43 changes: 0 additions & 43 deletions exports/root/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,40 +259,6 @@ interface IGetStepKeywordRequest {
pickleStep: messages.PickleStep;
}

// @public (undocumented)
export interface INewRuntimeOptions {
// (undocumented)
eventBroadcaster: EventEmitter;
// (undocumented)
eventDataCollector: EventDataCollector;
// (undocumented)
newId: IdGenerator.NewId;
// (undocumented)
options: IRuntimeOptions;
// (undocumented)
pickleIds: string[];
// (undocumented)
supportCodeLibrary: SupportCodeLibrary;
}

// @public (undocumented)
export interface IRuntimeOptions {
// (undocumented)
dryRun: boolean;
// (undocumented)
failFast: boolean;
// (undocumented)
filterStacktraces: boolean;
// (undocumented)
retry: number;
// (undocumented)
retryTagFilter: string;
// (undocumented)
strict: boolean;
// (undocumented)
worldParameters: JsonObject;
}

// @public (undocumented)
function isFailure(result: messages.TestStepResult, willBeRetried?: boolean): boolean;

Expand Down Expand Up @@ -406,15 +372,9 @@ declare namespace parallelCanAssignHelpers {
}
export { parallelCanAssignHelpers }

// @public @deprecated (undocumented)
export const parseGherkinMessageStream: typeof cliHelpers.parseGherkinMessageStream;

// @public (undocumented)
function parseTestCaseAttempt({ testCaseAttempt, snippetBuilder, supportCodeLibrary, }: IParseTestCaseAttemptRequest): IParsedTestCaseAttempt;

// @public @deprecated (undocumented)
export const PickleFilter: typeof PickleFilter_2;

declare namespace PickleParser {
export {
getScenarioDescription,
Expand Down Expand Up @@ -451,9 +411,6 @@ export class RerunFormatter extends Formatter {
protected readonly separator: string;
}

// @public @deprecated (undocumented)
export const Runtime: typeof Runtime_2;

// @public (undocumented)
export const setDefaultTimeout: (milliseconds: number) => void;

Expand Down
52 changes: 0 additions & 52 deletions src/cli/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { EventEmitter } from 'node:events'
import { Readable } from 'node:stream'
import os from 'node:os'
import shuffle from 'knuth-shuffle-seeded'
import * as messages from '@cucumber/messages'
import { IdGenerator } from '@cucumber/messages'
import detectCiEnvironment from '@cucumber/ci-environment'
import { doesHaveValue } from '../value_checker'
import { EventDataCollector } from '../formatter/helpers'
import PickleFilter from '../pickle_filter'
import { SupportCodeLibrary } from '../support_code_library_builder/types'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
Expand All @@ -16,54 +12,6 @@ import { ILogger } from '../logger'
import { ILineAndUri } from '../types'
import { IPickleOrder } from '../filter'

interface IParseGherkinMessageStreamRequest {
cwd?: string
eventBroadcaster: EventEmitter
eventDataCollector: EventDataCollector
gherkinMessageStream: Readable
order: string
pickleFilter: PickleFilter
}

/**
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
*
* @param eventBroadcaster
* @param eventDataCollector
* @param gherkinMessageStream
* @param order
* @param pickleFilter
*/
export async function parseGherkinMessageStream({
eventBroadcaster,
eventDataCollector,
gherkinMessageStream,
order,
pickleFilter,
}: IParseGherkinMessageStreamRequest): Promise<string[]> {
return await new Promise<string[]>((resolve, reject) => {
const result: string[] = []
gherkinMessageStream.on('data', (envelope: messages.Envelope) => {
eventBroadcaster.emit('envelope', envelope)
if (doesHaveValue(envelope.pickle)) {
const pickle = envelope.pickle
const pickleId = pickle.id
const gherkinDocument = eventDataCollector.getGherkinDocument(
pickle.uri
)
if (pickleFilter.matches({ gherkinDocument, pickle })) {
result.push(pickleId)
}
}
})
gherkinMessageStream.on('end', () => {
orderPickles(result, order as IPickleOrder, console)
resolve(result)
})
gherkinMessageStream.on('error', reject)
})
}

// Orders the pickleIds in place - morphs input
export function orderPickles<T = string>(
pickleIds: T[],
Expand Down
160 changes: 2 additions & 158 deletions src/cli/helpers_spec.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,24 @@
import { EventEmitter } from 'node:events'
import { Readable } from 'node:stream'
import { GherkinStreams } from '@cucumber/gherkin-streams'
import * as messages from '@cucumber/messages'
import { IdGenerator, SourceMediaType } from '@cucumber/messages'
import { IdGenerator } from '@cucumber/messages'
import { expect } from 'chai'
import { describe, it } from 'mocha'
import {
CucumberExpression,
ParameterType,
RegularExpression,
} from '@cucumber/cucumber-expressions'
import { EventDataCollector } from '../formatter/helpers'
import PickleFilter from '../pickle_filter'
import StepDefinition from '../models/step_definition'
import { SupportCodeLibrary } from '../support_code_library_builder/types'
import TestCaseHookDefinition from '../models/test_case_hook_definition'
import TestRunHookDefinition from '../models/test_run_hook_definition'
import { SourcedParameterTypeRegistry } from '../support_code_library_builder/sourced_parameter_type_registry'
import { IPickleOrder } from '../api'
import {
emitMetaMessage,
emitSupportCodeMessages,
parseGherkinMessageStream,
} from './helpers'
import { emitMetaMessage, emitSupportCodeMessages } from './helpers'

const noopFunction = (): void => {
// no code
}

interface ITestParseGherkinMessageStreamRequest {
gherkinMessageStream: Readable
order: IPickleOrder
pickleFilter: PickleFilter
}

interface ITestParseGherkinMessageStreamResponse {
envelopes: messages.Envelope[]
result: string[]
}

async function testParseGherkinMessageStream(
options: ITestParseGherkinMessageStreamRequest
): Promise<ITestParseGherkinMessageStreamResponse> {
const envelopes: messages.Envelope[] = []
const eventBroadcaster = new EventEmitter()
eventBroadcaster.on('envelope', (e) => envelopes.push(e))
const eventDataCollector = new EventDataCollector(eventBroadcaster)
const result = await parseGherkinMessageStream({
eventBroadcaster,
eventDataCollector,
gherkinMessageStream: options.gherkinMessageStream,
order: options.order,
pickleFilter: options.pickleFilter,
})
return { envelopes, result }
}

function testEmitSupportCodeMessages(
supportCode: Partial<SupportCodeLibrary>
): messages.Envelope[] {
Expand Down Expand Up @@ -373,123 +336,4 @@ describe('helpers', () => {
expect(envelopes).to.deep.eq(expectedEnvelopes)
})
})
describe('parseGherkinMessageStream', () => {
describe('empty feature', () => {
it('emits source and gherkinDocument events and returns an empty array', async function () {
// Arrange
const cwd = '/project'
const sourceEnvelope: messages.Envelope = {
source: {
data: '',
mediaType: SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN,
uri: '/project/features/a.feature',
},
}
const gherkinMessageStream = GherkinStreams.fromSources(
[sourceEnvelope],
{}
)
const order = 'defined'
const pickleFilter = new PickleFilter({ cwd })

// Act
const { envelopes, result } = await testParseGherkinMessageStream({
gherkinMessageStream,
order,
pickleFilter,
})

// Assert
expect(result).to.eql([])
expect(envelopes).to.have.lengthOf(2)
expect(envelopes[0]).to.eql(sourceEnvelope)
expect(envelopes[1].gherkinDocument).to.exist()
expect(envelopes[1].gherkinDocument).to.have.keys([
'comments',
'feature',
'uri',
])
})
})

describe('feature with scenario that does not match the filter', () => {
it('emits pickle event and returns an empty array', async function () {
// Arrange
const cwd = '/project'
const sourceEnvelope: messages.Envelope = {
source: {
data: '@tagA\nFeature: a\nScenario: b\nGiven a step',
mediaType: SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN,
uri: '/project/features/a.feature',
},
}
const gherkinMessageStream = GherkinStreams.fromSources(
[sourceEnvelope],
{}
)
const order = 'defined'
const pickleFilter = new PickleFilter({
cwd,
tagExpression: 'not @tagA',
})

// Act
const { envelopes, result } = await testParseGherkinMessageStream({
gherkinMessageStream,
order,
pickleFilter,
})

// Assert
expect(result).to.eql([])
expect(envelopes).to.have.lengthOf(3)
expect(envelopes[0]).to.eql(sourceEnvelope)
expect(envelopes[1].gherkinDocument).to.exist()
expect(envelopes[2].pickle).to.exist()
expect(envelopes[2].pickle).to.have.keys([
'astNodeIds',
'id',
'language',
'name',
'steps',
'tags',
'uri',
])
})
})

describe('feature with scenario that matches the filter', () => {
it('emits pickle and returns the pickleId', async function () {
// Arrange
const cwd = '/project'
const sourceEnvelope: messages.Envelope = {
source: {
data: 'Feature: a\nScenario: b\nGiven a step',
mediaType: SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN,
uri: '/project/features/a.feature',
},
}
const gherkinMessageStream = GherkinStreams.fromSources(
[sourceEnvelope],
{}
)
const order = 'defined'
const pickleFilter = new PickleFilter({ cwd })

// Act
const { envelopes, result } = await testParseGherkinMessageStream({
gherkinMessageStream,
order,
pickleFilter,
})

// Assert
expect(result).to.eql([envelopes[2].pickle.id])
expect(envelopes).to.have.lengthOf(3)
expect(envelopes[0]).to.eql(sourceEnvelope)
expect(envelopes[1].gherkinDocument).to.exist()
expect(envelopes[2].pickle).to.exist()
})
})
})
})
Loading
Loading