Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions ruby/test/minitest/queue/order_reporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,23 @@ def test_before_test

unless truffleruby?
def test_forking
pid = fork do
@reporter.start
end
# `start` truncates the log. In production it runs in the parent before
# workers fork; wait for it here so the truncate can't race the appends.
Process.waitpid(fork { @reporter.start })
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
pids.each { |pid| Process.waitpid(pid) }

assert_equal pids.map { |pid| "Minitest::Test##{pid}" }.sort, File.readlines(log_path).map(&:chomp).sort
end
end

private

def delete_log
File.delete(log_path) if File.exists?(log_path)
end

def log_path
@path ||= File.join(Dir.tmpdir, 'test_order.log')
end
Expand Down
Loading