Class: ReportTestsStdoutPlugin

Inherits:
Plugin show all
Defined in:
lib/ceedling/plugins/report_tests_stdout_plugin.rb

Overview

Base class for stdout test-results reporting plugins. Subclasses need only override the private load_template method to supply a different ERB template string. All hook logic lives here.

Instance Attribute Summary

Attributes inherited from Plugin

#environment, #name, #plugin_objects

Instance Method Summary collapse

Methods inherited from Plugin

#initialize, #inspect

Constructor Details

This class inherits a constructor from Plugin

Instance Method Details

#post_build(_timestamp_s) ⇒ Object

Plugin build step hook -- render a report immediately upon build completion (that invoked tests)



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ceedling/plugins/report_tests_stdout_plugin.rb', line 45

def post_build(_timestamp_s)
  # Ensure a test task was invoked as part of the build
  return if not @rake_invocation_tracker.test_task_invoked?

  return if @configurator.plugins_display_raw_test_results

  results = @plugin_reportinator.assemble_test_results( @result_list )
  hash = { :context => TEST_SYM, :results => results }
  verbosity = (results[:counts][:failed] > 0) ? Verbosity::ERRORS : Verbosity::NORMAL

  # Print unit test suite results
  @plugin_reportinator.run_test_results_report( hash, verbosity )
end

#post_test_fixture_execute(arg_hash) ⇒ Object

Plugin build step hook -- collect result file paths after each test fixture execution



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ceedling/plugins/report_tests_stdout_plugin.rb', line 32

def post_test_fixture_execute(arg_hash)
  result_file = arg_hash[:result_file]

  # Thread-safe manipulation since test fixtures can be run in child processes
  # spawned within multiple test execution threads.
  @mutex.synchronize do
    if (result_file =~ /#{PROJECT_TEST_RESULTS_PATH}/) && !@result_list.include?(result_file)
      @result_list << arg_hash[:result_file]
    end
  end
end

#setupObject

Plugin setup()



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ceedling/plugins/report_tests_stdout_plugin.rb', line 17

def setup
  @result_list = []
  @mutex = Mutex.new

  # References
  @configurator        = @ceedling[:configurator]
  @plugin_reportinator = @ceedling[:plugin_reportinator]
  @file_path_utils     = @ceedling[:file_path_utils]
  @rake_invocation_tracker   = @ceedling[:rake_invocation_tracker]

  # Set the report template (subclass supplies via load_template)
  @plugin_reportinator.register_test_results_template( load_template() )
end

#summaryObject

Plugin build step hook -- render a test results report on demand using results from a previous build



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

def summary
  return if @configurator.plugins_display_raw_test_results

  # Build up the list of passing results from all tests
  result_list = @file_path_utils.form_pass_results_filelist(
    PROJECT_TEST_RESULTS_PATH,
    COLLECTION_ALL_TESTS
  )

  hash = {
    :context => TEST_SYM,
    # Collect all existing test results (success or failing) in the filesystem,
    # limited to our test collection
    :results => @plugin_reportinator.assemble_test_results( result_list, {:boom => false} )
  }

  @plugin_reportinator.run_test_results_report( hash )
end