Class: PluginManager

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

Instance Method Summary collapse

Instance Method Details

#load_programmatic_plugins(plugins, system_objects) {|{ :environment => environment }| ... } ⇒ Object

Yields:

  • ({ :environment => environment })


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
# File 'lib/ceedling/plugins/plugin_manager.rb', line 19

def load_programmatic_plugins(plugins, system_objects)
  environment = []

  plugins.each do |hash|
    # Protect against instantiating object multiple times due to processing config multiple times (option files, etc)
    next if (@plugin_manager_helper.include?( @plugin_objects, hash[:plugin] ) )

    @loginator.lazy( Verbosity::OBNOXIOUS ) do 
      @reportinator.generate_progress( "Instantiating plugin class #{camelize( hash[:plugin] )}" )
    end

    begin
      @system_wrapper.require_file( "#{hash[:plugin]}.rb" )
      object = @plugin_manager_helper.instantiate_plugin( 
        camelize( hash[:plugin] ),
        system_objects,
        hash[:plugin],
        hash[:root_path]
      )
      @plugin_objects << object
      environment += object.environment

      # Add plugins to hash of all system objects
      system_objects[hash[:plugin].downcase().to_sym()] = object
    rescue 
      @loginator.log( "Exception raised while trying to load plugin: #{hash[:plugin]}", Verbosity::ERRORS, LogLabels::EXCEPTION  )
      raise # Raise again for backtrace, etc.
    end
  end

  yield( { :environment => environment } ) if (environment.size > 0)
end

#plugins_failed?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/ceedling/plugins/plugin_manager.rb', line 52

def plugins_failed?
  return (@build_fail_registry.size > 0)
end

#post_build(timestamp_s) ⇒ Object



132
# File 'lib/ceedling/plugins/plugin_manager.rb', line 132

def post_build(timestamp_s); execute_plugins(:post_build, timestamp_s); end

#post_compile_execute(arg_hash) ⇒ Object



106
# File 'lib/ceedling/plugins/plugin_manager.rb', line 106

def post_compile_execute(arg_hash); execute_plugins(:post_compile_execute, arg_hash); end

#post_error(timestamp_s) ⇒ Object



133
# File 'lib/ceedling/plugins/plugin_manager.rb', line 133

def post_error(timestamp_s); execute_plugins(:post_error, timestamp_s); end

#post_link_execute(arg_hash) ⇒ Object



109
# File 'lib/ceedling/plugins/plugin_manager.rb', line 109

def post_link_execute(arg_hash); execute_plugins(:post_link_execute, arg_hash); end

#post_mock_generate(arg_hash) ⇒ Object



100
# File 'lib/ceedling/plugins/plugin_manager.rb', line 100

def post_mock_generate(arg_hash); execute_plugins(:post_mock_generate, arg_hash); end

#post_mock_preprocess(arg_hash) ⇒ Object



94
# File 'lib/ceedling/plugins/plugin_manager.rb', line 94

def post_mock_preprocess(arg_hash); execute_plugins(:post_mock_preprocess, arg_hash); end

#post_release_build(timestamp_s) ⇒ Object



129
# File 'lib/ceedling/plugins/plugin_manager.rb', line 129

def post_release_build(timestamp_s); execute_plugins(:post_release_build, timestamp_s); end

#post_runner_generate(arg_hash) ⇒ Object



103
# File 'lib/ceedling/plugins/plugin_manager.rb', line 103

def post_runner_generate(arg_hash); execute_plugins(:post_runner_generate, arg_hash); end

#post_test(test) ⇒ Object



123
# File 'lib/ceedling/plugins/plugin_manager.rb', line 123

def post_test(test); execute_plugins(:post_test, test); end

#post_test_build(context, timestamp_s) ⇒ Object



126
# File 'lib/ceedling/plugins/plugin_manager.rb', line 126

def post_test_build(context, timestamp_s); execute_plugins(:post_test_build, context, timestamp_s); end

#post_test_fixture_execute(arg_hash) ⇒ Object



112
113
114
115
116
117
118
119
120
# File 'lib/ceedling/plugins/plugin_manager.rb', line 112

def post_test_fixture_execute(arg_hash)
  # Special arbitration: Raw test results are printed or taken over by plugins handling the job
  @loginator.log( arg_hash[:shell_result][:output] ) if @configurator.plugins_display_raw_test_results

  # Core failure detection independent of any reporting plugin
  register_build_failure( arg_hash[:context], 'Unit test failures' ) if arg_hash.dig(:results, :counts, :failed).to_i > 0

  execute_plugins(:post_test_fixture_execute, arg_hash)
end

#post_test_preprocess(arg_hash) ⇒ Object



97
# File 'lib/ceedling/plugins/plugin_manager.rb', line 97

def post_test_preprocess(arg_hash); execute_plugins(:post_test_preprocess, arg_hash); end

#pre_build(timestamp_s) ⇒ Object



131
# File 'lib/ceedling/plugins/plugin_manager.rb', line 131

def pre_build(timestamp_s); execute_plugins(:pre_build, timestamp_s); end

#pre_compile_execute(arg_hash) ⇒ Object



105
# File 'lib/ceedling/plugins/plugin_manager.rb', line 105

def pre_compile_execute(arg_hash); execute_plugins(:pre_compile_execute, arg_hash); end


108
# File 'lib/ceedling/plugins/plugin_manager.rb', line 108

def pre_link_execute(arg_hash); execute_plugins(:pre_link_execute, arg_hash); end

#pre_mock_generate(arg_hash) ⇒ Object



99
# File 'lib/ceedling/plugins/plugin_manager.rb', line 99

def pre_mock_generate(arg_hash); execute_plugins(:pre_mock_generate, arg_hash); end

#pre_mock_preprocess(arg_hash) ⇒ Object

execute all plugin methods ####



93
# File 'lib/ceedling/plugins/plugin_manager.rb', line 93

def pre_mock_preprocess(arg_hash); execute_plugins(:pre_mock_preprocess, arg_hash); end

#pre_release_build(timestamp_s) ⇒ Object



128
# File 'lib/ceedling/plugins/plugin_manager.rb', line 128

def pre_release_build(timestamp_s); execute_plugins(:pre_release_build, timestamp_s); end

#pre_runner_generate(arg_hash) ⇒ Object



102
# File 'lib/ceedling/plugins/plugin_manager.rb', line 102

def pre_runner_generate(arg_hash); execute_plugins(:pre_runner_generate, arg_hash); end

#pre_test(test) ⇒ Object



122
# File 'lib/ceedling/plugins/plugin_manager.rb', line 122

def pre_test(test); execute_plugins(:pre_test, test); end

#pre_test_build(context, timestamp_s) ⇒ Object



125
# File 'lib/ceedling/plugins/plugin_manager.rb', line 125

def pre_test_build(context, timestamp_s); execute_plugins(:pre_test_build, context, timestamp_s); end

#pre_test_fixture_execute(arg_hash) ⇒ Object



111
# File 'lib/ceedling/plugins/plugin_manager.rb', line 111

def pre_test_fixture_execute(arg_hash); execute_plugins(:pre_test_fixture_execute, arg_hash); end

#pre_test_preprocess(arg_hash) ⇒ Object



96
# File 'lib/ceedling/plugins/plugin_manager.rb', line 96

def pre_test_preprocess(arg_hash); execute_plugins(:pre_test_preprocess, arg_hash); end


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ceedling/plugins/plugin_manager.rb', line 56

def print_plugin_failures
  return if (@build_fail_registry.size == 0)
  failures = []

  banner = @reportinator.generate_banner(
    @loginator.decorate( 'BUILD FAILURE SUMMARY', LogLabels::FAIL )
  )

  # If we only ran basic unit tests, there's no need to prefix the failure messages with the context.
  if (@build_fail_registry.keys.size == 1 and @build_fail_registry.keys[0] == TEST_SYM)
    @build_fail_registry.each do |context, messages|
      messages.each {|message| failures << message}
    end
  # Otherwise, add the context to each message so the user knows the source of the failure.
  else
    @build_fail_registry.each do |context, messages|
      messages.each {|message| failures << "[#{context.to_s.upcase}] #{message}"}
    end
  end

  @loginator.log_list( failures, "\n" + banner, Verbosity::ERRORS, LogLabels::NONE )
end

#register_build_failure(context, message) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ceedling/plugins/plugin_manager.rb', line 79

def register_build_failure(context, message)
  return if (message.nil? or message.empty?)

  _context = context.is_a?(Symbol) ? context : context.to_sym

  # Create a new key/value with empty list if it doesn't exist
  @build_fail_registry[_context] ||= []

  list = @build_fail_registry[_context]
  list << message if !list.include?( message )
end

#setupObject



14
15
16
17
# File 'lib/ceedling/plugins/plugin_manager.rb', line 14

def setup
  @build_fail_registry = {}
  @plugin_objects = [] # List so we can preserve order
end

#summaryObject



135
# File 'lib/ceedling/plugins/plugin_manager.rb', line 135

def summary; execute_plugins(:summary); end