Skip to content

Commit c1d1236

Browse files
committed
hack around runit-maven-plugin expecting a test report output (with minitest 5)
1 parent 98c0071 commit c1d1236

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/test/ruby/test_helper.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@
2626
begin
2727
gem 'minitest'
2828
require 'minitest/autorun'
29+
# NOTE: deal with maven plugin 1.0.10 setting output (gone on minitest 5) :
30+
if Minitest.const_defined?(:Unit) && ! defined?(Minitest::Unit.output)
31+
Minitest::Unit.module_eval do
32+
@@report_path = nil
33+
def self.report_path; @@report_path end
34+
def self.output=(report_path) # called by the runit-maven-plugin
35+
Minitest.extensions << 'output' # add a plugin (MiniT calls #plugin_output_init)
36+
@@report_path = report_path
37+
end
38+
end
39+
Minitest.module_eval do
40+
def self.plugin_output_init(options)
41+
summary = self.reporter.reporters.find { |rr| rr.is_a?(Minitest::SummaryReporter) }
42+
if summary && Minitest::Unit.report_path
43+
summary = summary.dup
44+
summary.io = Minitest::Unit.report_path
45+
self.reporter.reporters << summary
46+
end
47+
end
48+
end
49+
end
2950
rescue LoadError
3051
end
3152

0 commit comments

Comments
 (0)