Class: PluginReportinatorHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ceedling/plugin_reportinator_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ceedling=(value) ⇒ Object (writeonly)

Sets the attribute ceedling

Parameters:

  • value

    the value to set the attribute ceedling to.



16
17
18
# File 'lib/ceedling/plugin_reportinator_helper.rb', line 16

def ceedling=(value)
  @ceedling = value
end

Instance Method Details

#fetch_results(results_path, options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
# File 'lib/ceedling/plugin_reportinator_helper.rb', line 20

def fetch_results(results_path, options)
  # Create the results filepaths
  pass_path = results_path.ext( @configurator.extension_testpass )
  fail_path = results_path.ext( @configurator.extension_testfail )

  # Collect whether the results file(s) exists
  pass_exists = ( @file_wrapper.exist?( pass_path ) ? true : false )
  fail_exists = ( @file_wrapper.exist?( fail_path ) ? true : false )

  # Handle if neither file exists
  if !fail_exists and !pass_exists

    if options[:boom]
      # Complain loudly
      error = "Could find no test results for '#{File.basename(results_path).ext(@configurator.extension_source)}'"
      raise CeedlingException.new(error)

    else
      # Otherwise simply return empty results
      return {}
    end
  end

  # Handle if both files exists and return the newer results
  if pass_exists and fail_exists
    if @file_wrapper.newer?( pass_path, fail_path )
      return @yaml_wrapper.load( pass_path )
    else
      return @yaml_wrapper.load( fail_path )
    end
  end

  # Return success results
  return @yaml_wrapper.load(pass_path) if pass_exists

  # Return fail results
  return @yaml_wrapper.load(fail_path) if fail_exists
  
  # Safety fall-through (flow control should never get here)
  return {}
end

#process_results(aggregate, results) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/ceedling/plugin_reportinator_helper.rb', line 62

def process_results(aggregate, results)
  return if (results.empty?)
  aggregate[:times][(results[:source][:file])] = results[:time]
  aggregate[:successes]        << { :source => results[:source].clone, :collection => results[:successes].clone } if (results[:successes].size > 0)
  aggregate[:failures]         << { :source => results[:source].clone, :collection => results[:failures].clone  } if (results[:failures].size > 0)
  aggregate[:ignores]          << { :source => results[:source].clone, :collection => results[:ignores].clone   } if (results[:ignores].size > 0)
  aggregate[:stdout]           << { :source => results[:source].clone, :collection => results[:stdout].clone    } if (results[:stdout].size > 0)
  aggregate[:counts][:total]   += results[:counts][:total]
  aggregate[:counts][:passed]  += results[:counts][:passed]
  aggregate[:counts][:failed]  += results[:counts][:failed]
  aggregate[:counts][:ignored] += results[:counts][:ignored]
  aggregate[:counts][:stdout]  += results[:stdout].size
  aggregate[:total_time]       += results[:time]
end

#run_report(template, hash, verbosity) ⇒ Object



77
78
79
80
81
82
# File 'lib/ceedling/plugin_reportinator_helper.rb', line 77

def run_report(template, hash, verbosity)
  output = ERB.new( template, trim_mode: "%<>" )

  # Run the report template and log result with no log level heading
  @loginator.log( output.result(binding()), verbosity, LogLabels::NONE )
end