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
9 changes: 8 additions & 1 deletion ruby/lib/ci/queue/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ def from_env(env)

def load_flaky_tests(path)
return [] unless path
::File.readlines(path).map(&:chomp).to_set
if ::File.extname(path) == ".xml"
require 'rexml/document'
REXML::Document.new(::File.read(path)).elements.to_a("//testcase").map do |element|
"#{element.attributes['classname']}##{element.attributes['name']}"
end.to_set
else
::File.readlines(path).map(&:chomp).to_set
end
rescue SystemCallError
[]
end
Expand Down
15 changes: 15 additions & 0 deletions ruby/test/ci/queue/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ def test_parses_file_correctly

flaky_tests = Configuration.load_flaky_tests('/tmp/does-not-exist')
assert_empty flaky_tests

Tempfile.open(['flaky_test_file', '.junit.xml']) do |file|
file.write(<<~XML)
<testsuite name="ATest">
<testcase name="test_foo" classname="ATest" />
<testcase name="test_bar" classname="ATest" />
</testsuite>
XML
file.close

flaky_tests = Configuration.load_flaky_tests(file.path)
assert_equal 2, flaky_tests.size
assert_includes flaky_tests, "ATest#test_foo"
assert_includes flaky_tests, "ATest#test_bar"
end
end

def test_queue_init_timeout_unset
Expand Down
Loading