Class: Minitest::Reporters::ParallelTestsReporter
- Inherits:
-
BaseReporter
- Object
- BaseReporter
- Minitest::Reporters::ParallelTestsReporter
- Defined in:
- lib/minitest/reporters/parallel_tests_reporter.rb
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
-
.compile_reports! ⇒ Object
Call to compile all of the parallel reports together into one Destroys each of the segment reports after compiling.
-
.compiled_report_filepath ⇒ Object
Override if needed.
-
.load_compiled_report ⇒ Object
Use to read the report.
- .logger ⇒ Object
-
.report_name_prefix ⇒ Object
Override if needed.
Instance Method Summary collapse
- #logger ⇒ Object
-
#report ⇒ Object
Hook into BaseReporter.
Class Method Details
.compile_reports! ⇒ Object
Call to compile all of the parallel reports together into one Destroys each of the segment reports after compiling
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 25 def self.compile_reports! outputs = Dir[self.report_name_prefix + '*.yml'] outputs.delete self.compiled_report_filepath sorted = outputs .flat_map {|p| YAML.load_file(p)} .sort {|a,b| b[:time] <=> a[:time]} File.open(self.compiled_report_filepath, 'w') { |f| f.write sorted.to_yaml } logger.debug(self.name + "::compile_reports!") { "Compiled parallel test results written to #{self.compiled_report_filepath}" } FileUtils.rm(outputs) logger.debug(self.name + "::compile_reports!") { "Parallel segment test results deleted #{outputs}" } sorted end |
.compiled_report_filepath ⇒ Object
Override if needed
9 10 11 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 9 def self.compiled_report_filepath 'tmp/test_output_compiled.yml' end |
.load_compiled_report ⇒ Object
Use to read the report
19 20 21 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 19 def self.load_compiled_report YAML.load_file(self.compiled_report_filepath) end |
.logger ⇒ Object
57 58 59 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 57 def self.logger @logger ||= Logger.new($stdout) end |
.report_name_prefix ⇒ Object
Override if needed
14 15 16 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 14 def self.report_name_prefix 'tmp/test_output' end |
Instance Method Details
#logger ⇒ Object
53 54 55 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 53 def logger self.class.logger end |
#report ⇒ Object
Hook into BaseReporter
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/minitest/reporters/parallel_tests_reporter.rb', line 41 def report super result = tests.map do |t| { test_class_name: t.class.name, failures: t.failures.map(&:location), location: t.location, time: t.time } end filename = self.class.report_name_prefix + ENV['TEST_ENV_NUMBER'] + '.yml' File.open(filename, 'w') do |f| f.write result.to_yaml end logger.debug("#{self.class.name}#report") { "Parallel segment test results written to #{filename}" } end |