Test2::Harness::TestFile - Abstraction of a test file and its
meta-data.
When Test2::Harness finds test files to run each one gets an
instance of this class to represent it. This class will scan test files to
find important meta data (binary vs script, inline harness directives, etc).
The meta-data this class can find helps yath decide when and how to run the
test.
If you write a custom Test2::Harness::Finder or use some
Test2::Harness::Plugin callbacks you may have to use, or even construct
instances of this class.
use Test2::Harness::TestFile;
my $tf = Test2::Harness::TestFile->new(file => "path/to/file.t");
# For an example 1, 1 works, but normally they are job_name and run_id.
my $meta_data = $tf->queue_item(1, 1);
- $filename = $tf->file
- Set during object construction, and cannot be changed.
- $bool = $tf->is_binary
- Automatically set during construction, cannot be changed or set
manually.
- $bool = $tf->non_perl
- Automatically set during construction, cannot be changed or set
manually.
- $string = $tf->comment
- $tf->set_comment($string)
- Defaults to '#' can be set during construction, or changed if needed.
This is used to tell yath what character(s) are used to denote
a comment. This is necessary for finding harness directives. In perl the
'#' character is used, and that is the default value. This is here to
support non-perl tests.
- $class = $tf->job_class
- $tf->set_job_class($class)
- Default it undef (let the runner pick). You can change this if you want
the test to run with a custom job subclass.
- $arrayref = $tf->queue_args
- $tf->set_queue_args(\@ARGS)
- Key/Value pairs to append to the queue_item() data.
- $cat = $tf->check_category()
- $tf->set_category($cat)
- This is how you find the category for a file. You can use
"set_category()" to assign/override a
category.
- $dur = $tf->check_duration()
- $tf->set_duration($dur)
- Get the duration of the test file ('LONG', 'MEDIUM', 'SHORT'). You can
override with "set_duration()".
- $stage = $tf->check_stage()
- $tf->set_stage($stage)
- Get the preload stage the test file thinks it should be run in. You can
override with "set_stage()".
- $bool = $tf->check_feature($name)
- This checks for the "# HARNESS-NO-NAME"
or "# HARNESS-USE-NAME" or
"# HARNESS-YES-NAME" directives.
"NO" will result in a false boolean.
"YES" and
"USE" will result in a ture boolean. If
no directive is found then "undef" will
be returned.
- $arrayref = $tf->conflicts_list()
- Get a list of conflict markers.
- $seconds = $tf->event_timeout()
- If they test specifies an event timeout this will return it.
- %headers = $tf->headers()
- This returns the header data from the test file.
- $bool = $tf->is_executable()
- Check if the test file is executable or not.
- $data = $tf->meta($key)
- Get the meta-data for the specific key.
- $seconds = $tf->post_exit_timeout()
- If the test file has a custom post-exit timeout, this will return it.
- $hashref = $tf->queue_item($job_name, $run_id)
- This returns the data used to add the test file to the runner queue.
- $int = $tf->rank()
- Returns an integer value used to sort tests into an efficient run
order.
- $path = $tf->relative()
- Relative path to the test file.
- $tf->scan()
- Scan the file and populate the header data. Return nothing, takes no
arguments. Automatically run by things that require the scan data. Results
are cached.
- $tf->set_smoke($bool)
- Set smoke status. Smoke tests go to the front of the line when tests are
sorted.
- $hashref = $tf->shbang()
- Get data gathered from parsing the tests shbang line.
- $arrayref = $tf->switches()
- A list of switches passed to perl, usually from the shbang line.
The source code repository for Test2-Harness can be found at
http://github.com/Test-More/Test2-Harness/.
Copyright 2020 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/