1App::Yath::Plugin(3)  User Contributed Perl Documentation App::Yath::Plugin(3)
2
3
4

NAME

6       App::Yath::Plugin - Base class for yath plugins
7

DESCRIPTION

9       This is a base class for yath plugins. Note this class also subclasses
10       Test2::Harness::Plugin.
11
12       This class holds the methods specific to yath, which is the UI layer.
13       Test2::Harness::Plugin holds the methods specific to Test2::Harness
14       which is the backend.
15

SYNOPSIS

17           package App::Yath::Plugin::MyPlugin;
18
19           use parent 'App::Yath::Plugin';
20
21           # ... Define methods
22
23           1;
24
25       Then to use it at the command line:
26
27           $ yath -pMyPlugin ...
28

NOTE ON INSTANCE VS CLASS

30       None of the plugin base classes provide a "new()" method. By default
31       plugins are not instantiated and only the plugin package name is passed
32       around. All methods are then called on the class.
33
34       If you want your plugin to be instantiated as an object you need only
35       define a "new()" method. If this method is defined yath will call it
36       and create an instance. The instance created will then be used when
37       calling all the methods.
38
39       To pass arguments to the constructor you can use "yath
40       -pYourPlugin=arg1,arg2,arg3...". Your plugin can also define options
41       using App::Yath::Options which will be dropped into the $settings that
42       get passed around.
43

METHODS

45       Note: See Test2::Harness::Plugin for additional method you can
46       implement/override
47
48       $plugin->handle_event($event, $settings)
49           Called for every single event that yath sees. Note that this method
50           is not defined by default for performance reasons, however it will
51           be called if you define it.
52
53       @sorted = $plugin->sort_files(@unsorted)
54           This gives your plugin a chance to sort the files before they are
55           added to the queue. Other things are done later to re-order the
56           files optimally based on length or category, so this sort is just
57           for initial job numbering, and to define a base order before
58           optimization takes place.
59
60           All files to sort will be instances of Test2::Harness::TestFile.
61
62           This method is normally left undefined, but will be called if you
63           define it.
64
65       $plugin->finish(%args)
66           This is what arguments are recieved:
67
68               (
69                   settings     => $settings,                      # The settings
70                   final_data   => $final_data,                    # See below
71                   pass         => $pass ? 1 : 0,                  # Always a 0 or 1
72                   tests_seen   => $self->{+TESTS_SEEN} // 0,      # Integer 0 or greater
73                   asserts_seen => $self->{+ASSERTS_SEEN} // 0,    # Integer 0 or greater
74               )
75
76           The final_data looks like this, note that some data may not be
77           present if it is not applicable. The data structure can be as
78           simple as "{ pass => $bool }".
79
80               {
81                   pass => $pass,    # boolean, did the test run pass or fail?
82
83                   failed => [       # Jobs that failed, and did not pass on a retry
84                       [$job_id1, $file1],    # Failing job 1
85                       [$job_id2, $file2],    # Failing job 2
86                       ...
87                   ],
88                   retried => [               # Jobs that failed and were retried
89                       [$job_id1, $times_run1, $file1, $passed_eventually1],    # Passed_eventually is a boolean
90                       [$job_id2, $times_run2, $file2, $passed_eventually2],
91                       ...
92                   ],
93                   hatled => [                                                  # Jobs that caused the entire test suite to halt
94                       [$job_id1, $file1, $halt_reason1],                       # halt_reason is a human readible string
95                       [$job_id2, $file2, $halt_reason2],
96                   ],
97               }
98

SOURCE

100       The source code repository for Test2-Harness can be found at
101       http://github.com/Test-More/Test2-Harness/.
102

MAINTAINERS

104       Chad Granum <exodist@cpan.org>
105

AUTHORS

107       Chad Granum <exodist@cpan.org>
108
110       Copyright 2020 Chad Granum <exodist7@gmail.com>.
111
112       This program is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.
114
115       See http://dev.perl.org/licenses/
116
117
118
119perl v5.32.1                      2021-03-12              App::Yath::Plugin(3)
Impressum