Skip to content

Commit dc5ad70

Browse files
committed
Revert "cli: have gherkin emit uris relative to the cwd (#1672)"
This reverts commit 5a21c22.
1 parent cb25cbe commit dc5ad70

10 files changed

+17
-12
lines changed

CHANGELOG.md

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
2424

2525
### Fixed
2626

27-
* All messages now emitted with project-relative `uri`s
28-
([#1534](https://github.com/cucumber/cucumber-js/issues/1534)
29-
[#1672](https://github.com/cucumber/cucumber-js/pull/1672))
3027
* Json formatter now works with tagged examples
3128
([#1621](https://github.com/cucumber/cucumber-js/issues/1621)
3229
[#1651](https://github.com/cucumber/cucumber-js/pull/1651))

src/cli/helpers.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import _ from 'lodash'
22
import ArgvParser from './argv_parser'
33
import ProfileLoader from './profile_loader'
44
import shuffle from 'knuth-shuffle-seeded'
5+
import path from 'path'
56
import { EventEmitter } from 'events'
67
import PickleFilter from '../pickle_filter'
78
import { EventDataCollector } from '../formatter/helpers'
@@ -68,7 +69,10 @@ export async function parseGherkinMessageStream({
6869
if (doesHaveValue(envelope.parseError)) {
6970
reject(
7071
new Error(
71-
`Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`
72+
`Parse error in '${path.relative(
73+
cwd,
74+
envelope.parseError.source.uri
75+
)}': ${envelope.parseError.message}`
7276
)
7377
)
7478
}

src/cli/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ export default class Cli {
205205
{
206206
defaultDialect: configuration.featureDefaultLanguage,
207207
newId,
208-
relativeTo: this.cwd,
209208
}
210209
)
211210
const pickleIds = await parseGherkinMessageStream({

src/formatter/helpers/issue_helpers_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async function testFormatIssue(sourceData: string): Promise<string> {
1111
const sources = [
1212
{
1313
data: sourceData,
14-
uri: 'a.feature',
14+
uri: 'project/a.feature',
1515
},
1616
]
1717
const supportCodeLibrary = getBaseSupportCodeLibrary()

src/formatter/helpers/test_case_attempt_parser.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getGherkinStepMap,
66
} from './gherkin_document_parser'
77
import { getPickleStepMap, getStepKeyword } from './pickle_parser'
8+
import path from 'path'
89
import * as messages from '@cucumber/messages'
910
import { ITestCaseAttempt } from './event_data_collector'
1011
import StepDefinitionSnippetBuilder from '../step_definition_snippet_builder'
@@ -137,7 +138,7 @@ export function parseTestCaseAttempt({
137138
gherkinDocument
138139
)
139140
const pickleStepMap = getPickleStepMap(pickle)
140-
const relativePickleUri = pickle.uri
141+
const relativePickleUri = path.relative(cwd, pickle.uri)
141142
const parsedTestCase: IParsedTestCase = {
142143
attempt: testCaseAttempt.attempt,
143144
name: pickle.name,

src/formatter/helpers/usage_helpers/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash'
22
import { getPickleStepMap } from '../pickle_parser'
3+
import path from 'path'
34
import { getGherkinStepMap } from '../gherkin_document_parser'
45
import * as messages from '@cucumber/messages'
56
import StepDefinition from '../../../models/step_definition'
@@ -72,7 +73,7 @@ function buildMapping({
7273
const match: IUsageMatch = {
7374
line: gherkinStep.location.line,
7475
text: pickleStep.text,
75-
uri: testCaseAttempt.pickle.uri,
76+
uri: path.relative(cwd, testCaseAttempt.pickle.uri),
7677
}
7778
const { duration, status } = testCaseAttempt.stepResults[testStep.id]
7879
if (!unexecutedStatuses.includes(status) && doesHaveValue(duration)) {

src/formatter/json_formatter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import _ from 'lodash'
22
import Formatter, { IFormatterOptions } from './'
33
import { formatLocation, GherkinDocumentParser, PickleParser } from './helpers'
4+
import path from 'path'
45
import * as messages from '@cucumber/messages'
56
import {
67
getGherkinExampleRuleMap,
@@ -135,7 +136,7 @@ export default class JsonFormatter extends Formatter {
135136
this.eventDataCollector.getTestCaseAttempts(),
136137
(testCaseAttempt: ITestCaseAttempt) => {
137138
if (!testCaseAttempt.worstTestStepResult.willBeRetried) {
138-
const uri = testCaseAttempt.pickle.uri
139+
const uri = path.relative(this.cwd, testCaseAttempt.pickle.uri)
139140
if (doesNotHaveValue(groupedTestCaseAttempts[uri])) {
140141
groupedTestCaseAttempts[uri] = []
141142
}

src/formatter/rerun_formatter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash'
22
import Formatter, { IFormatterOptions } from './'
3+
import path from 'path'
34
import { getGherkinScenarioLocationMap } from './helpers/gherkin_document_parser'
45
import {
56
doesHaveValue,
@@ -36,7 +37,7 @@ export default class RerunFormatter extends Formatter {
3637
if (
3738
worstTestStepResult.status !== messages.TestStepResultStatus.PASSED
3839
) {
39-
const relativeUri = pickle.uri
40+
const relativeUri = path.relative(this.cwd, pickle.uri)
4041
const line = getGherkinScenarioLocationMap(gherkinDocument)[
4142
_.last(pickle.astNodeIds)
4243
].line

src/pickle_filter.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import _ from 'lodash'
2+
import path from 'path'
23
import parse from '@cucumber/tag-expressions'
34
import { getGherkinScenarioLocationMap } from './formatter/helpers/gherkin_document_parser'
45
import { doesHaveValue, doesNotHaveValue } from './value_checker'
@@ -72,7 +73,7 @@ export class PickleLineFilter {
7273
featurePaths.forEach((featurePath) => {
7374
const match = FEATURE_LINENUM_REGEXP.exec(featurePath)
7475
if (doesHaveValue(match)) {
75-
const uri = match[1]
76+
const uri = path.resolve(cwd, match[1])
7677
const linesExpression = match[2]
7778
if (doesHaveValue(linesExpression)) {
7879
if (doesNotHaveValue(mapping[uri])) {

src/pickle_filter_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('PickleFilter', () => {
9191
gherkinDocument,
9292
} = await parse({
9393
data: ['Feature: a', '', 'Scenario: b', 'Given a step'].join('\n'),
94-
uri: 'features/b.feature',
94+
uri: path.resolve(cwd, 'features/b.feature'),
9595
})
9696

9797
// Act

0 commit comments

Comments
 (0)