Class Plugin

Inheritance Relationships

Derived Types

Class Documentation

class Plugin
[source]

Base class for test lifecycle extensions.

Plugins are linked together in a chain; all pre_test_action(), post_test_action(), and parse_arguments() calls propagate through the entire chain automatically via the run_all_*() and parse_all_*() helpers.

Subclassed by mu::tiny::mock::SupportPlugin, mu::tiny::test::JUnitOutputPlugin, mu::tiny::test::SetPointerPlugin, mu::tiny::test::TapOutputPlugin

Public Functions

Plugin(const String &name)

Construct a named plugin.

Parameters:

name – Identifier used for logging and retrieval by name.

virtual ~Plugin() = default
[source]
virtual void pre_test_action(Shell &test, Result &result)

Called once before each test body executes.

Override to set up per-test state. The default implementation does nothing.

Parameters:
  • test – The test shell about to run.

  • result – The active test result accumulator.

virtual void post_test_action(Shell &test, Result &result)

Called once after each test body completes (pass or fail).

Override to tear down per-test state. The default implementation does nothing.

Parameters:
  • test – The test shell that just ran.

  • result – The active test result accumulator.

virtual bool parse_arguments(int argc, const char *const *argv)

Handle a custom command-line argument.

Called with a pre-sliced view where argv[0] is the argument to inspect and argc is the number of remaining arguments (including argv[0]). Return true to indicate the argument was consumed.

Parameters:
  • argc – Remaining argument count (argv[0] through end).

  • argv – Pointer to the current argument.

Returns:

true if argv[0] was consumed.

inline virtual String get_help() const

Return a help string for this plugin’s command-line arguments.

Returns:

Help text, or an empty string if no arguments are accepted.

inline virtual Output *create_output()
[source]

Create an Output for this plugin, if any.

Returns:

A new Output, or nullptr if this plugin produces no output.

virtual Output *create_all_outputs()
[source]

Collect all outputs from the plugin chain.

Calls create_output() on each enabled plugin in the chain and wires them together as a composite output.

Returns:

Combined Output for the entire plugin chain.

virtual void run_all_pre_test_action(Shell &test, Result &result)

Invoke pre_test_action() on this plugin and all following plugins.

virtual void run_all_post_test_action(Shell &test, Result &result)

Invoke post_test_action() on this plugin and all following plugins.

virtual bool parse_all_arguments(int argc, const char *const *argv)

Invoke parse_arguments() on each plugin in the chain.

Parameters:
  • argc – Remaining argument count (argv[0] through end).

  • argv – Pointer to the current argument.

Returns:

true if any plugin consumed the argument.

virtual bool parse_all_arguments(int argc, char **argv)

Overload accepting a non-const argv.

Parameters:
  • argc – Remaining argument count (argv[0] through end).

  • argv – Pointer to the current argument.

Returns:

true if any plugin consumed the argument.

virtual String get_all_help() const
Returns:

Concatenated help strings from all plugins in the chain.

virtual Plugin *add_plugin(Plugin *plugin)

Append plugin to the end of the plugin chain.

Parameters:

pluginPlugin to add; must not already be in a chain.

Returns:

plugin.

virtual Plugin *get_next()
[source]
Returns:

The next plugin in the chain, or nullptr.

virtual void disable()
[source]

Disable this plugin (pre_test_action/post_test_action become no-ops).

virtual void enable()
[source]

Re-enable this plugin.

virtual bool is_enabled()
[source]
Returns:

true if this plugin is currently enabled.

const String &get_name()
[source]
Returns:

This plugin’s name.

Protected Functions

Plugin(Plugin *next)

Construct from an existing chain link (used internally for head nodes).

Parameters:

next – Pointer to the next plugin in the list.