From 61c4be477706b721688e36a3168f86aabc625658 Mon Sep 17 00:00:00 2001 From: Fumiaki MATSUSHIMA Date: Mon, 25 Mar 2019 02:59:28 +0900 Subject: [PATCH] Output junit format test report --- .gitignore | 1 + Gemfile | 1 + Gemfile.lock | 7 +++++++ actioncable/test/test_helper.rb | 2 ++ actionmailbox/test/test_helper.rb | 2 ++ actionmailer/test/abstract_unit.rb | 2 ++ actionpack/test/abstract_unit.rb | 2 ++ actiontext/test/test_helper.rb | 2 ++ actionview/test/abstract_unit.rb | 2 ++ activejob/test/helper.rb | 2 ++ activemodel/test/cases/helper.rb | 2 ++ activerecord/test/cases/helper.rb | 2 ++ activestorage/test/test_helper.rb | 2 ++ activesupport/test/abstract_unit.rb | 2 ++ railties/test/abstract_unit.rb | 2 ++ tools/test_common.rb | 15 +++++++++++++++ 16 files changed, 48 insertions(+) create mode 100644 tools/test_common.rb diff --git a/.gitignore b/.gitignore index e127852627..71acd2c638 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ package-lock.json pkg/ /tmp/ /yarn-error.log +/test-reports/ diff --git a/Gemfile b/Gemfile index 122baa4c33..b5c6312c52 100644 --- a/Gemfile +++ b/Gemfile @@ -102,6 +102,7 @@ instance_eval File.read local_gemfile if File.exist? local_gemfile group :test do gem "minitest-bisect" gem "minitest-retry" + gem "minitest-reporters" platforms :mri do gem "stackprof" diff --git a/Gemfile.lock b/Gemfile.lock index b6b1aaf92d..20f6b3ac21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -111,6 +111,7 @@ GEM addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) amq-protocol (2.3.0) + ansi (1.5.0) ast (2.4.0) aws-eventstream (1.0.1) aws-partitions (1.111.0) @@ -316,6 +317,11 @@ GEM minitest-bisect (1.4.0) minitest-server (~> 1.0) path_expander (~> 1.0) + minitest-reporters (1.3.6) + ansi + builder + minitest (>= 5.0) + ruby-progressbar minitest-retry (0.1.9) minitest (>= 5.0) minitest-server (1.0.5) @@ -555,6 +561,7 @@ DEPENDENCIES libxml-ruby listen (>= 3.0.5, < 3.2) minitest-bisect + minitest-reporters minitest-retry mysql2 (>= 0.4.10) nokogiri (>= 1.8.1) diff --git a/actioncable/test/test_helper.rb b/actioncable/test/test_helper.rb index c924f1e475..033f034b0c 100644 --- a/actioncable/test/test_helper.rb +++ b/actioncable/test/test_helper.rb @@ -41,3 +41,5 @@ class ActionCable::TestCase < ActiveSupport::TestCase end end end + +require_relative "../../tools/test_common" diff --git a/actionmailbox/test/test_helper.rb b/actionmailbox/test/test_helper.rb index bf93df1029..09f6cc818d 100644 --- a/actionmailbox/test/test_helper.rb +++ b/actionmailbox/test/test_helper.rb @@ -54,3 +54,5 @@ class BounceMailer < ActionMailer::Base end end end + +require_relative "../../tools/test_common" diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index 448807c144..a2a603834c 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -49,3 +49,5 @@ class ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +require_relative "../../tools/test_common" diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index f23151e518..6460ca6f8d 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -382,3 +382,5 @@ end class DrivenBySeleniumWithHeadlessFirefox < ActionDispatch::SystemTestCase driven_by :selenium, using: :headless_firefox end + +require_relative "../../tools/test_common" diff --git a/actiontext/test/test_helper.rb b/actiontext/test/test_helper.rb index 196fba8c99..51a207f76a 100644 --- a/actiontext/test/test_helper.rb +++ b/actiontext/test/test_helper.rb @@ -31,3 +31,5 @@ class ActiveSupport::TestCase ActiveStorage::Blob.create_after_upload! io: file_fixture(filename).open, filename: filename, content_type: content_type, metadata: metadata end end + +require_relative "../../tools/test_common" diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index fe317bf39e..2c1b277b41 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -205,3 +205,5 @@ class ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +require_relative "../../tools/test_common" diff --git a/activejob/test/helper.rb b/activejob/test/helper.rb index 694232d7ef..d400210fef 100644 --- a/activejob/test/helper.rb +++ b/activejob/test/helper.rb @@ -16,3 +16,5 @@ else end require "active_support/testing/autorun" + +require_relative "../../tools/test_common" diff --git a/activemodel/test/cases/helper.rb b/activemodel/test/cases/helper.rb index 138b1d1bb9..a4cb472ffc 100644 --- a/activemodel/test/cases/helper.rb +++ b/activemodel/test/cases/helper.rb @@ -25,3 +25,5 @@ class ActiveModel::TestCase < ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +require_relative "../../../tools/test_common" diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 298ee40df1..543a0aeb39 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -202,3 +202,5 @@ module InTimeZone ActiveRecord::Base.time_zone_aware_attributes = old_tz end end + +require_relative "../../../tools/test_common" diff --git a/activestorage/test/test_helper.rb b/activestorage/test/test_helper.rb index 144c224421..b34d0d64bb 100644 --- a/activestorage/test/test_helper.rb +++ b/activestorage/test/test_helper.rb @@ -101,3 +101,5 @@ end class Group < ActiveRecord::Base has_one_attached :avatar end + +require_relative "../../tools/test_common" diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 62356e4d46..01e60abd99 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -40,3 +40,5 @@ class ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +require_relative "../../tools/test_common" diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 9c866263f0..9600194ed6 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -32,3 +32,5 @@ class ActiveSupport::TestCase skip message if defined?(JRUBY_VERSION) end end + +require_relative "../../tools/test_common" diff --git a/tools/test_common.rb b/tools/test_common.rb new file mode 100644 index 0000000000..7f59caf644 --- /dev/null +++ b/tools/test_common.rb @@ -0,0 +1,15 @@ +if ENV["BUILDKITE"] + require "minitest/reporters" + require "fileutils" + + module Minitest + def self.plugin_rails_ci_junit_format_test_report_for_buildkite_init(*) + dir = File.join(__dir__, "../test-reports/#{ENV['BUILDKITE_JOB_ID']}") + reporter << Minitest::Reporters::JUnitReporter.new(dir, false) + FileUtils.mkdir_p(dir) + end + end + + Minitest.load_plugins + Minitest.extensions.unshift "rails_ci_junit_format_test_report_for_buildkite" +end