@@ -7,7 +7,6 @@ module ExcludeMessage
77end
88
99require "minitest/excludes"
10- require "minitest/github_action_reporter"
1110
1211# This gives great visibility on schema dump related tests, but
1312# some rails specific messages are then ignored.
@@ -152,21 +151,34 @@ def with_postgresql_datetime_type(type)
152151
153152ActiveRecord ::TestCase . prepend ( SetDatetimeInCockroachDBAdapter )
154153
155- module Minitest
156- module GithubActionReporterExt
157- def gh_link ( loc )
158- return super unless loc . include? ( "/gems/" )
154+ if ENV [ "GITHUB_ACTIONS" ]
155+ require "minitest/github_action_reporter"
159156
160- path , _ , line = loc [ %r(/(?:test|spec|lib)/.*) ] [ 1 ..] . rpartition ( ":" )
157+ module Minitest
158+ module GithubActionReporterExt
159+ def gh_link ( loc )
160+ return super unless loc . include? ( "/gems/" )
161161
162- rails_version = "v#{ ActiveRecord ::VERSION ::STRING } "
163- "#{ ENV [ "GITHUB_SERVER_URL" ] } /rails/rails/blob/#{ rails_version } /activerecord/#{ path } #L#{ line } "
164- rescue
165- warn "Failed to generate link for #{ loc } "
166- super
162+ path , _ , line = loc [ %r(/(?:test|spec|lib)/.*) ] [ 1 ..] . rpartition ( ":" )
163+
164+ rails_version = "v#{ ActiveRecord ::VERSION ::STRING } "
165+ "#{ ENV [ "GITHUB_SERVER_URL" ] } /rails/rails/blob/#{ rails_version } /activerecord/#{ path } #L#{ line } "
166+ rescue
167+ warn "Failed to generate link for #{ loc } "
168+ super
169+ end
167170 end
171+ GithubActionReporter . prepend ( GithubActionReporterExt )
168172 end
169- GithubActionReporter . prepend ( GithubActionReporterExt )
173+ end
174+
175+ # Using '--fail-fast' may cause the rails plugin to raise Interrupt when recording
176+ # a test. This would prevent other plugins from recording it. Hence we make sure
177+ # that rails plugin is loaded last.
178+ Minitest . load_plugins
179+ if Minitest . extensions . include? ( "rails" )
180+ Minitest . extensions . delete ( "rails" )
181+ Minitest . extensions << "rails"
170182end
171183
172184if ENV [ 'TRACE_LIB' ]
0 commit comments