diff --git a/plugins/stdout_pretty_tests_report/README.md b/plugins/stdout_pretty_tests_report/README.md index 7e1be238..1f67ecc4 100644 --- a/plugins/stdout_pretty_tests_report/README.md +++ b/plugins/stdout_pretty_tests_report/README.md @@ -1,17 +1,41 @@ -ceedling-pretty-tests-report -============================ +# Ceedling Plugin: Pretty Tests Report -## Overview +# Overview -The stdout_pretty_tests_report is the default output of ceedling. Instead of -showing most of the raw output of CMock, Ceedling, etc., it shows a simplified -view. It also creates a nice summary at the end of execution which groups the -results into ignored and failed tests. +This plugin is intended to be the default option for formatting a test suites +results when displayed at the console. It collects raw test results from the +individual test executables of your test suite and presents them in a more +readable summary form. -## Setup +# Example Output -Enable the plugin in your project.yml by adding `stdout_pretty_tests_report` -to the list of enabled plugins. +``` +------------------- +FAILED TEST SUMMARY +------------------- +[test/TestModel.c] + Test: testInitShouldCallSchedulerAndTemperatureFilterInit + At line (21): "Function TaskScheduler_Init() called more times than expected." + +-------------------- +OVERALL TEST SUMMARY +-------------------- +TESTED: 1 +PASSED: 0 +FAILED: 1 +IGNORED: 0 + +--------------------- +BUILD FAILURE SUMMARY +--------------------- +Unit test failures. +``` + +# Configuration + +Enable the plugin in your project.yml by adding `stdout_pretty_tests_report` to +the list of enabled plugins instead of any other `stdout_*_tests_report` +plugin. ``` YAML :plugins: diff --git a/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb b/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb index bf1aa39b..e57fe4dc 100644 --- a/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb +++ b/plugins/stdout_pretty_tests_report/lib/stdout_pretty_tests_report.rb @@ -5,21 +5,31 @@ class StdoutPrettyTestsReport < Plugin def setup @result_list = [] + @mutex = Mutex.new + + # Fetch the test results template for this plugin @plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) template = @ceedling[:file_wrapper].read(File.join(@plugin_root, 'assets/template.erb')) + + # Set the report template @ceedling[:plugin_reportinator].register_test_results_template( template ) end + # Collect result file paths after each test fixture execution def post_test_fixture_execute(arg_hash) - #TODO CLEANUP return if not (arg_hash[:context] == TEST_SYM) - - @result_list << 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 + @result_list << arg_hash[:result_file] + end end - def post_build + # Render a report immediately upon build completion (that invoked tests) + def post_build() + # Ensure a test task was invoked as part of the build return if not (@ceedling[:task_invoker].test_invoked?) - results = @ceedling[:plugin_reportinator].assemble_test_results(@result_list) + results = @ceedling[:plugin_reportinator].assemble_test_results( @result_list ) hash = { :header => '', :results => results @@ -32,16 +42,25 @@ def post_build end end - def summary - result_list = @ceedling[:file_path_utils].form_pass_results_filelist( PROJECT_TEST_RESULTS_PATH, COLLECTION_ALL_TESTS ) + # Render a test results report on demand using results from a previous build + def summary() + # Build up the list of passing results from all tests + result_list = @ceedling[:file_path_utils].form_pass_results_filelist( + PROJECT_TEST_RESULTS_PATH, + COLLECTION_ALL_TESTS + ) - # get test results for only those tests in our configuration and of those only tests with results on disk hash = { :header => '', - :results => @ceedling[:plugin_reportinator].assemble_test_results(result_list, {:boom => false}) + # Collect all existing test results (success or failing) in the filesystem, + # limited to our test collection + :results => @ceedling[:plugin_reportinator].assemble_test_results( + result_list, + {:boom => false} + ) } - @ceedling[:plugin_reportinator].run_test_results_report(hash) + @ceedling[:plugin_reportinator].run_test_results_report( hash ) end end