Skip to content

Commit

Permalink
Change warnings file to be JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBr committed Jan 4, 2024
1 parent d7b3796 commit 9a313d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 2 additions & 7 deletions ruby/lib/minitest/queue/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,9 @@ def display_warnings(build)
return unless queue_config.warnings_file

warnings = build.pop_warnings.map do |type, attributes|
case type
when CI::Queue::Warnings::RESERVED_LOST_TEST
"[WARNING] #{attributes[:test]} was picked up by another worker because it didn't complete in the allocated #{attributes[:timeout]} seconds.\n" \
"You may want to either optimize this test or bump ci-queue timeout.\n" \
"It's also possible that the worker that was processing it was terminated without being able to report back.\n"
end
attributes.merge(type: type)
end.compact
File.write(queue_config.warnings_file, warnings.join("\n"))
File.write(queue_config.warnings_file, warnings.to_json)
end

def run_tests_in_fork(queue)
Expand Down
6 changes: 5 additions & 1 deletion ruby/test/integration/minitest_redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,11 @@ def test_redis_reporter
END

warnings_file.rewind
assert_equal warning, warnings_file.read
content = JSON.parse(warnings_file.read)
assert_equal 1, content.size
assert_equal "RESERVED_LOST_TEST", content[0]["type"]
assert_equal "Atest#test_bar", content[0]["test"]
assert_equal 2, content[0]["timeout"]

assert_empty err
output = normalize(out)
Expand Down

0 comments on commit 9a313d7

Please sign in to comment.