Skip to content

Commit

Permalink
Gracefully handle non-existing failing test given to bisect
Browse files Browse the repository at this point in the history
  • Loading branch information
zarifmahfuz committed May 14, 2024
1 parent 7bb8625 commit 601b634
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ruby/lib/ci/queue/bisect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def failing_test
Static.new([config.failing_test], config).populate(@all_tests)
end

def failing_test_present?
@all_tests.find { |t| t.id == config.failing_test }
end

def candidates
Static.new(first_half + [config.failing_test], config).populate(@all_tests)
end
Expand Down
7 changes: 7 additions & 0 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ def bisect_command
populate_queue

step("Testing the failing test in isolation")
unless queue.failing_test_present?
puts reopen_previous_step
puts red("The failing test does not exist.")
File.write('log/test_order.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.")
Expand Down
16 changes: 16 additions & 0 deletions ruby/test/integration/minitest_bisect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,22 @@ def test_broken
assert_equal expected_output, normalize(out)
end

def test_failing_test_is_not_present
out, err = capture_subprocess_io do
run_bisect('log/leaky_test_order.log', 'LeakyTestDoesNotExist#test_sensible_to_leak')
end

assert_empty err
expected_output = strip_heredoc <<-EOS
--- Testing the failing test in isolation
^^^ +++
The failing test does not exist.
EOS

assert_equal expected_output, normalize(out)
end

private

def normalize(output)
Expand Down

0 comments on commit 601b634

Please sign in to comment.