NAME
Test2::Workflow::Unit - Representation of a workflow unit.
*** EXPERIMENTAL ***
This distribution is experimental, anything can change at any time!
DESCRIPTION
This package is a single unit of work to be done in a workflow. The unit may contain a codeblock, or many child units.
METHODS
- $unit->add_modify($other_unit)
- $unit->add_buildup($other_unit)
- $unit->add_teardown($other_unit)
-
These add
$other_unit
as a child unit. The child is added to the group specified in the method name. - $unit->add_primary($other_unit)
-
Add a primary unit child. Note: The primary unit is either an arrayref of other units, or a single coderef. In cases where the primary is a coderef, this will fail badly.
- $unit->add_post(sub { ... })
-
Add a post-build callback.
- $unit->do_post()
-
Run (and remove) the post-build callbacks.
- $dbg = $unit->debug
-
Generate an Test2::Debug object for this unit.
- $ctx = $unit->context
-
Generate a context representing the scope of the unit. Note: this context is non-canonical.
- $name = $unit->name
-
Get the unit name.
- $hr = $unit->meta
-
Get the meta hashref, this contains things like 'todo' and 'skip'.
- $type = $unit->type
-
Get the unit type.
- $bool = $unit->wrap
-
True if the codeblock for this unit is a wrap (around_all, around_each, etc).
- $hr = $unit->stash
-
General purpose stash for use in plugins and extensions.
- $pkg = $unit->package
-
Package for the unit.
- $file = $unit->file
-
Filename for the unit
- $start = $unit->start_line
-
Starting line for the unit.
- $end = $unit->end_line
-
Ending line number for the unit. Note: This can be set to an integer, or to the string 'EOF'.
- $unit->adjust_lines
-
This will check all child unit bounds, if they fall outside the parents bounds then the parent will be adjusted.
- $ar = $unit->post
- $ar = $unit->modify
- $ar = $unit->buildup
- $ar = $unit->teardown
-
Access to the arrayrefs for the specific child types.
- $code_or_ar = $unit->primary
-
Get the primary, which may be an arrayref of other units, or a single coderef.
- $check = $unit->filtered
-
$check
will be undefined when there is no filter.$check
will be true if the unit has been filtered out. (Should not run)$check
will be 0 if the unit passed the filter. (Should run).This means that a false result is interpreted as RUN, and a true result is interpreted as DO NOT RUN.
- $keep = $unit->filter($file, $line, $name)
-
This is used to filter out units that DO NOT match the input. All 3 arguments are optional, filtering will only consider the ones that are provided. Use undef for an argument to ignore it.
This will set the
filtered
attribute on the unit and all descendant units. The attribute will be set to1
or0
depending on if the unit should run given the filter.This will return true if the unit or one of its descendants matched the filter. It will return false if there are no matches.
If
filter()
has already run then it will return the result of its last run without even looking at the input parameters. This means you can only ever run filter once on any unit tree. - $unit->unfilter()
-
This will set the
filtered
attribute to0
on the unit and all its descendednts.
SOURCE
The source code repository for Test2-Workflow can be found at http://github.com/Test-More/Test2-Workflow/.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright 2015 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/