-
Notifications
You must be signed in to change notification settings - Fork 373
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
Use original return values for rake methods #742
Conversation
Thanks for the heads up @redapted. I'm honestly surprised this is happening. EDIT: Oh right, we're calling A possibly shorter way of doing this would be I would also suggest adding in an RSpec test that verifies we don't regress on this in the future. Otherwise this seems like a good idea to me. |
Good call! I always forget about
Added. Only added an example for The builds for Ruby < 2.3 now seem to be failing on the "Install Appraisal Gems" step, but they were passing with the previous commit. It looks like the bundle checksums have changed, so it could be that this commit got on the wrong side of a cache expiration or Docker image update? The latest ruby >= 2.1 builds are trying to install nokogiri 1.10.3, has a minimum ruby version of 2.3.0, whereas the second-most-recent build was trying to install nokogiri 1.9.1, which has a minimum ruby version of 2.1.0. The 2.0 build is failing on hitimes (1.3.1 vs 1.3.0), and 1.9 on dogstatsd-ruby (4.2.0 vs. 3.3.0) for what appear to be similar reasons. Anything I should do to remedy this, or is it a CI issue? |
@redapted Pretty sure this is flaky CircleCI behavior; whenever I see this, I just re-run the builds and most of the time it resolves itself. Haven't figured out why CircleCI has a habit of trying to install the wrong gems, but as you pointed out, it seems correlated with Ruby version. Overall the changes look good, and I'm quite happy with this! I think I'll merge this for the next release (probably 0.23.0.) Thanks for the contribution! 🎉 |
Problem
The Rake instrumentation causes the results of
#invoke
and#execute
to be swallowed. This means, when calling one Rake task from another Rake task, the former will now always returnnil
. For example, given the following rake tasks:Running
rake some:task
will fail with the "I am sad." message.Impact
There are some instances, where it is helpful to run certain Rake tasks within others. For example, running ActiveRecord's built-in
db
tasks as part of a larger purpose-built task that sets up an environment.In general, this does not appear to be a common use-case. However, in cases where it's needed, the only alternative would be to use exceptions for control-flow, which is an anti-pattern that should be avoided.
Solution
Simply assign the results of
super
in these two methods to a local variable, and return that at the end of the wrapper's execution. This causesrake some:task
to print "Yaaay!" and not error, for the above example.