TAP::Parser::Scheduler(3p) Perl Programmers Reference Guide

TAP::Parser::Scheduler(3p) Perl Programmers Reference Guide #

TAP::Parser::Scheduler(3p) Perl Programmers Reference Guide

NNAAMMEE #

 TAP::Parser::Scheduler - Schedule tests during parallel testing

VVEERRSSIIOONN #

 Version 3.44

SSYYNNOOPPSSIISS #

     use TAP::Parser::Scheduler;

DDEESSCCRRIIPPTTIIOONN #

MMEETTHHOODDSS #

CCllaassss MMeetthhooddss _"_n_e_w_"

     my $sched = TAP::Parser::Scheduler->new(tests => \@tests);
     my $sched = TAP::Parser::Scheduler->new(
         tests => [ ['t/test_name.t','Test Description'], ... ],
         rules => \%rules,
     );

 Given 'tests' and optional 'rules' as input, returns a new
 "TAP::Parser::Scheduler" object.  Each member of @tests should be either
 a a test file name, or a two element arrayref, where the first element is
 a test file name, and the second element is a test description. By
 default, we'll use the test name as the description.

 The optional "rules" attribute provides direction on which tests should
 be run in parallel and which should be run sequentially. If no rule data
 structure is provided, a default data structure is used which makes every
 test eligible to be run in parallel:

     { par => '**' },

 The rules data structure is documented more in the next section.

RRuulleess ddaattaa ssttrruuccttuurree The ““rules”” data structure is the the heart of the scheduler. It allows you to express simple rules like “run all tests in sequence” or “run all tests in parallel except these five tests.”. However, the rules structure also supports glob-style pattern matching and recursive definitions, so you can also express arbitarily complicated patterns.

 The rule must only have one top level key: either 'par' for "parallel" or
 'seq' for "sequence".

 Values must be either strings with possible glob-style matching, or
 arrayrefs of strings or hashrefs which follow this pattern recursively.

 Every element in an arrayref directly below a 'par' key is eligible to be
 run in parallel, while vavalues directly below a 'seq' key must be run in
 sequence.

 _R_u_l_e_s _e_x_a_m_p_l_e_s

 Here are some examples:

     # All tests be run in parallel (the default rule)
     { par => '**' },

     # Run all tests in sequence, except those starting with "p"
     { par => 't/p*.t' },

     # Run all tests in parallel, except those starting with "p"
     {
         seq => [
                   { seq => 't/p*.t' },
                   { par => '**'     },
                ],
     }

     # Run some  startup tests in sequence, then some parallel tests then some
     # teardown tests in sequence.
     {
         seq => [
             { seq => 't/startup/*.t' },
             { par => ['t/a/*.t','t/b/*.t','t/c/*.t'], }
             { seq => 't/shutdown/*.t' },
         ],
     },

 _R_u_l_e_s _r_e_s_o_l_u_t_i_o_n

 •   By default, all tests are eligible to be run in parallel. Specifying
     any of your own rules removes this one.

 •   "First match wins". The first rule that matches a test will be the
     one that applies.

 •   Any test which does not match a rule will be run in sequence at the
     end of the run.

 •   The existence of a rule does not imply selecting a test. You must
     still specify the tests to run.

 •   Specifying a rule to allow tests to run in parallel does not make the
     run in parallel. You still need specify the number of parallel "jobs"
     in your Harness object.

 _G_l_o_b_-_s_t_y_l_e _p_a_t_t_e_r_n _m_a_t_c_h_i_n_g _f_o_r _r_u_l_e_s

 We implement our own glob-style pattern matching. Here are the patterns
 it supports:

     ** is any number of characters, including /, within a pathname
     * is zero or more characters within a filename/directory name
     ? is exactly one character within a filename/directory name
     {foo,bar,baz} is any of foo, bar or baz.
     \ is an escape character

IInnssttaannccee MMeetthhooddss _"_g_e_t___a_l_l_"

 Get a list of all remaining tests.

 _"_g_e_t___j_o_b_"

 Return the next available job as TAP::Parser::Scheduler::Job object or
 "undef" if none are available. Returns a TAP::Parser::Scheduler::Spinner
 if the scheduler still has pending jobs but none are available to run
 right now.

 _"_a_s___s_t_r_i_n_g_"

 Return a human readable representation of the scheduling tree.  For
 example:

     my @tests = (qw{
         t/startup/foo.t
         t/shutdown/foo.t

         t/a/foo.t t/b/foo.t t/c/foo.t t/d/foo.t
     });
     my $sched = TAP::Parser::Scheduler->new(
         tests => \@tests,
         rules => {
             seq => [
                 { seq => 't/startup/*.t' },
                 { par => ['t/a/*.t','t/b/*.t','t/c/*.t'] },
                 { seq => 't/shutdown/*.t' },
             ],
         },
     );

 Produces:

     par:
       seq:
         par:
           seq:
             par:
               seq:
                 't/startup/foo.t'
             par:
               seq:
                 't/a/foo.t'
               seq:
                 't/b/foo.t'
               seq:
                 't/c/foo.t'
             par:
               seq:
                 't/shutdown/foo.t'
         't/d/foo.t'

perl v5.36.3 2023-02-15 TAP::Parser::Scheduler(3p)