From 9a313d708ebebd8abe90354bf51d689452945c5e Mon Sep 17 00:00:00 2001 From: Christian Bruckmayer Date: Thu, 4 Jan 2024 14:37:29 +0000 Subject: [PATCH] Change warnings file to be JSON --- ruby/lib/minitest/queue/runner.rb | 9 ++------- ruby/test/integration/minitest_redis_test.rb | 6 +++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ruby/lib/minitest/queue/runner.rb b/ruby/lib/minitest/queue/runner.rb index 1f19f18b..0162ca33 100644 --- a/ruby/lib/minitest/queue/runner.rb +++ b/ruby/lib/minitest/queue/runner.rb @@ -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) diff --git a/ruby/test/integration/minitest_redis_test.rb b/ruby/test/integration/minitest_redis_test.rb index a8e99cc8..2cdd4e5e 100644 --- a/ruby/test/integration/minitest_redis_test.rb +++ b/ruby/test/integration/minitest_redis_test.rb @@ -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)