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

Cmdline arguments parsing error if --drb is enabled. #117

Closed
iromeo opened this issue Aug 11, 2011 · 6 comments
Closed

Cmdline arguments parsing error if --drb is enabled. #117

iromeo opened this issue Aug 11, 2011 · 6 comments

Comments

@iromeo
Copy link
Contributor

iromeo commented Aug 11, 2011

Cucumber gem v. 10.0.2 doesn't parse cmdline arguments correctly in DRB mode.

How to reproduce:

  1. Create new rails 3.0.9 application, run cucumber:instal generator with enabled spark support
  2. Create some feature file (e.g. using cucumber:feature)
  3. Launch spork
  4. Launch feature file using default profile
# cucumber.yml
default: --drb <%= std_opts %> features

, "-r features" cmdline argument and rails application home as a working directory

  1. In my case cucumber pass to spork incorrect cmdline arguments:

My cucumber gem cmdline options:

ruby ~/RubymineProjects/rspec_cuc_rails309/script/cucumber ~/RubymineProjects/rspec_cuc_rails309/features/subfolder/manage_people.feature --expand --drb --color -r features

Cucumber passes to spork:

Running tests with args [".../rspec_cuc_rails309/features/subfolder/manage_people.feature", "--expand", "--color", 
"-r", "--format", "Teamcity::Cucumber::Formatter", "--strict", "--tags", "~@wip", "--no-profile"]...
Done.

instead of:

Running tests with args [".../rspec_cuc_rails309/features/subfolder/manage_people.feature", "--expand", "--color", 
"-r", "features", "--format", "Teamcity::Cucumber::Formatter", "--strict", "--tags", "~@wip", "--no-profile"]...

Done.

As you can notice cucumber remove work "features" from "-r features". It is due to bug in "expanded_args_without_drb" method:

# gems/cucumber-1.0.2/lib/cucumber/cli/options.rb

def expanded_args_without_drb
  return @expanded_args_without_drb  if @expanded_args_without_drb
    @expanded_args_without_drb = (
    previous_flag_was_profile = false
    @expanded_args.reject do |arg|
      if previous_flag_was_profile
         previous_flag_was_profile = false
         next true
       end
       if [PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG].include?(arg)
         previous_flag_was_profile = true
         next true
       end
       arg == DRB_FLAG || @overridden_paths.include?(arg)    # <<<---- !!!!!! bug !!!!!!
     end
   )

   @expanded_args_without_drb.push("--no-profile") unless @expanded_args_without_drb.include?(NO_PROFILE_LONG_FLAG) || @expanded_args_without_drb.include?(NO_PROFILE_SHORT_FLAG)
   @expanded_args_without_drb
end

"overridden_paths" list contains "features" string because default profile suggests to launch all tests in "features" folder and it is overridden by our cmdline arguments which ask just to launch a single feature file. So the above method removes all mentions of "features" string from cmdline arguments and thus converts "-r features --format ..." to "-r --format ..." and thus all other arguments will be parsed incorrectly.

iromeo added a commit to iromeo/cucumber that referenced this issue Aug 11, 2011
@iromeo
Copy link
Contributor Author

iromeo commented Aug 11, 2011

Test which shows the bug - iromeo@6c09406

iromeo added a commit to iromeo/cucumber that referenced this issue Aug 11, 2011
iromeo added a commit to iromeo/cucumber that referenced this issue Aug 11, 2011
@iromeo
Copy link
Contributor Author

iromeo commented Aug 11, 2011

Suggested fix - iromeo@396e3ee

or

iromeo@25296e2, but previous I like more.

@iromeo
Copy link
Contributor Author

iromeo commented Sep 8, 2011

Hi, any progress? I've attached a patch...

@aslakhellesoy
Copy link
Contributor

Merged! Will be in 1.0.4

@iromeo
Copy link
Contributor Author

iromeo commented Sep 11, 2011

Aslak, thanks!

@lock
Copy link

lock bot commented Oct 25, 2018

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 Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants