Skip to content

Commit

Permalink
Pretty Tests Report plugin updates
Browse files Browse the repository at this point in the history
- Added mutex for post test fixture event handling
- Made documentation more better
  • Loading branch information
mkarlesky committed Jan 4, 2024
1 parent 0f691e3 commit beb3833
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 20 deletions.
44 changes: 34 additions & 10 deletions plugins/stdout_pretty_tests_report/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit beb3833

Please sign in to comment.