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

Avoid confusing error message with duplicated formats. #434

Merged
merged 2 commits into from
Apr 12, 2013
Merged

Avoid confusing error message with duplicated formats. #434

merged 2 commits into from
Apr 12, 2013

Conversation

sldblog
Copy link
Contributor

@sldblog sldblog commented Apr 11, 2013

If one specified the same formatter and output (eg. --format html --out cucumber/report.html) in both the std_opts part of cucumber.yml and the command line, the error message was the following:

"All but one formatter must use --out, only one can print to each stream (or STDOUT)".

This was really bewildering in most cases, since the user usually wants to use the command line to try/verify/rerun things and the message is not helping him/her understand the cause of the problem (remove the formatter from the config or the CLI, duh!).

To avoid the confusing error message, the (format, output) pairs are now uniqued, which I think is consistent with the user's wishes.


How to reproduce the problem

Modify cucumber.yml to contain:

std_opts = "--format html --out report.html --format progress features --tags ~@wip"

And execute:

$ bundle exec cucumber --format html --out report.html
All but one formatter must use --out, only one can print to each stream (or STDOUT) (RuntimeError)
/home/sldblog/Documents/work/cucumber/lib/cucumber/cli/configuration.rb:209:in `arrange_formats'

At this point the user is usually sufficiently flabbergasted.

What the commit does

With the same cucumber.yml, the command won't fail but work as intended:

$ bundle exec cucumber --format html --out report.html
Using the default profile...
..............................^C
Exiting... Interrupt again to exit immediately.
.

3 scenarios (1 skipped, 2 passed)
20 steps (20 passed)
0m3.602s

If one specified the same formatter and output (eg. '--format html
--out cucumber/report.html') in both the 'std_opts' part of
'config/cucumber.yml' and the command line, the error message
was the following:

"All but one formatter must use --out, only one can print to each
stream (or STDOUT)".

This was really bewildering in most cases, since the user usually wants
to use the command line to try/verify/rerun things and the message is
not helping him/her understand the cause of the problem (remove the
formatter from the config or the CLI, duh!).

To avoid the confusing error message, the (format, output) pairs are now
uniqued, which I think is consistent with the user's wishes.
@os97673
Copy link
Member

os97673 commented Apr 12, 2013

The suggestion looks reasonable for me, but could you please add one tests for the following situations:

  • the same formatter to stdout: --format pretty --format pretty
  • different formatters to the same file/stdout: --format pretty --out file1 --format html --out file1

This is to stress that duplication removal works even for implicit
stdout streams.
@sldblog
Copy link
Contributor Author

sldblog commented Apr 12, 2013

I have added the first one, and the second one luckily was already there in configuration_spec.rb:318 as "should not accept multiple --out streams pointing to the same place".

os97673 added a commit that referenced this pull request Apr 12, 2013
Avoid confusing error message with duplicated formats.
@os97673 os97673 merged commit cf54b05 into cucumber:master Apr 12, 2013
@os97673
Copy link
Member

os97673 commented Apr 12, 2013

Ok, thank you for the contribution.

@sldblog sldblog deleted the fix_confusing_format_error branch April 12, 2013 09:14
@sldblog
Copy link
Contributor Author

sldblog commented Apr 12, 2013

Thank you :)

@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

Successfully merging this pull request may close these issues.

2 participants