Skip to content

Commit c4584a7

Browse files
authored
Merge pull request #363 from Shopify/09-08-include_detailed_bisect_log_with_file_paths
Include detailed bisect log with file paths
2 parents b7b9e43 + 56973df commit c4584a7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ruby/lib/minitest/queue.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ def flaky?
257257
Minitest.queue.flaky?(self)
258258
end
259259

260+
def source_location
261+
@runnable.instance_method(@method_name).source_location
262+
rescue NameError, NoMethodError
263+
nil
264+
end
265+
260266
private
261267

262268
def current_timestamp

ruby/lib/minitest/queue/runner.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,15 @@ def bisect_command
193193
puts reopen_previous_step
194194
puts red("The failing test does not exist.")
195195
File.write('log/test_order.log', "")
196+
File.write('log/bisect_test_details.log', "")
196197
exit! 1
197198
end
198199

199200
unless run_tests_in_fork(queue.failing_test)
200201
puts reopen_previous_step
201202
puts red("The test fail when ran alone, no need to bisect.")
202203
File.write('log/test_order.log', queue_config.failing_test)
204+
File.write('log/bisect_test_details.log', "")
203205
exit! 0
204206
end
205207

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

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

240244
File.write('log/test_order.log', failing_order.to_a.map(&:id).join("\n"))
245+
246+
bisect_test_details = failing_order.to_a.map do |test|
247+
source_location = test.source_location
248+
file_path = source_location&.first || 'unknown'
249+
line_number = source_location&.last || -1
250+
"#{test.id} #{file_path}:#{line_number}"
251+
end
252+
253+
File.write('log/bisect_test_details.log', bisect_test_details.join("\n"))
254+
241255
exit! 0
242256
end
243257
end

0 commit comments

Comments
 (0)