Class: PluginReportinatorHelper

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

Instance Method Summary collapse

Instance Method Details

#fetch_results(results_path, options) ⇒ Object



16
17
18
19
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
61
62
63
# File 'lib/ceedling/plugins/plugin_reportinator_helper.rb', line 16

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

  begin
    # 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
  rescue YamlLoadException => e
    raise YamlLoadException.new(
      reason: e.reason, source: e.source, original_error: e.original_error,
      message: "Generated test results file is corrupted or unreadable ⏩️ #{e.message}"
    )
  end

  # Safety fall-through (flow control should never get here)
  return {}
end

#process_results(aggregate, results) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ceedling/plugins/plugin_reportinator_helper.rb', line 65

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