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

gherkin: Pass the content type of a docstring down into its pickle string form… #292

Merged
merged 3 commits into from Feb 10, 2018

Conversation

rjwittams
Copy link
Contributor

… for use in formatters.

Summary

Pass the content type of a docstring down into its pickle string form.
This allows formatters to use it.
This used to work in Cucumber 1.2.5.
A PR for cucumber-jvm accompanies this.

Details

Motivation and Context

cucumber/cucumber-jvm#1263
As suggested here by mpkorstanje , I am doing a PR against the mono repo.

How Has This Been Tested?

Added in a unit test - not sure if it should be moved.
Also not sure that Gson-ing pickles is expected - given camelCase vs snake_case.
Ran against my updated cucumber-jvm. Added a unit test there.
Verified that my json report processor which works with 1.2.5 picks up the docstrings.

Ran all tests in cucumber-jvm. Examples: Pax-Exam : Calculator Test is broken before and after the change due to a missing deployment I think.

Screenshots (if appropriate):

Types of changes

  • [x ] Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Adds a field to PickleString. Not sure if that gets serialised within this project.
Maintains the old constructor signature to avoid compile breaks. Could be deprecated.

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Not sure which if any docs should be updated - I think 1.2.5 preserved docs will now be correct.

@rjwittams
Copy link
Contributor Author

cucumber/cucumber-jvm#1265 <- this is the PR for cucumber-jvm

Rebase the docstrings pickle acceptance test data.
@rjwittams
Copy link
Contributor Author

rjwittams commented Oct 22, 2017

Discovered the make build tests - hadn't noticed before. Updated the acceptance tests data. Switched to use snake_case for the json object key as I assumed that was the convention.

@@ -152,7 +152,8 @@ private void compileScenarioOutline(List<Pickle> pickles, List<PickleStep> backg
result.add(
new PickleString(
pickleLocation(ds.getLocation()),
interpolate(ds.getContent(), variableCells, valueCells)
interpolate(ds.getContent(), variableCells, valueCells),
ds.getContentType()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also be interpolated?

@rjwittams
Copy link
Contributor Author

rjwittams commented Oct 22, 2017 via email

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be possible to do this:

Scenario: The parser accepts formatted text
Given some formatted  text 
"""<format>
<header>Hello world!<footer>
"""
Example:
 | format | header | footer|
 | html | <p> | </p> |
 | xml | <type:paragraph> | </type:paragraph> |

And while the content type is not passed onto the step definition, it might still be useful to the formatter to properly highlight xml or html.

Not a major use case I imagine but it also doesn't seem to hurt.

@mpkorstanje
Copy link
Contributor

We're on slack btw. https://cucumberbdd-slack-invite.herokuapp.com/ the #commiters-jvm channel.

@brasmusson brasmusson changed the title gherkin/java: Pass the content type of a docstring down into its pickle string form… gherkin: Pass the content type of a docstring down into its pickle string form… Oct 22, 2017
@@ -1 +1 @@
{"pickle":{"language":"en","locations":[{"column":3,"line":3}],"name":"minimalistic","steps":[{"arguments":[{"content":"first line (no indent)\n second line (indented with two spaces)\n\nthird line was empty","location":{"column":7,"line":5}}],"locations":[{"column":11,"line":4}],"text":"a simple DocString"},{"arguments":[{"content":"<foo>\n <bar />\n</foo>","location":{"column":7,"line":12}}],"locations":[{"column":11,"line":11}],"text":"a DocString with content type"},{"arguments":[{"content":"wrongly indented line","location":{"column":7,"line":18}}],"locations":[{"column":9,"line":17}],"text":"a DocString with wrong indentation"},{"arguments":[{"content":"first line\nsecond line","location":{"column":7,"line":22}}],"locations":[{"column":9,"line":21}],"text":"a DocString with alternative separator"},{"arguments":[{"content":"first line\n\"\"\"\nthird line","location":{"column":7,"line":27}}],"locations":[{"column":9,"line":26}],"text":"a DocString with normal separator inside"},{"arguments":[{"content":"first line\n```\nthird line","location":{"column":7,"line":33}}],"locations":[{"column":9,"line":32}],"text":"a DocString with alternative separator inside"},{"arguments":[{"content":"first line\n\"\"\"\nthird line","location":{"column":7,"line":39}}],"locations":[{"column":9,"line":38}],"text":"a DocString with escaped separator inside"}],"tags":[]},"type":"pickle","uri":"testdata/good/docstrings.feature"}
{"pickle":{"language":"en","locations":[{"column":3,"line":3}],"name":"minimalistic","steps":[{"arguments":[{"content":"first line (no indent)\n second line (indented with two spaces)\n\nthird line was empty","location":{"column":7,"line":5}}],"locations":[{"column":11,"line":4}],"text":"a simple DocString"},{"arguments":[{"content":"<foo>\n <bar />\n</foo>","content_type":"xml","location":{"column":7,"line":12}}],"locations":[{"column":11,"line":11}],"text":"a DocString with content type"},{"arguments":[{"content":"wrongly indented line","location":{"column":7,"line":18}}],"locations":[{"column":9,"line":17}],"text":"a DocString with wrong indentation"},{"arguments":[{"content":"first line\nsecond line","location":{"column":7,"line":22}}],"locations":[{"column":9,"line":21}],"text":"a DocString with alternative separator"},{"arguments":[{"content":"first line\n\"\"\"\nthird line","location":{"column":7,"line":27}}],"locations":[{"column":9,"line":26}],"text":"a DocString with normal separator inside"},{"arguments":[{"content":"first line\n```\nthird line","location":{"column":7,"line":33}}],"locations":[{"column":9,"line":32}],"text":"a DocString with alternative separator inside"},{"arguments":[{"content":"first line\n\"\"\"\nthird line","location":{"column":7,"line":39}}],"locations":[{"column":9,"line":38}],"text":"a DocString with escaped separator inside"}],"tags":[]},"type":"pickle","uri":"testdata/good/docstrings.feature"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be edited directly, it is gherkin/testdata/good/docstrings.feature.pickles.ndjson which is the source file that is pushed down to each language version of the gherkin library (using rsync_files). Since we use the same testdata for acceptance tests for all language version for the gherkin library, this pull-request cannot be merged until all 8 language versions have been updated.

@rjwittams
Copy link
Contributor Author

rjwittams commented Oct 22, 2017 via email

@brasmusson
Copy link
Contributor

@rjwittams Many people can contribute to a pull-request, so "each contributor" does not need to fix all languages. However the acceptance test data should not diverge between language versions.

@brasmusson
Copy link
Contributor

And while the content type is not passed onto the step definition, ...

The Pickles are primarily for executing the test cases from each feature file, so if the content type is not needed for that, maybe the content type should not be added to the Pickles data.

A formatter can still access the content type, since the formatter has access to the complete feature file content.

@rjwittams
Copy link
Contributor Author

rjwittams commented Oct 22, 2017 via email

@brasmusson
Copy link
Contributor

argument transformers could make use of it

This is a real argument for including the content type in the Pickle. That it is easier for the formatters is not. For instance the step keyword is not in the Pickle, even though practically every formatter needs to use it.

@rjwittams
Copy link
Contributor Author

Also, as mentioned above, it may be useful (and consistent) for it to be transformed by interpolation.

Added a test for this.
Updated other language implementations.
The Obj-C implementation does not appear to support pickles so I didn't change it.

There is a generated parser change in the javascript. Not sure why - if it was accidentally left out before, or is environmental ( different versions of something?)
@@ -48,9 +48,6 @@ module.exports = function Parser(builder) {
if(typeof tokenScanner == 'string') {
tokenScanner = new TokenScanner(tokenScanner);
}
if(typeof tokenMatcher == 'string') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this change was made in the generated parser - I assume it was missed out. I assume it is benign.

@rjwittams
Copy link
Contributor Author

The build seemed to fail due to yarn timing out. Can it be restarted?
On binary and source compatibility:
C and go I did not try, as a struct size needs to change.
Java and C# should have a compatible PickleString constructor defaulting content type to null.
The rest are dynamic I think.

@mlvandijk
Copy link
Member

@rjwittams Restarted the build. It fails with the following message:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

@stale
Copy link

stale bot commented Dec 25, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Dec 25, 2017
@brasmusson brasmusson added the 🧷 pinned Tells Stalebot not to close this issue label Dec 26, 2017
@stale stale bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Dec 26, 2017
aslakhellesoy added a commit that referenced this pull request Feb 10, 2018
@aslakhellesoy aslakhellesoy merged commit ec7a9eb into cucumber:master Feb 10, 2018
aslakhellesoy added a commit that referenced this pull request Feb 10, 2018
@aslakhellesoy
Copy link
Contributor

Hi @rjwittams,

Thanks for your making your first contribution to Cucumber, and welcome to the Cucumber committers team! You can now push directly to this repo and all other repos under the cucumber organization! 🍾

In return for this generous offer we hope you will:

  • ✅ Continue to use branches and pull requests. When someone on the core team approves a pull request (yours or someone else's), you're welcome to merge it yourself.
  • 💚 Commit to setting a good example by following and upholding our code of conduct in your interactions with other collaborators and users.
  • 💬 Join the community Slack channel to meet the rest of the team and make yourself at home.
  • ℹ️ Don't feel obliged to help, just do what you can if you have the time and the energy.
  • 🙋 Ask if you need anything. We're looking for feedback about how to make the project more welcoming, so please tell us!

On behalf of the Cucumber core team,
Aslak Hellesøy
Creator of Cucumber

@lock
Copy link

lock bot commented Feb 10, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
library: gherkin 🧷 pinned Tells Stalebot not to close this issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants