-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
'feature' variable comes up nil if you don't provide an explicit file path to cucumber command (4.0.0) #1427
Comments
Hey Douglas, Thanks for opening the issue. The behaviour you explain is surprising, as this should now have changed in As an example: ╭─vincent.pretre@Vincents-MacBook-Pro ~/dev/open-source/cucumber-ruby-meta/cucumber-ruby ‹ruby-2.6.3› ‹master*›
╰─$ bundle exec cucumber
WARNING: Nokogiri was built against LibXML version 2.9.10, but has dynamically loaded 2.9.4
Using the default profile...
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
217 scenarios (217 passed)
1285 steps (1285 passed)
0m3.701s
╭─vincent.pretre@Vincents-MacBook-Pro ~/dev/open-source/cucumber-ruby-meta/cucumber-ruby ‹ruby-2.6.3› ‹master*›
╰─$ bundle exec cucumber -t@global_state
WARNING: Nokogiri was built against LibXML version 2.9.10, but has dynamically loaded 2.9.4
Using the default profile...
.......................................
4 scenarios (4 passed)
39 steps (39 passed)
0m0.117s Also on OSX (Catalina in my case, but I don't think this has much impact). Do you have some custom profiles defined by any chance ? |
I wouldn't know about custom profiles. We can certainly do a screenshare as I did not set up the initial environment and did not change it when I switched to cucumber v4. |
Do you have a I'm also a bit surprised with the way you used the ENV variables (I guesss
|
Your suggestion still gives the same error: OS=chrome ENV=us-prod cucumber -t@peak_quick_smoke Yes I do have a cucumber.yml file, There are four key value pairs: |
I'm wondering if those extra options may be set for those profiles (which may end up causing issues). That said, the way you describe it, there's no override of the default profile so it should not cause the issue during the run. |
Sure sounds good or we can do a GTM because I heard Zoom has some security issues |
Good news, I was able to reproduce your issue. It can happened when there's an empty Can you confirm you have an empty file in your features ? (or at least a feature that does not have the "Feature" keyword at the beginning, it can also happen when the file only has comments) |
Great. Unfortunately off hand, I don't think I have such a file. I know that I have one or two .feature files that have no Scenarios defined yet but they at least have a Feature line as well as a background section (with an accompanying comment block). I will see if I can find some time to look through the 50+ features files I have but all should have a Feature line. |
I checked all the .feature files which I work on and all have a Feature keyword So I want to be able to run cucumber like I had before with cucumber 3.0.0 at my $HOME/repos/repo-name. Under this directory is an entire infrastructure of our organization, many of which were worked on by folks no longer in the company so there may be an empty .feature file there somewhere, I don't know. All I had to do before was just specify a tag in my scripts like -t@my_feature and it would find all those scripts buried in the sub-folder directory structure from that root. I tried cd'ing to main header folder for my feature e.g., $HOME/repos/repo-name/features/my_feature. but when I run cucumber from there, I get: No such file or directory - features. You can use |
@DougMaisells You might be able to use something like |
Of course, that's a bug that was introduced when I added gherkin query. I'll publish a bug fix (considering it comes from an empty Feature file). Hopefully it'll solve your problem. |
Yes thank you, with #grep -Lr Feature . I was able to find an empty file. It was another project written by an engineer whom has long since left the company. Now after adding a Feature: line to that file, I get the following: (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '@Legistar @LSregression @atsui @ats @intc' (Cucumber::Core::Gherkin::ParseError) |
That's weird, normally the parser supports a file with simply a "Feature: some name" as content. |
So I made a fix in cucumber-gherkin gem - it's not yet released but should be soon (I have to discuss that with the other commiters as we have a few other on-going fixes there). |
The fix was released in cucumber-gherkin 14.0.0, but cucumber itself doesn't allow the use of that version (it requires unless Gherkin::Query.const_defined?('Patch', false)
module Gherkin::Query::Patch
private
def update_feature(feature)
super unless feature.nil?
end
end
Gherkin::Query.class_exec do
prepend Gherkin::Query::Patch
end
end I could have just prepended an anonymous module, but I didn't want to do so more than once just in case the support file got loaded more than once, so I made a named module to have a detectable condition. I did the prepend in a Looking forward to the new cucumber gem version that includes this fix. |
Brian,
Thanks for information. Well that stinks, life is fun with all these gem dependencies. Why can’t we all just get along? I think I will wait for official cucumber gem version because I am not sure what I am doing adding the lines below. In the meantime, I found the empty feature file from the engineer that left the company and added information there. I get a different error now:
Would your solution fix this as well or is there something in error with this person’s script?
features/legistar/legistar_ats.feature: (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got '@Legistar @LSregression @atsui @ats @intc' (Cucumber::Core::Gherkin::ParseError)
/Users/douglas.maisells/.rvm/gems/ruby-2.3.0/gems/cucumber-core-7.0.0/lib/cucumber/core/gherkin/parser.rb:29:in `block in document'
Douglas Maisells
Senior QA Engineer (govMeetings (Peak team))
P: 720.635.0118 E: [email protected]<mailto:[email protected]>
[Granicus Logo]<https://granicus.com/>
From: Brian Hawley <[email protected]>
Sent: Monday, June 29, 2020 12:02 PM
To: cucumber/cucumber-ruby <[email protected]>
Cc: Douglas Maisells <[email protected]>; Mention <[email protected]>
Subject: Re: [cucumber/cucumber-ruby] 'feature' variable comes up nil if you don't provide an explicit file path to cucumber command (4.0.0) (#1427)
[EXTERNAL]
The fix was released in cucumber-gherkin 14.0.0, but cucumber itself doesn't allow the use of that version (it requires ~> 13.0.0). So for others who have run into this issue, I made a patch that applies the fix. Put this code in one of your support files (I used env_changes.rb):
unless Gherkin::Query.const_defined?('Patch', false)
module Gherkin::Query::Patch
private
def update_feature(feature)
super unless feature.nil?
end
end
Gherkin::Query.class_exec do
prepend Gherkin::Query::Patch
end
end
I could have just prepended an anonymous module, but I didn't want to do so more than once just in case the support file got loaded more than once, so I made a named module to have a detectable condition. I did the prepend in a class_exec because it's a private method in older Ruby versions.
Looking forward to the new cucumber gem version that includes this fix.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#1427 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AC4C7NA7XP5EI2RV6J5BJMLRZDJI3ANCNFSM4N6IAWGQ>.
|
@DougMaisells my patch is basically the same conditional code from the code change that went into the cucumber-gherkin commit referenced above, but refactored into a wrapper method that calls the original method if the not-nil condition passes. It doesn't fix your additional issue. About that, that code looks like something that should count as a TagLine. The only thing that stands out to me is that tag which starts with the capital letter. Have you tried renaming that tag to lowercase? If switching to lowercase works, that would be useful info for making a new issue report. |
This should be fixed with the 4.1.0 release of |
Describe the bug
Cucumber no longer searches beyond current folder for scripts matching a -t@
To Reproduce
Steps to reproduce the behavior:
I recently updated a bunch of gems including Chromedriver, cucumber, capybara, selenium-webdriver. Everything was working fine before. Now I get the following error. The token (feature is undefined)....
cucumber OS=xxx ENV=yyy -t@some_tag
undefined method
tags' for nil:NilClass (NoMethodError) ../.rvm/gems/ruby-2.3.0/gems/cucumber-gherkin-13.0.0/lib/gherkin/query.rb:19:in
update_feature'_def update_feature(feature)
store_nodes_location(feature.tags)
feature.children.each do |child|
update_rule(child.rule) if child.rule
update_background(child.background) if child.background
update_scenario(child.scenario) if child.scenario
end
end_
I used to be able to at my root directory where I had a features/app_name directory I used to be able to run a script with
cucumber OS=xxx ENV=yyy -t@some_tag
(and this would search all folders from the root directory AND ALL subfolders for this tag and run those scripts)
now I must use
cucumber OS=xxx ENV=yyy features/app_name/..sub-directory... -t@some_tag OR
cucumber OS=xxx ENV=yyy features/app_name/..sub-directory... /thefeature.feature -t@some_tag
Is there something I need to set in my environment so that the first command works that it will search from the root folder for all feature files matching the tag?
Expected behavior
Cucumber 3.0 used to search all .feature files from the root directory whether they were in the current folder or sub-folders within the current folder etc
Context & Motivation
I must be more specific in the path given to cucumber particularly for a hierarchical test system of feature files broken up into folders by functionality
Screenshots
If applicable, add screenshots to help explain your problem.
Your Environment
Additional context
Come on. Basic functionality was removed in 4.0.0. Was this not regression tested by QA team at SmartBear prior to release?
The text was updated successfully, but these errors were encountered: