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

debt: remove --predictable-ids option #1801

Merged
merged 4 commits into from
Sep 28, 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 @@ -16,6 +16,7 @@ See the [migration guide](./docs/migration.md) for details of how to migrate fro
* Drop support for Node.js 10 and 15, add support for Node.js 16
* Remove deprecated `--retryTagFilter` option (the correct option is `--retry-tag-filter`)
* Remove `setDefinitionFunctionWrapper` and step definition option `wrapperOptions`
* Remove `--predictable-ids` option (was only used for internal testing)

### Added

Expand Down
28 changes: 5 additions & 23 deletions compatibility/cck_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import path from 'path'
import { PassThrough, pipeline, Writable } from 'stream'
import { Cli } from '../src'
import toString from 'stream-to-string'
import { normalizeMessageOutput } from '../features/support/formatter_output_helpers'
import {
ignorableKeys,
normalizeMessageOutput,
} from '../features/support/formatter_output_helpers'
import * as messages from '@cucumber/messages'
import * as messageStreams from '@cucumber/message-streams'
import util from 'util'
Expand Down Expand Up @@ -74,28 +77,7 @@ describe('Cucumber Compatibility Kit', () => {
)

expect(actualMessages)
.excludingEvery([
'meta',
// sources
'uri',
'line',
// ids
'astNodeId',
'astNodeIds',
'hookId',
'id',
'pickleId',
'pickleStepId',
'stepDefinitionIds',
'testCaseId',
'testCaseStartedId',
'testStepId',
// time
'nanos',
'seconds',
// errors
'message',
])
.excludingEvery(ignorableKeys)
.to.deep.eq(expectedMessages)
})
})
Expand Down
8 changes: 6 additions & 2 deletions features/step_definitions/formatter_steps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Then } from '../../'
import { expect } from 'chai'
import { expect, use } from 'chai'
import chaiExclude from 'chai-exclude'
import {
ignorableKeys,
normalizeJsonOutput,
normalizeMessageOutput,
stripMetaMessages,
Expand All @@ -9,6 +11,8 @@ import fs from 'mz/fs'
import path from 'path'
import { World } from '../support/world'

use(chaiExclude)

Then(
'the message formatter output matches the fixture {string}',
async function (this: World, filePath: string) {
Expand All @@ -18,7 +22,7 @@ Then(
const fixturePath = path.join(__dirname, '..', 'fixtures', filePath)
const expected = require(fixturePath) // eslint-disable-line @typescript-eslint/no-var-requires
try {
expect(actual).to.eql(expected)
expect(actual).excludingEvery(ignorableKeys).to.deep.eq(expected)
} catch (e) {
if (process.env.GOLDEN) {
await fs.writeFile(
Expand Down
23 changes: 23 additions & 0 deletions features/support/formatter_output_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,26 @@ export function normalizeJsonOutput(str: string, cwd: string): IJsonFeature[] {
})
return json
}

export const ignorableKeys = [
'meta',
// sources
'uri',
'line',
// ids
'astNodeId',
'astNodeIds',
'hookId',
'id',
'pickleId',
'pickleStepId',
'stepDefinitionIds',
'testCaseId',
'testCaseStartedId',
'testStepId',
// time
'nanos',
'seconds',
// errors
'message',
]
1 change: 0 additions & 1 deletion features/support/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export class World {
const messageFilename = 'message.ndjson'
const args = ['node', executablePath].concat(inputArgs, [
'--backtrace',
'--predictable-ids',
'--format',
`message:${messageFilename}`,
])
Expand Down
6 changes: 0 additions & 6 deletions src/cli/argv_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface IParsedArgvOptions {
name: string[]
order: string
parallel: number
predictableIds: boolean
profile: string[]
publish: boolean
publishQuiet: boolean
Expand Down Expand Up @@ -167,11 +166,6 @@ const ArgvParser = {
(val) => ArgvParser.validateCountOption(val, '--parallel'),
0
)
.option(
'--predictable-ids',
'Use predictable ids in messages (option ignored if using parallel)',
false
)
.option(
'--publish',
'Publish a report to https://reports.cucumber.io',
Expand Down
3 changes: 0 additions & 3 deletions src/cli/configuration_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface IConfiguration {
order: string
parallel: number
pickleFilterOptions: IPickleFilterOptions
predictableIds: boolean
profiles: string[]
runtimeOptions: IRuntimeOptions
shouldExitImmediately: boolean
Expand Down Expand Up @@ -95,11 +94,9 @@ export default class ConfigurationBuilder {
names: this.options.name,
tagExpression: this.options.tags,
},
predictableIds: this.options.predictableIds,
profiles: this.options.profile,
runtimeOptions: {
dryRun: this.options.dryRun,
predictableIds: this.options.predictableIds,
failFast: this.options.failFast,
filterStacktraces: !this.options.backtrace,
retry: this.options.retry,
Expand Down
2 changes: 0 additions & 2 deletions src/cli/configuration_builder_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ describe('Configuration', () => {
tagExpression: '',
},
profiles: [],
predictableIds: false,
runtimeOptions: {
dryRun: false,
failFast: false,
filterStacktraces: true,
predictableIds: false,
retry: 0,
retryTagFilter: '',
strict: true,
Expand Down
7 changes: 2 additions & 5 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { pathToFileURL } from 'url'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { importer } = require('../importer')
const { incrementing, uuid } = IdGenerator
const { uuid } = IdGenerator

export interface ICliRunResult {
shouldExitImmediately: boolean
Expand Down Expand Up @@ -182,10 +182,7 @@ export default class Cli {
this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))
return { shouldExitImmediately: true, success: true }
}
const newId =
configuration.predictableIds && configuration.parallel <= 1
? incrementing()
: uuid()
const newId = uuid()
const supportCodeLibrary = await this.getSupportCodeLibrary({
newId,
supportCodePaths: configuration.supportCodePaths,
Expand Down
11 changes: 2 additions & 9 deletions src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import { EventEmitter } from 'events'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import TestRunHookDefinition from '../models/test_run_hook_definition'
import { doesHaveValue, valueOrDefault } from '../value_checker'
import {
ITestRunStopwatch,
PredictableTestRunStopwatch,
RealTestRunStopwatch,
} from './stopwatch'
import { ITestRunStopwatch, RealTestRunStopwatch } from './stopwatch'
import { assembleTestCases } from './assemble_test_cases'

export interface INewRuntimeOptions {
Expand All @@ -28,7 +24,6 @@ export interface INewRuntimeOptions {

export interface IRuntimeOptions {
dryRun: boolean
predictableIds: boolean
failFast: boolean
filterStacktraces: boolean
retry: number
Expand Down Expand Up @@ -58,9 +53,7 @@ export default class Runtime {
}: INewRuntimeOptions) {
this.eventBroadcaster = eventBroadcaster
this.eventDataCollector = eventDataCollector
this.stopwatch = options.predictableIds
? new PredictableTestRunStopwatch()
: new RealTestRunStopwatch()
this.stopwatch = new RealTestRunStopwatch()
this.newId = newId
this.options = options
this.pickleIds = pickleIds
Expand Down
10 changes: 2 additions & 8 deletions src/runtime/parallel/coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import { IRuntimeOptions } from '..'
import { ISupportCodeLibrary } from '../../support_code_library_builder/types'
import { ICoordinatorReport, IWorkerCommand } from './command_types'
import { doesHaveValue } from '../../value_checker'
import {
ITestRunStopwatch,
PredictableTestRunStopwatch,
RealTestRunStopwatch,
} from '../stopwatch'
import { ITestRunStopwatch, RealTestRunStopwatch } from '../stopwatch'
import { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'
import { IdGenerator } from '@cucumber/messages'

Expand Down Expand Up @@ -66,9 +62,7 @@ export default class Coordinator {
this.cwd = cwd
this.eventBroadcaster = eventBroadcaster
this.eventDataCollector = eventDataCollector
this.stopwatch = options.predictableIds
? new PredictableTestRunStopwatch()
: new RealTestRunStopwatch()
this.stopwatch = new RealTestRunStopwatch()
this.options = options
this.newId = newId
this.supportCodeLibrary = supportCodeLibrary
Expand Down
6 changes: 2 additions & 4 deletions src/runtime/parallel/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import TestRunHookDefinition from '../../models/test_run_hook_definition'
import { ISupportCodeLibrary } from '../../support_code_library_builder/types'
import { doesHaveValue, valueOrDefault } from '../../value_checker'
import { IRuntimeOptions } from '../index'
import { PredictableTestRunStopwatch, RealTestRunStopwatch } from '../stopwatch'
import { RealTestRunStopwatch } from '../stopwatch'
import { duration } from 'durations'
import { pathToFileURL } from 'url'

Expand Down Expand Up @@ -126,9 +126,7 @@ export default class Worker {
retries,
skip,
}: IWorkerCommandRun): Promise<void> {
const stopwatch = this.options.predictableIds
? new PredictableTestRunStopwatch()
: new RealTestRunStopwatch()
const stopwatch = new RealTestRunStopwatch()
stopwatch.from(duration(elapsed))
const testCaseRunner = new TestCaseRunner({
eventBroadcaster: this.eventBroadcaster,
Expand Down
1 change: 0 additions & 1 deletion test/runtime_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function buildOptions(
): IRuntimeOptions {
return {
dryRun: false,
predictableIds: false,
failFast: false,
filterStacktraces: false,
retry: 0,
Expand Down