Class: JUnitRhoLogFormatter
- Inherits:
-
JUnitFormatter
- Object
- DottedFormatter
- YamlFormatter
- JUnitFormatter
- JUnitRhoLogFormatter
- Defined in:
- lib/extensions/mspec/mspec/runner/formatters/rhospecf.rb
Overview
Junit formatter with cache, stores all the output inside StringIO After test is completed put results in log with small pieces and save xml to file
Instance Attribute Summary
Attributes inherited from DottedFormatter
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(file_name = nil) ⇒ JUnitRhoLogFormatter
constructor
A new instance of JUnitRhoLogFormatter.
Methods inherited from JUnitFormatter
#after, #exception, #load, #register
Methods inherited from YamlFormatter
Methods inherited from DottedFormatter
#abort, #after, #before, #exception, #exception?, #failure?, #print, #register
Constructor Details
#initialize(file_name = nil) ⇒ JUnitRhoLogFormatter
Returns a new instance of JUnitRhoLogFormatter.
29 30 31 32 33 |
# File 'lib/extensions/mspec/mspec/runner/formatters/rhospecf.rb', line 29 def initialize(file_name=nil) super @fname = file_name @finish = StringIO.new() end |
Instance Method Details
#finish ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/extensions/mspec/mspec/runner/formatters/rhospecf.rb', line 35 def finish super @finish.rewind() Rho::Log.info(@fname.nil? ? 'spec' : @fname,"JUNITNAME") max_buffer_size = 2 * 1024 buffer = [] buffer_size = 0 @finish.each_line do |line| pure_line = line.rstrip if (buffer_size + pure_line.length > max_buffer_size) && !buffer.empty? Rho::Log.info(buffer.join("~~"),'JUNITBLOB') buffer = [] buffer_size = 0 end buffer << pure_line buffer_size += pure_line.length + 2 end Rho::Log.info(buffer.join("~~"),'JUNITBLOB') unless buffer.empty? @finish.rewind() if !@fname.nil? File.open(@fname, "w") { |io| io.write(@finish.string) } end end |