1Test2::Harness::TestFilUes(e3r)Contributed Perl DocumentTaetsito2n::Harness::TestFile(3)
2
3
4
6 Test2::Harness::TestFile - Abstraction of a test file and its
7 meta-data.
8
10 When Test2::Harness finds test files to run each one gets an instance
11 of this class to represent it. This class will scan test files to find
12 important meta data (binary vs script, inline harness directives, etc).
13 The meta-data this class can find helps yath decide when and how to run
14 the test.
15
16 If you write a custom Test2::Harness::Finder or use some
17 Test2::Harness::Plugin callbacks you may have to use, or even construct
18 instances of this class.
19
21 use Test2::Harness::TestFile;
22
23 my $tf = Test2::Harness::TestFile->new(file => "path/to/file.t");
24
25 # For an example 1, 1 works, but normally they are job_name and run_id.
26 my $meta_data = $tf->queue_item(1, 1);
27
29 $filename = $tf->file
30 Set during object construction, and cannot be changed.
31
32 $bool = $tf->is_binary
33 Automatically set during construction, cannot be changed or set
34 manually.
35
36 $bool = $tf->non_perl
37 Automatically set during construction, cannot be changed or set
38 manually.
39
40 $string = $tf->comment
41 $tf->set_comment($string)
42 Defaults to '#' can be set during construction, or changed if
43 needed.
44
45 This is used to tell yath what character(s) are used to denote a
46 comment. This is necessary for finding harness directives. In perl
47 the '#' character is used, and that is the default value. This is
48 here to support non-perl tests.
49
50 $class = $tf->job_class
51 $tf->set_job_class($class)
52 Default it undef (let the runner pick). You can change this if you
53 want the test to run with a custom job subclass.
54
55 $arrayref = $tf->queue_args
56 $tf->set_queue_args(\@ARGS)
57 Key/Value pairs to append to the queue_item() data.
58
60 $cat = $tf->check_category()
61 $tf->set_category($cat)
62 This is how you find the category for a file. You can use
63 set_category() to assign/override a category.
64
65 $dur = $tf->check_duration()
66 $tf->set_duration($dur)
67 Get the duration of the test file ('LONG', 'MEDIUM', 'SHORT'). You
68 can override with set_duration().
69
70 $stage = $tf->check_stage()
71 $tf->set_stage($stage)
72 Get the preload stage the test file thinks it should be run in. You
73 can override with set_stage().
74
75 $bool = $tf->check_feature($name)
76 This checks for the "# HARNESS-NO-NAME" or "# HARNESS-USE-NAME" or
77 "# HARNESS-YES-NAME" directives. "NO" will result in a false
78 boolean. "YES" and "USE" will result in a ture boolean. If no
79 directive is found then "undef" will be returned.
80
81 $arrayref = $tf->conflicts_list()
82 Get a list of conflict markers.
83
84 $seconds = $tf->event_timeout()
85 If they test specifies an event timeout this will return it.
86
87 %headers = $tf->headers()
88 This returns the header data from the test file.
89
90 $bool = $tf->is_executable()
91 Check if the test file is executable or not.
92
93 $data = $tf->meta($key)
94 Get the meta-data for the specific key.
95
96 $seconds = $tf->post_exit_timeout()
97 If the test file has a custom post-exit timeout, this will return
98 it.
99
100 $hashref = $tf->queue_item($job_name, $run_id)
101 This returns the data used to add the test file to the runner
102 queue.
103
104 $int = $tf->rank()
105 Returns an integer value used to sort tests into an efficient run
106 order.
107
108 $path = $tf->relative()
109 Relative path to the test file.
110
111 $tf->scan()
112 Scan the file and populate the header data. Return nothing, takes
113 no arguments. Automatically run by things that require the scan
114 data. Results are cached.
115
116 $tf->set_smoke($bool)
117 Set smoke status. Smoke tests go to the front of the line when
118 tests are sorted.
119
120 $hashref = $tf->shbang()
121 Get data gathered from parsing the tests shbang line.
122
123 $arrayref = $tf->switches()
124 A list of switches passed to perl, usually from the shbang line.
125
127 The source code repository for Test2-Harness can be found at
128 http://github.com/Test-More/Test2-Harness/.
129
131 Chad Granum <exodist@cpan.org>
132
134 Chad Granum <exodist@cpan.org>
135
137 Copyright 2020 Chad Granum <exodist7@gmail.com>.
138
139 This program is free software; you can redistribute it and/or modify it
140 under the same terms as Perl itself.
141
142 See http://dev.perl.org/licenses/
143
144
145
146perl v5.38.0 2023-10-04 Test2::Harness::TestFile(3)