Fix options changed after pass it to any notifiers #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi All,
I got some errors when running tests with guard and guard-gotest, below are those notifiers I am using.
My error is Libnotify reported tests failed when got some errors, but emacs got success notification.
When I look into guard, and try to prints the
opts
atlib/guard/notifier.rb#177
(v2.2.1) and found the opts was changed after finish every notification:When send the first notification, the opts is
{:title=>"Gotest results", :type=>:failed, :priority=>2}
After finish the first notification, the opts changed to
{:priority=>2}
, (missed the failed type)After finish the emacs notification, the value became
{:priority=>2, :title=>"Guard", :type=>:success, :image=>"/home/jinzhu/.gem/ruby/2.0.0/gems/guard-2.2.1/images/success.png"}
(Got some unexpected values)After doing some research, I found every notifier's notify method inherit Guard::Notifier::Base#notify, but the code of Guard::Notifier::Base#notify looks strange for me:
It will update the original opts passed to it. I think it should only update the opts for this notifier but not global. So maybe pass a cloned options to each notifier should be a better idea.
Here is a simple code base to explain what's the error, hope it make sense: