Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions ruby/lib/minitest/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def flaky?
Minitest.queue.flaky?(self)
end

def source_location
@runnable.instance_method(@method_name).source_location
rescue NameError, NoMethodError
nil
end

private

def current_timestamp
Expand Down
14 changes: 14 additions & 0 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,15 @@ def bisect_command
puts reopen_previous_step
puts red("The failing test does not exist.")
File.write('log/test_order.log', "")
File.write('log/bisect_test_details.log', "")
exit! 1
end

unless run_tests_in_fork(queue.failing_test)
puts reopen_previous_step
puts red("The test fail when ran alone, no need to bisect.")
File.write('log/test_order.log', queue_config.failing_test)
File.write('log/bisect_test_details.log', "")
exit! 0
end

Expand All @@ -218,6 +220,7 @@ def bisect_command
if queue.suspects_left == 0
step(yellow("The failing test was the first test in the test order so there is nothing to bisect."))
File.write('log/test_order.log', "")
File.write('log/bisect_test_details.log', "")
exit! 1
end

Expand All @@ -226,6 +229,7 @@ def bisect_command
if run_tests_in_fork(failing_order)
step(yellow("The bisection was inconclusive, there might not be any leaky test here."))
File.write('log/test_order.log', "")
File.write('log/bisect_test_details.log', "")
exit! 1
else
step(green('The following command should reproduce the leak on your machine:'), collapsed: false)
Expand All @@ -238,6 +242,16 @@ def bisect_command
puts

File.write('log/test_order.log', failing_order.to_a.map(&:id).join("\n"))

bisect_test_details = failing_order.to_a.map do |test|
source_location = test.source_location
file_path = source_location&.first || 'unknown'
line_number = source_location&.last || -1
"#{test.id} #{file_path}:#{line_number}"
end

File.write('log/bisect_test_details.log', bisect_test_details.join("\n"))

exit! 0
end
end
Expand Down
Loading