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

Draft: Use cucumber/gherkin parser in Behat #1404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ciaranmcnulty
Copy link
Contributor

This incorporates the compatibility layer from Behat/Gherkin#253 into Behat, as a configuration file flag

default:
  gherkin:
    parser: cucumber

The expectation is that at some point in the future we could flip the default behaviour to be 'use the cucumber one if cucumber/gherkin is installed'

composer.json Outdated Show resolved Hide resolved
if: matrix.symfony-version != ''
run: |
composer config --global --no-plugins allow-plugins.symfony/flex true &&
composer global require symfony/flex

- name: Temporary - add ciaran fork
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DO NOT MERGE with this


$definition = new Definition('Behat\Gherkin\Loader\CucumberGherkinLoader');
$definition->addMethodCall('setBasePath', array('%paths.base%'));
$definition->addTag(self::LOADER_TAG, array('priority' => 100));
Copy link
Member

Choose a reason for hiding this comment

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

Does it need to be 100? Could it be 50 as with the legacy parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably. I think if we were doing 'auto' mode more cleanly we could register both but have older parser be higher priority?

Copy link
Member

Choose a reason for hiding this comment

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

Should it be even possible to have two Gherkin parsers? How would that work together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The highest priority that supports() the resource being loaded wins

IRL the resource is always a file and both parsers will say they can load it

@@ -97,6 +99,11 @@ public function configure(ArrayNodeDefinition $builder)
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->enumNode('parser')
->info('Sets which gherkin parser to use if not specified at CLI')
->values(['auto', 'cucumber', 'legacy'])
Copy link
Member

Choose a reason for hiding this comment

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

Legacy -> Behat?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I don't like either name :)

Legacy is too harsh but 'behat' is confusing as the new one is used by behat too. Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, behat is not my favourite too, but makes it consistent with cucumber? What about if we make it a package name? behat/gherkin or cucumber/gherkin - could be more discoverable this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about classic?

@ciaranmcnulty
Copy link
Contributor Author

I want to come back to this and implement a CLI flag too; however it's not quite clear how to do that in the container so it might need to be reworked as a runtime switch

@@ -1,4 +1,4 @@
default:
gherkin:
filters:
tags: ~@php8
tags: ~@php8&&~@cucumber-parser
Copy link
Member

Choose a reason for hiding this comment

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

We should probably handle that with 2 suites running the same scenarios with each parser instead of having only a few scenarios running with the new parser. The tag would then be used only to tag scenarios that require the cucumber parser

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm how about a second profile too?

default - runs ~@php8&&~@cucumber-parser
cucumber - includes @cucumber-parser and also enables the config setting?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, a profile rather than a suite might do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants