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

Fix gherkin-python for compiling example values with trailing backslash #2048

Merged
merged 5 commits into from
Aug 12, 2022
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 gherkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt

### Fixed

* [C] Fix gherkin-python for compiling example values with trailing backslash ([#2048](https://github.com/cucumber/common/pull/2048), [#1954](https://github.com/cucumber/common/issues/1954))
* [PHP] Disallow installation of Messages `18.x` ([#2034](https://github.com/cucumber/common/pull/2034))

## [24.0.0] - 2022-05-31
Expand Down
4 changes: 3 additions & 1 deletion gherkin/python/gherkin/pickles/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ def _interpolate(self, name, variable_cells, value_cells):

for n, variable_cell in enumerate(variable_cells):
value_cell = value_cells[n]
# For the case of trailing backslash, re-escaping backslashes are needed
reescaped_value = re.sub(r'\\', r'\\\\', value_cell['value'])
name = re.sub(
u'<{0[value]}>'.format(variable_cell),
value_cell['value'],
reescaped_value,
name
)
return name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Scenario Outline with values with trailing backslash

Scenario Outline: minimalistic
Given <what>
When <this>
Then <that>

Examples:
| what | this | that |
| x\\y | this\ | that\\ |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"gherkinDocument":{"comments":[],"feature":{"children":[{"scenario":{"description":"","examples":[{"description":"","id":"5","keyword":"Examples","location":{"column":1,"line":8},"name":"","tableBody":[{"cells":[{"location":{"column":5,"line":10},"value":"x\\y"},{"location":{"column":12,"line":10},"value":"this\\"},{"location":{"column":20,"line":10},"value":"that\\"}],"id":"4","location":{"column":3,"line":10}}],"tableHeader":{"cells":[{"location":{"column":5,"line":9},"value":"what"},{"location":{"column":12,"line":9},"value":"this"},{"location":{"column":20,"line":9},"value":"that"}],"id":"3","location":{"column":3,"line":9}},"tags":[]}],"id":"6","keyword":"Scenario Outline","location":{"column":1,"line":3},"name":"minimalistic","steps":[{"id":"0","keyword":"Given ","keywordType":"Context","location":{"column":5,"line":4},"text":"<what>"},{"id":"1","keyword":"When ","keywordType":"Action","location":{"column":5,"line":5},"text":"<this>"},{"id":"2","keyword":"Then ","keywordType":"Outcome","location":{"column":5,"line":6},"text":"<that>"}],"tags":[]}}],"description":"","keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"Scenario Outline with values with trailing backslash","tags":[]},"uri":"../testdata/good/scenario_outline_with_value_with_trailing_backslash.feature"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pickle":{"id":"8","uri":"../testdata/good/scenario_outline_with_value_with_trailing_backslash.feature","name":"minimalistic","language":"en","steps":[{"astNodeIds":["0","3"],"id":"6","type":"Action","text":"what\\"},{"astNodeIds":["1","3"],"id":"7","type":"Outcome","text":"that\\"}],"tags":[],"astNodeIds":["5","3"]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pickle":{"astNodeIds":["6","4"],"id":"10","language":"en","name":"minimalistic","steps":[{"astNodeIds":["0","4"],"id":"7","text":"x\\y","type":"Context"},{"astNodeIds":["1","4"],"id":"8","text":"this\\","type":"Action"},{"astNodeIds":["2","4"],"id":"9","text":"that\\","type":"Outcome"}],"tags":[],"uri":"../testdata/good/scenario_outline_with_value_with_trailing_backslash.feature"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"source":{"data":"Feature: Scenario Outline with values with trailing backslash\n\nScenario Outline: minimalistic\n Given <what>\n When <this>\n Then <that>\n\nExamples:\n | what | this | that |\n | x\\\\y | this\\ | that\\\\ |","mediaType":"text/x.cucumber.gherkin+plain","uri":"../testdata/good/scenario_outline_with_value_with_trailing_backslash.feature"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(1:1)FeatureLine:()Feature/Scenario Outline with values with trailing backslash/
(2:1)Empty://
(3:1)ScenarioLine:()Scenario Outline/minimalistic/
(4:5)StepLine:(Context)Given /<what>/
(5:5)StepLine:(Action)When /<this>/
(6:5)StepLine:(Outcome)Then /<that>/
(7:1)Empty://
(8:1)ExamplesLine:()Examples//
(9:3)TableRow://5:what,12:this,20:that
(10:3)TableRow://5:x\y,12:this\,20:that\
EOF