DESCRIPTION
run_new_tests is called with three (named) parameters:
tests-
A references to an array of tests (explained below).
targets-
A reference to a hash of targets (explained below).
version_from-
The name of the file that is checked for a version number.
Targets
Targets provide a set of strings to match against. Targets are indexed by name. Each target is a hash, with the following keys:
list-
Required. This is a reference to an array that will act as building blocks to build strings to match against. In the simplest form, this is just an array with strings - but typically, this is an array of arrays, each subarray used to create a string.
query-
A coderef. For each entry in array given above, this coderef is called. It takes a set of arguments and returns a string to match against. If the corresponding entry in
listis reference to an array, all its elements are passed - otherwise, the entry is passed as a whole. Extra arguments provided withquery_argsbelow are prepended. If no coderef is given,sub {$_ [0]}is assumed. wanted-
A coderef. If the target is used for positive matches (that is, it's expected to match), this sub is called with the same arguments as
query- except thatwanted_argsare prepended. It should return a list of strings as if the regular expression was called with{-keep}. The string to match against may be assumed to be$_. If no coderef is given,sub {$_}is assumed.
Tests
The tests to run are put in an array, and run in that order. Each test tests a specific pattern. Up to seven types of tests are performed, depending whether the tests includes expected failures, expected passes or both. Expected passes are tested as a regular expression, as a regular expression with the {-keep} option, as a subroutine, as an object using the match method, and as an object using the subs method. Expected failures are tested as a regular expression, and as a subroutine. Each test is a hash with the following keys:
name-
The name of this test - mostly used in the test output.
regex-
The pattern to test with.
sub-
The subroutine to test with, if any.
sub_args-
Any arguments that need to be passed into the subroutine. If more than one argument needs to be passed, use a reference to an array - the array will be flattened when calling the subroutine.
query_args-
Extra arguments to pass into the
querycoderef for all the targets belonging to this tests, if not overriden as discussed below. wanted_args-
Extra arguments to pass into the
wantedcoderef for all the targets belonging to this tests, if not overriden as discussed below. pass-
Indicates which targets (discussed above) should be run with expected passes. The value of
passis either a reference to an array - the array containing the names of the targets to run, or a reference to a hash. In the latter case, the keys are the targets to be run, while the keys are hash references, containing more configuration options for the target. Values allowed:query_args-
Extra arguments to pass into the
querycoderef belonging to this test. See discussion above. wanted_args-
Extra arguments to pass into the
wantedcoderef belonging to this test. See discussion above.
fail-
As
pass, except that it will list targets with an expected failure.