-
Notifications
You must be signed in to change notification settings - Fork 550
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
Add -Werror
flag to turn Ruby warnings into errors
#995
Conversation
Fix: minitest#990 When working on gems that support multiple Ruby versions, it can be tricky to noticed you introduced a warning as you generally develop locally with one specific version and rely on CI to ensure it still works on other Ruby versions.
Taking a poke at it... I have a few questions rolling around in my brain:
I suspect my answers are: 1) hard maybe, 2) probably both mixin and cmdline flag that forces the mixin into Minitest::Test? 3) I suspect failure or subtype, not actually error. |
That was a bit fragmented... other possibilities: Activating (or including) this could install a teardown that simply asserts that no warnings were collected, or wraps run_one_method in Thanks for opening this. I'm gonna enjoy seeing how this plays out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some q's
when "error" | ||
options[:error_on_warning] = true | ||
$VERBOSE = true | ||
::Warning[:deprecated] if ::Warning.respond_to?(:[]=) # Ruby 2.7+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean?
::Warning[:deprecated] if ::Warning.respond_to?(:[]=) # Ruby 2.7+ | |
::Warning[:deprecated] = true if ::Warning.respond_to?(:[]=) # Ruby 2.7+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
else | ||
if ::Warning.respond_to?(:[]=) # Ruby 2.7+ | ||
::Warning[s.to_sym] = true | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unfamiliar enough with Warning that I don't understand this side of the top branch... I can see that you're setting that category to true, but I don't see it doing anything? Clue me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warnings that have a category (:deprecated
, :performance
, :experimental
), are only emitted if Warning[category_name] = true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of my confusion was that minitest/test_task always runs -w by default so Warning[:deprecated] was always true.
I got some high priority sutff that came out, I'll try to come back to this at some point but may take a tiny while, sorry! |
I've got some changes in flight here: https://gist.github.com/zenspider/391536c12501eff15894ddd9de9c4198 basically, add Warnings to summary output, improve location information (was all internal:), fix/refactor tests to work with both normal and -Werror |
merged my modifications... release soon |
|
Fix: #990
When working on gems that support multiple Ruby versions, it can be tricky to noticed you introduced a warning as you generally develop locally with one specific version and rely on CI to ensure it still works on other Ruby versions.
I tested this manually with:
Open questions:
error
,failure
, or their own count?