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
EventProf Minitest integration #29
EventProf Minitest integration #29
Conversation
…for factory.create
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.
Great job 👍
There are some small issues but overall looks good. Thank you!
Don't forget about:
-
Guide update
-
Changelog update
lib/minitest/event_prof_plugin.rb
Outdated
opts.on "--event-prof=EVENT", "Collects metrics for specified EVENT" do |event| | ||
options[:event] = event | ||
end | ||
opts.on "--event-prof-rank=RANK_BY", "Defines RANK_BY parameter for results" do |rank| |
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.
Let's name it --event-prof-rank-by
making more readable
lib/test_prof/event_prof/minitest.rb
Outdated
|
||
def location(group, example) | ||
name = group.public_instance_methods(false).find { |mtd| mtd.to_s == example } | ||
group.instance_method(name).source_location |
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've tried to run it with sample Rails app and got the following:
Run options: --event-prof=sql.active_record --seed 5773
# Running:
..../usr/local/lib/ruby/gems/2.4.0/bundler/gems/test-prof-3b646bac1b96/lib/test_prof/event_prof/minitest.rb:60:in `instance_method': nil is not a symbol nor a string (TypeError)
from /usr/local/lib/ruby/gems/2.4.0/bundler/gems/test-prof-3b646bac1b96/lib/test_prof/event_prof/minitest.rb:60:in `location'
from /usr/local/lib/ruby/gems/2.4.0/bundler/gems/test-prof-3b646bac1b96/lib/test_prof/event_prof/minitest.rb:52:in `change_current_group'
from /usr/local/lib/ruby/gems/2.4.0/bundler/gems/test-prof-3b646bac1b96/lib/test_prof/event_prof/minitest.rb:38:in `track_current_example'
from /usr/local/lib/ruby/gems/2.4.0/bundler/gems/test-prof-3b646bac1b96/lib/test_prof/event_prof/minitest.rb:19:in `prerecord'
I think, this is something Rails specific but we should care.
Example app is here https://github.com/palkan/th-dummy/tree/test-prof-minitest
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.
Also, FYI rails/rails#29469 (maybe, it worth mentioning this issue in the guide).
Thanks for the review! |
Let's use "master"; I'll update it before releasing. |
Thanks, got it! |
lib/test_prof/logging.rb
Outdated
@@ -13,7 +13,7 @@ def log(level, msg) | |||
end | |||
|
|||
def build_log_msg(level, msg) | |||
colorize(level, "[TEST PROF #{level.to_s.upcase}] #{msg}") | |||
colorize(level, "\n[TEST PROF #{level.to_s.upcase}] #{msg}") |
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.
What's the reason for the change? I think, it's better to control newlines in-place and do not hide within a private method.
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.
Yep, you're right - it was just a workaround for default Minitest reporter, where progress line concatenates with EventProf message. I'll remove it.
lib/test_prof/event_prof/minitest.rb
Outdated
@@ -37,7 +38,7 @@ def after_test(*); end | |||
def report | |||
@profiler.group_finished(@current_group) | |||
result = @formatter.prepare_results | |||
|
|||
puts "\n" |
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.
Bad idea. We should output everything using log
, 'cause (in theory) it can write to file.
Just prepend the result
with "\n"
(i.e. log :info, "\n#{result}"
).
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.
Actually, it won't help with the concatenation issue, because we need new line before log message itself, but not before the results. But as I wrote below I agree that it was a dumb mistake to didn't keep in mind a possibility to write results to the file :)
Frankly, I don't know what I was thinking about at that moment. Sorry for such a silly mistake :( Also there is one more thing I need to mention - even all specs are green I think that EventProf guide need to be updated a little bit with some caveat about minitest-reporters. When the user unintentionally run specs without prepending them with |
Sounds good! |
@IDolgirev Thank you for your help! I need your full name in Russian for CultOfMartians and your Twitter nickname (if any) for the announcement. |
You're welcome! Glad to help :) |
@IDolgirev Take a look, please: wrong event count https://travis-ci.org/palkan/test-prof/jobs/282329413 |
Thanks, already trying to reproduce it locally. As you see the whole group is missing in the results. I'm not quite good at multithreading and probably need some advices but at the first glance the reason is inside |
Yep, that may be the case. Not sure, but maybe Minitest automatically runs in multithreaded mode in JRuby. |
Well, I was totally unlucky yesterday so I didn't even get a chance to reproduce the error. Single spec, whole suite, random order, specific seed from Travis' failed job - nothing :( |
Have you tried JRuby?) Let's not spend too much time; I will try to investigate the next this problem occur. Thank you! |
In that case it was definitely JRuby because my machine started to work like any Dyson devices :) |
What is the purpose of this pull request?
It implements Minitest integration for EventProf (#21)
What changes did you make? (overview)
Custom Minitest plugin and reporter were added
Integration specs (based on the same Rspec ones) were added
Is there anything you'd like reviewers to focus on?
If there are no critical comments about I'll update EventProf guide