-
Notifications
You must be signed in to change notification settings - Fork 33
Make the CI Queue reporters work in parallel #355
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,16 +7,41 @@ class OrderReporterTest < Minitest::Test | |
|
|
||
| def setup | ||
| @reporter = OrderReporter.new(path: log_path) | ||
| end | ||
|
|
||
| def test_start | ||
| @reporter.start | ||
| @reporter.report | ||
| assert_equal [], File.readlines(log_path).map(&:chomp) | ||
| end | ||
|
|
||
| def test_before_test | ||
| @reporter.start | ||
| @reporter.before_test(runnable('a')) | ||
| @reporter.before_test(runnable('b')) | ||
| @reporter.report | ||
| assert_equal ['Minitest::Test#a', 'Minitest::Test#b'], File.readlines(log_path).map(&:chomp) | ||
| end | ||
|
|
||
| unless truffleruby? | ||
| def test_forking | ||
|
Comment on lines
+26
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean to run this test only when not running the test suite with Truffle Ruby?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fork isn't implemented in truffle ruby. CI queue doesn't fork explicitly anywhere, we're just making sure the logging behaves well when distributed across multiple processes in forks or other threads. |
||
| pid = fork do | ||
| @reporter.start | ||
| end | ||
| pids = 5.times.map do | ||
| fork do | ||
| @reporter.before_test(runnable(Process.pid)) | ||
| @reporter.report | ||
| end | ||
| end | ||
| (pids + [pid]).map do |pid| | ||
| Process.waitpid(pid) | ||
| end | ||
|
|
||
| assert_equal pids.map { |pid| "Minitest::Test##{pid}" }.sort, File.readlines(log_path).map(&:chomp).sort | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def delete_log | ||
|
|
||
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.
Is
#startcalled only once before forking?If not, is there a risk that you truncate the few first logs in the case the first tests ran very quickly?
Also, is it okay not to call
super?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 it is called once before forking, so the truncate will behave like opening the file in write mode and rewriting sections of it in a non-forked setup.
Uh oh!
There was an error while loading. Please reload this page.
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.
Looks like we call https://github.com/minitest/minitest/blob/7c907429e8e7ec7c3b6ee0c7045e67249f4ad505/lib/minitest.rb#L864
Probably not needed, but I see most of the time it is called. I'll add it back just in case.