Skip to content

Commit 4d189c7

Browse files
authored
debt: remove --predictable-ids option (#1801)
* WIP * fix up testing * add changelog entry
1 parent d6615ec commit 4d189c7

13 files changed

+43
-64
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ See the [migration guide](./docs/migration.md) for details of how to migrate fro
1616
* Drop support for Node.js 10 and 15, add support for Node.js 16
1717
* Remove deprecated `--retryTagFilter` option (the correct option is `--retry-tag-filter`)
1818
* Remove `setDefinitionFunctionWrapper` and step definition option `wrapperOptions`
19+
* Remove `--predictable-ids` option (was only used for internal testing)
1920

2021
### Added
2122

compatibility/cck_spec.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import path from 'path'
77
import { PassThrough, pipeline, Writable } from 'stream'
88
import { Cli } from '../src'
99
import toString from 'stream-to-string'
10-
import { normalizeMessageOutput } from '../features/support/formatter_output_helpers'
10+
import {
11+
ignorableKeys,
12+
normalizeMessageOutput,
13+
} from '../features/support/formatter_output_helpers'
1114
import * as messages from '@cucumber/messages'
1215
import * as messageStreams from '@cucumber/message-streams'
1316
import util from 'util'
@@ -74,28 +77,7 @@ describe('Cucumber Compatibility Kit', () => {
7477
)
7578

7679
expect(actualMessages)
77-
.excludingEvery([
78-
'meta',
79-
// sources
80-
'uri',
81-
'line',
82-
// ids
83-
'astNodeId',
84-
'astNodeIds',
85-
'hookId',
86-
'id',
87-
'pickleId',
88-
'pickleStepId',
89-
'stepDefinitionIds',
90-
'testCaseId',
91-
'testCaseStartedId',
92-
'testStepId',
93-
// time
94-
'nanos',
95-
'seconds',
96-
// errors
97-
'message',
98-
])
80+
.excludingEvery(ignorableKeys)
9981
.to.deep.eq(expectedMessages)
10082
})
10183
})

features/step_definitions/formatter_steps.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Then } from '../../'
2-
import { expect } from 'chai'
2+
import { expect, use } from 'chai'
3+
import chaiExclude from 'chai-exclude'
34
import {
5+
ignorableKeys,
46
normalizeJsonOutput,
57
normalizeMessageOutput,
68
stripMetaMessages,
@@ -9,6 +11,8 @@ import fs from 'mz/fs'
911
import path from 'path'
1012
import { World } from '../support/world'
1113

14+
use(chaiExclude)
15+
1216
Then(
1317
'the message formatter output matches the fixture {string}',
1418
async function (this: World, filePath: string) {
@@ -18,7 +22,7 @@ Then(
1822
const fixturePath = path.join(__dirname, '..', 'fixtures', filePath)
1923
const expected = require(fixturePath) // eslint-disable-line @typescript-eslint/no-var-requires
2024
try {
21-
expect(actual).to.eql(expected)
25+
expect(actual).excludingEvery(ignorableKeys).to.deep.eq(expected)
2226
} catch (e) {
2327
if (process.env.GOLDEN) {
2428
await fs.writeFile(

features/support/formatter_output_helpers.ts

+23
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,26 @@ export function normalizeJsonOutput(str: string, cwd: string): IJsonFeature[] {
9696
})
9797
return json
9898
}
99+
100+
export const ignorableKeys = [
101+
'meta',
102+
// sources
103+
'uri',
104+
'line',
105+
// ids
106+
'astNodeId',
107+
'astNodeIds',
108+
'hookId',
109+
'id',
110+
'pickleId',
111+
'pickleStepId',
112+
'stepDefinitionIds',
113+
'testCaseId',
114+
'testCaseStartedId',
115+
'testStepId',
116+
// time
117+
'nanos',
118+
'seconds',
119+
// errors
120+
'message',
121+
]

features/support/world.ts

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class World {
5858
const messageFilename = 'message.ndjson'
5959
const args = ['node', executablePath].concat(inputArgs, [
6060
'--backtrace',
61-
'--predictable-ids',
6261
'--format',
6362
`message:${messageFilename}`,
6463
])

src/cli/argv_parser.ts

-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export interface IParsedArgvOptions {
3232
name: string[]
3333
order: string
3434
parallel: number
35-
predictableIds: boolean
3635
profile: string[]
3736
publish: boolean
3837
publishQuiet: boolean
@@ -167,11 +166,6 @@ const ArgvParser = {
167166
(val) => ArgvParser.validateCountOption(val, '--parallel'),
168167
0
169168
)
170-
.option(
171-
'--predictable-ids',
172-
'Use predictable ids in messages (option ignored if using parallel)',
173-
false
174-
)
175169
.option(
176170
'--publish',
177171
'Publish a report to https://reports.cucumber.io',

src/cli/configuration_builder.ts

-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export interface IConfiguration {
2727
order: string
2828
parallel: number
2929
pickleFilterOptions: IPickleFilterOptions
30-
predictableIds: boolean
3130
profiles: string[]
3231
runtimeOptions: IRuntimeOptions
3332
shouldExitImmediately: boolean
@@ -95,11 +94,9 @@ export default class ConfigurationBuilder {
9594
names: this.options.name,
9695
tagExpression: this.options.tags,
9796
},
98-
predictableIds: this.options.predictableIds,
9997
profiles: this.options.profile,
10098
runtimeOptions: {
10199
dryRun: this.options.dryRun,
102-
predictableIds: this.options.predictableIds,
103100
failFast: this.options.failFast,
104101
filterStacktraces: !this.options.backtrace,
105102
retry: this.options.retry,

src/cli/configuration_builder_spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ describe('Configuration', () => {
4545
tagExpression: '',
4646
},
4747
profiles: [],
48-
predictableIds: false,
4948
runtimeOptions: {
5049
dryRun: false,
5150
failFast: false,
5251
filterStacktraces: true,
53-
predictableIds: false,
5452
retry: 0,
5553
retryTagFilter: '',
5654
strict: true,

src/cli/index.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { pathToFileURL } from 'url'
3333

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

3838
export interface ICliRunResult {
3939
shouldExitImmediately: boolean
@@ -182,10 +182,7 @@ export default class Cli {
182182
this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))
183183
return { shouldExitImmediately: true, success: true }
184184
}
185-
const newId =
186-
configuration.predictableIds && configuration.parallel <= 1
187-
? incrementing()
188-
: uuid()
185+
const newId = uuid()
189186
const supportCodeLibrary = await this.getSupportCodeLibrary({
190187
newId,
191188
supportCodePaths: configuration.supportCodePaths,

src/runtime/index.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import { EventEmitter } from 'events'
1010
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
1111
import TestRunHookDefinition from '../models/test_run_hook_definition'
1212
import { doesHaveValue, valueOrDefault } from '../value_checker'
13-
import {
14-
ITestRunStopwatch,
15-
PredictableTestRunStopwatch,
16-
RealTestRunStopwatch,
17-
} from './stopwatch'
13+
import { ITestRunStopwatch, RealTestRunStopwatch } from './stopwatch'
1814
import { assembleTestCases } from './assemble_test_cases'
1915

2016
export interface INewRuntimeOptions {
@@ -28,7 +24,6 @@ export interface INewRuntimeOptions {
2824

2925
export interface IRuntimeOptions {
3026
dryRun: boolean
31-
predictableIds: boolean
3227
failFast: boolean
3328
filterStacktraces: boolean
3429
retry: number
@@ -58,9 +53,7 @@ export default class Runtime {
5853
}: INewRuntimeOptions) {
5954
this.eventBroadcaster = eventBroadcaster
6055
this.eventDataCollector = eventDataCollector
61-
this.stopwatch = options.predictableIds
62-
? new PredictableTestRunStopwatch()
63-
: new RealTestRunStopwatch()
56+
this.stopwatch = new RealTestRunStopwatch()
6457
this.newId = newId
6558
this.options = options
6659
this.pickleIds = pickleIds

src/runtime/parallel/coordinator.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import { IRuntimeOptions } from '..'
88
import { ISupportCodeLibrary } from '../../support_code_library_builder/types'
99
import { ICoordinatorReport, IWorkerCommand } from './command_types'
1010
import { doesHaveValue } from '../../value_checker'
11-
import {
12-
ITestRunStopwatch,
13-
PredictableTestRunStopwatch,
14-
RealTestRunStopwatch,
15-
} from '../stopwatch'
11+
import { ITestRunStopwatch, RealTestRunStopwatch } from '../stopwatch'
1612
import { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'
1713
import { IdGenerator } from '@cucumber/messages'
1814

@@ -66,9 +62,7 @@ export default class Coordinator {
6662
this.cwd = cwd
6763
this.eventBroadcaster = eventBroadcaster
6864
this.eventDataCollector = eventDataCollector
69-
this.stopwatch = options.predictableIds
70-
? new PredictableTestRunStopwatch()
71-
: new RealTestRunStopwatch()
65+
this.stopwatch = new RealTestRunStopwatch()
7266
this.options = options
7367
this.newId = newId
7468
this.supportCodeLibrary = supportCodeLibrary

src/runtime/parallel/worker.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TestRunHookDefinition from '../../models/test_run_hook_definition'
1616
import { ISupportCodeLibrary } from '../../support_code_library_builder/types'
1717
import { doesHaveValue, valueOrDefault } from '../../value_checker'
1818
import { IRuntimeOptions } from '../index'
19-
import { PredictableTestRunStopwatch, RealTestRunStopwatch } from '../stopwatch'
19+
import { RealTestRunStopwatch } from '../stopwatch'
2020
import { duration } from 'durations'
2121
import { pathToFileURL } from 'url'
2222

@@ -126,9 +126,7 @@ export default class Worker {
126126
retries,
127127
skip,
128128
}: IWorkerCommandRun): Promise<void> {
129-
const stopwatch = this.options.predictableIds
130-
? new PredictableTestRunStopwatch()
131-
: new RealTestRunStopwatch()
129+
const stopwatch = new RealTestRunStopwatch()
132130
stopwatch.from(duration(elapsed))
133131
const testCaseRunner = new TestCaseRunner({
134132
eventBroadcaster: this.eventBroadcaster,

test/runtime_helpers.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export function buildOptions(
1212
): IRuntimeOptions {
1313
return {
1414
dryRun: false,
15-
predictableIds: false,
1615
failFast: false,
1716
filterStacktraces: false,
1817
retry: 0,

0 commit comments

Comments
 (0)