Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
Test2::Harness::TestFiUser)Contributed Perl DocumenTest2::Harness::TestFile(3)

       Test2::Harness::TestFile	- Abstraction of a test	file and its

       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

       $bool = $tf->non_perl
	   Automatically set during construction, cannot be changed or set

       $string = $tf->comment
	   Defaults to '#' can be set during construction, or changed if

	   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
	   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
	   Key/Value pairs to append to	the queue_item() data.

       $cat = $tf->check_category()
	   This	is how you find	the category for a file. You can use
	   "set_category()" to assign/override a category.

       $dur = $tf->check_duration()
	   Get the duration of the test	file ('LONG', 'MEDIUM',	'SHORT'). You
	   can override	with "set_duration()".

       $stage =	$tf->check_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

       $hashref	= $tf->queue_item($job_name, $run_id)
	   This	returns	the data used to add the test file to the runner

       $int = $tf->rank()
	   Returns an integer value used to sort tests into an efficient run

       $path = $tf->relative()
	   Relative path to the	test file.

	   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.

	   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

       Chad Granum <>

       Chad Granum <>

       Copyright 2020 Chad Granum <>.

       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.


perl v5.32.1			  2020-11-18	   Test2::Harness::TestFile(3)


Want to link to this manual page? Use this URL:

home | help