• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/H03-May-2022-44,59320,297

scripts/H18-Nov-2021-312191

t/H18-Nov-2021-9,5077,562

t2/H18-Nov-2021-429301

xt/author/H03-May-2022-170153

.yath.rcH A D18-Nov-2021103 97

ChangesH A D18-Nov-202132 KiB1,073659

LICENSEH A D18-Nov-202117.9 KiB380292

MANIFESTH A D18-Nov-20219.9 KiB335334

META.jsonH A D18-Nov-20213.6 KiB118116

META.ymlH A D18-Nov-20211.8 KiB7473

Makefile.PLH A D18-Nov-20214.6 KiB161149

READMEH A D18-Nov-202116.1 KiB546347

README.mdH A D18-Nov-202116.3 KiB525330

TODOH A D18-Nov-20213.8 KiB13683

appveyor.ymlH A D18-Nov-2021680 2922

cpanfileH A D18-Nov-20212.5 KiB7974

dist.iniH A D18-Nov-20215.1 KiB201177

foo.jsonlH A D18-Nov-202113.4 KiB1514

test.plH A D18-Nov-2021763 2818

README

1NAME
2
3    App::Yath - Yet Another Test Harness (Test2-Harness) Command Line
4    Interface (CLI)
5
6DESCRIPTION
7
8    This is the primary documentation for yath, App::Yath, Test2::Harness.
9
10    The canonical source of up-to-date command options are the help output
11    when using $ yath help and $ yath help COMMAND.
12
13    This document is mainly an overview of yath usage and common recipes.
14
15    App::Yath is an alternative to App::Prove, and Test2::Harness is an
16    alternative to Test::Harness. It is not designed to replace
17    Test::Harness/prove. Test2::Harness is designed to take full advantage
18    of the rich data Test2 can provide. Test2::Harness is also able to use
19    non-core modules and provide more functionality than prove can achieve
20    with its restrictions.
21
22PLATFORM SUPPORT
23
24    Test2::Harness/App::Yath is is focused on unix-like platforms. Most
25    development happens on linux, but bsd, macos, etc should work fine as
26    well.
27
28    Patches are welcome for any/all platforms, but the primary author (Chad
29    'Exodist' Granum) does not directly develop against non-unix platforms.
30
31 WINDOWS
32
33    Currently windows is not supported, and it is known that the package
34    will not install on windows. Patches are be welcome, and it would be
35    great if someone wanted to take on the windows-support role, but it is
36    not a primary goal for the project.
37
38OVERVIEW
39
40    To use Test2::Harness, you use the yath command. Yath will find the
41    tests (or use the ones you specify) and run them. As it runs, it will
42    output diagnostic information such as failures. At the end, yath will
43    print a summary of the test run.
44
45    yath can be thought of as a more powerful alternative to prove
46    (Test::Harness)
47
48RECIPES
49
50    These are common recipes for using yath.
51
52 RUN PROJECT TESTS
53
54        $ yath
55
56    Simply running yath with no arguments means "Run all tests for the
57    current project". Yath will look for tests in ./t, ./t2, and ./test.pl
58    and run any which are found.
59
60    Normally this implies the test command but will instead imply the run
61    command if a persistent test runner is detected.
62
63 PRELOAD MODULES
64
65    Yath has the ability to preload modules. Yath normally forks to start
66    new tests, so preloading can reduce the time spent loading modules over
67    and over in each test.
68
69    Note that some tests may depend on certain modules not being loaded. In
70    these cases you can add the # HARNESS-NO-PRELOAD directive to the top
71    of the test files that cannot use preload.
72
73  SIMPLE PRELOAD
74
75    Any module can be preloaded:
76
77        $ yath -PMoose
78
79    You can preload as many modules as you want:
80
81        $ yath -PList::Util -PScalar::Util
82
83  COMPLEX PRELOAD
84
85    If your preload is a subclass of Test2::Harness::Runner::Preload then
86    more complex preload behavior is possible. See those docs for more
87    info.
88
89 LOGGING
90
91  RECORDING A LOG
92
93    You can turn on logging with a flag. The filename of the log will be
94    printed at the end.
95
96        $ yath -L
97        ...
98        Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl
99
100    The event log can be quite large. It can be compressed with bzip2.
101
102        $ yath -B
103        ...
104        Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2
105
106    gzip compression is also supported.
107
108        $ yath -G
109        ...
110        Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.gz
111
112    -B and -G both imply -L.
113
114  REPLAYING FROM A LOG
115
116    You can replay a test run from a log file:
117
118        $ yath test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2
119
120    This will be significantly faster than the initial run as no tests are
121    actually being executed. All events are simply read from the log, and
122    processed by the harness.
123
124    You can change display options and limit rendering/processing to
125    specific test jobs from the run:
126
127        $ yath test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2 -v [TEST UUID(S)]
128
129    Note: This is done using the $ yath replay ... command. The replay
130    command is implied if the first argument is a log file.
131
132 PER-TEST TIMING DATA
133
134    The -T option will cause each test file to report how long it took to
135    run.
136
137        $ yath -T
138
139        ( PASSED )  job  1    t/yath_script.t
140        (  TIME  )  job  1    Startup: 0.07692s | Events: 0.01170s | Cleanup: 0.00190s | Total: 0.09052s
141
142 PERSISTENT RUNNER
143
144    yath supports starting a yath session that waits for tests to run. This
145    is very useful when combined with preload.
146
147  STARTING
148
149    This starts the server. Many options available to the 'test' command
150    will work here but not all. See $ yath help start for more info.
151
152        $ yath start
153
154  RUNNING
155
156    This will run tests using the persistent runner. By default, it will
157    search for tests just like the 'test' command. Many options available
158    to the test command will work for this as well. See $ yath help run for
159    more details.
160
161        $ yath run
162
163  STOPPING
164
165    Stopping a persistent runner is easy.
166
167        $ yath stop
168
169  INFORMATIONAL
170
171    The which command will tell you which persistent runner will be used.
172    Yath searches for the persistent runner in the current directory, then
173    searches in parent directories until it either hits the root directory,
174    or finds the persistent runner tracking file.
175
176        $ yath which
177
178    The watch command will tail the runner's log files.
179
180        $ yath watch
181
182  PRELOAD + PERSISTENT RUNNER
183
184    You can use preloads with the yath start command. In this case, yath
185    will track all the modules pulled in during preload. If any of them
186    change, the server will reload itself to bring in the changes. Further,
187    modified modules will be blacklisted so that they are not preloaded on
188    subsequent reloads. This behavior is useful if you are actively working
189    on a module that is normally preloaded.
190
191 MAKING YOUR PROJECT ALWAYS USE YATH
192
193        $ yath init
194
195    The above command will create test.pl. test.pl is automatically run by
196    most build utils, in which case only the exit value matters. The
197    generated test.pl will run yath and execute all tests in the ./t and/or
198    ./t2 directories. Tests in ./t will ALSO be run by prove but tests in
199    ./t2 will only be run by yath.
200
201 PROJECT-SPECIFIC YATH CONFIG
202
203    You can write a .yath.rc file. The file format is very simple. Create a
204    [COMMAND] section to start the configuration for a command and then
205    provide any options normally allowed by it. When yath is run inside
206    your project, it will use the config specified in the rc file, unless
207    overridden by command line options.
208
209    Note: You can also add pre-command options by placing them at the top
210    of your config file BEFORE any [cmd] markers.
211
212    Comments start with a semi-colon.
213
214    Example .yath.rc:
215
216        -pFoo ; Load the 'foo' plugin before dealing with commands.
217
218        [test]
219        -B ;Always write a bzip2-compressed log
220
221        [start]
222        -PMoose ;Always preload Moose with a persistent runner
223
224    This file is normally committed into the project's repo.
225
226  SPECIAL PATH PSEUDO-FUNCTIONS
227
228    Sometimes you want to specify files relative to the .yath.rc so that
229    the config option works from any subdirectory of the project. Other
230    times you may wish to use a shell expansion. Sometimes you want both!
231
232    rel(path/to/file)
233
234          -I rel(path/to/extra_lib)
235          -I=rel(path/to/extra_lib)
236
237      This will take the path to .yath.rc and prefix it to the path inside
238      rel(...). If for example you have /project/.yath.rc then the path
239      would become /project/path/to/extra_lib.
240
241    glob(path/*/file)
242
243          --default-search glob(subprojects/*/t)
244          --default-search=glob(subprojects/*/t)
245
246      This will add a --default-search $_ for every item found in the glob.
247      This uses the perl builtin function glob() under the hood.
248
249    relglob(path/*/file)
250
251          --default-search relglob(subprojects/*/t)
252          --default-search=relglob(subprojects/*/t)
253
254      Same as glob() except paths are relative to the .yath.rc file.
255
256 PROJECT-SPECIFIC YATH CONFIG USER OVERRIDES
257
258    You can add a .yath.user.rc file. Format is the same as the regular
259    .yath.rc file. This file will be read in addition to the regular config
260    file. Directives in this file will come AFTER the directives in the
261    primary config so it may be used to override config.
262
263    This file should not normally be committed to the project repo.
264
265 HARNESS DIRECTIVES INSIDE TESTS
266
267    yath will recognise a number of directive comments placed near the top
268    of test files. These directives should be placed after the #! line but
269    before any real code.
270
271    Real code is defined as any line that does not start with use, require,
272    BEGIN, package, or #
273
274    good example 1
275
276          #!/usr/bin/perl
277          # HARNESS-NO-FORK
278
279          ...
280
281    good example 2
282
283          #!/usr/bin/perl
284          use strict;
285          use warnings;
286
287          # HARNESS-NO-FORK
288
289          ...
290
291    bad example 1
292
293          #!/usr/bin/perl
294
295          # blah
296
297          # HARNESS-NO-FORK
298
299          ...
300
301    bad example 2
302
303          #!/usr/bin/perl
304
305          print "hi\n";
306
307          # HARNESS-NO-FORK
308
309          ...
310
311  HARNESS-NO-PRELOAD
312
313        #!/usr/bin/perl
314        # HARNESS-NO-PRELOAD
315
316    Use this if your test will fail when modules are preloaded. This will
317    tell yath to start a new perl process to run the script instead of
318    forking with preloaded modules.
319
320    Currently this implies HARNESS-NO-FORK, but that may not always be the
321    case.
322
323  HARNESS-NO-FORK
324
325        #!/usr/bin/perl
326        # HARNESS-NO-FORK
327
328    Use this if your test file cannot run in a forked process, but instead
329    must be run directly with a new perl process.
330
331    This implies HARNESS-NO-PRELOAD.
332
333  HARNESS-NO-STREAM
334
335    yath usually uses the Test2::Formatter::Stream formatter instead of
336    TAP. Some tests depend on using a TAP formatter. This option will make
337    yath use Test2::Formatter::TAP or Test::Builder::Formatter.
338
339  HARNESS-NO-IO-EVENTS
340
341    yath can be configured to use the Test2::Plugin::IOEvents plugin. This
342    plugin replaces STDERR and STDOUT in your test with tied handles that
343    fire off proper Test2::Event's when they are printed to. Most of the
344    time this is not an issue, but any fancy tests or modules which do
345    anything with STDERR or STDOUT other than print may have really messy
346    errors.
347
348    Note: This plugin is disabled by default, so you only need this
349    directive if you enable it globally but need to turn it back off for
350    select tests.
351
352  HARNESS-NO-TIMEOUT
353
354    yath will usually kill a test if no events occur within a timeout
355    (default 60 seconds). You can add this directive to tests that are
356    expected to trip the timeout, but should be allowed to continue.
357
358    NOTE: you usually are doing the wrong thing if you need to set this.
359    See: HARNESS-TIMEOUT-EVENT.
360
361  HARNESS-TIMEOUT-EVENT 60
362
363    yath can be told to alter the default event timeout from 60 seconds to
364    another value. This is the recommended alternative to
365    HARNESS-NO-TIMEOUT
366
367  HARNESS-TIMEOUT-POSTEXIT 15
368
369    yath can be told to alter the default POSTEXIT timeout from 15 seconds
370    to another value.
371
372    Sometimes a test will fork producing output in the child while the
373    parent is allowed to exit. In these cases we cannot rely on the
374    original process exit to tell us when a test is complete. In cases
375    where we have an exit, and partial output (assertions with no final
376    plan, or a plan that has not been completed) we wait for a timeout
377    period to see if any additional events come into
378
379  HARNESS-DURATION-LONG
380
381    This lets you tell yath that the test file is long-running. This is
382    primarily used when concurrency is turned on in order to run longer
383    tests earlier, and concurrently with shorter ones. There is also a yath
384    option to skip all long tests.
385
386    This duration is set automatically if HARNESS-NO-TIMEOUT is set.
387
388  HARNESS-DURATION-MEDIUM
389
390    This lets you tell yath that the test is medium.
391
392    This is the default duration.
393
394  HARNESS-DURATION-SHORT
395
396    This lets you tell yath That the test is short.
397
398  HARNESS-CATEGORY-ISOLATION
399
400    This lets you tell yath that the test cannot be run concurrently with
401    other tests. Yath will hold off and run these tests one at a time after
402    all other tests.
403
404  HARNESS-CATEGORY-IMMISCIBLE
405
406    This lets you tell yath that the test cannot be run concurrently with
407    other tests of this class. This is helpful when you have multiple tests
408    which would otherwise have to be run sequentially at the end of the
409    run.
410
411    Yath prioritizes running these tests above HARNESS-CATEGORY-LONG.
412
413  HARNESS-CATEGORY-GENERAL
414
415    This is the default category.
416
417  HARNESS-CONFLICTS-XXX
418
419    This lets you tell yath that no other test of type XXX can be run at
420    the same time as this one. You are able to set multiple conflict types
421    and yath will honor them.
422
423    XXX can be replaced with any type of your choosing.
424
425    NOTE: This directive does not alter the category of your test. You are
426    free to mark the test with LONG or MEDIUM in addition to this marker.
427
428    Example with multiple lines.
429
430          #!/usr/bin/perl
431          # DASH and space are split the same way.
432          # HARNESS-CONFLICTS-DAEMON
433          # HARNESS-CONFLICTS  MYSQL
434
435          ...
436
437    Or on a single line.
438
439          #!/usr/bin/perl
440          # HARNESS-CONFLICTS DAEMON MYSQL
441
442          ...
443
444  HARNESS-RETRY-n
445
446    This lets you specify a number (minimum n=1) of retries on test failure
447    for a specific test. HARNESS-RETRY-1 means a failing test will be run
448    twice and is equivalent to HARNESS-RETRY.
449
450  HARNESS-NO-RETRY
451
452    Use this to avoid this test being retried regardless of your retry
453    settings.
454
455MODULE DOCS
456
457    This section documents the App::Yath module itself.
458
459 SYNOPSIS
460
461    In practice you should never need to write your own yath script, or
462    construct an App::Yath instance, or even access themain instance when
463    yath is running. However some aspects of doing so are documented here
464    for completeness.
465
466    A minimum yath script looks like this:
467
468        BEGIN {
469            package App::Yath:Script;
470
471            require Time::HiRes;
472            require App::Yath;
473            require Test2::Harness::Settings;
474
475            my $settings = Test2::Harness::Settings->new(
476                harness => {
477                    orig_argv       => [@ARGV],
478                    orig_inc        => [@INC],
479                    script          => __FILE__,
480                    start           => Time::HiRes::time(),
481                    version         => $App::Yath::VERSION,
482                },
483            );
484
485            my $app = App::Yath->new(
486                argv    => \@ARGV,
487                config  => {},
488                settings => $settings,
489            );
490
491            $app->generate_run_sub('App::Yath::Script::run');
492        }
493
494        exit(App::Yath::Script::run());
495
496    It is important that most logic live in a BEGIN block. This is so that
497    goto::file can be used post-fork to execute a test script.
498
499    The actual yath script is significantly more complicated with the
500    following behaviors:
501
502    pre-process essential arguments such as -D and no-scan-plugins
503
504    re-exec with a different yath script if in developer mode and a local
505    copy is found
506
507    Parse the yath-rc config files
508
509    gather and store essential startup information
510
511 METHODS
512
513    App::Yath does not provide many methods to use externally.
514
515    $app->generate_run_sub($symbol_name)
516
517      This tells App::Yath to generate a subroutine at the specified symbol
518      name which can be run and be expected to return an exit value.
519
520    $lib_path = $app->app_path()
521
522      Get the include directory App::Yath was loaded from.
523
524SOURCE
525
526    The source code repository for Test2-Harness can be found at
527    http://github.com/Test-More/Test2-Harness/.
528
529MAINTAINERS
530
531    Chad Granum <exodist@cpan.org>
532
533AUTHORS
534
535    Chad Granum <exodist@cpan.org>
536
537COPYRIGHT
538
539    Copyright 2020 Chad Granum <exodist7@gmail.com>.
540
541    This program is free software; you can redistribute it and/or modify it
542    under the same terms as Perl itself.
543
544    See http://dev.perl.org/licenses/
545
546

README.md

1# NAME
2
3App::Yath - Yet Another Test Harness (Test2-Harness) Command Line Interface
4(CLI)
5
6# DESCRIPTION
7
8This is the primary documentation for `yath`, [App::Yath](https://metacpan.org/pod/App%3A%3AYath), [Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness).
9
10The canonical source of up-to-date command options are the help output when
11using `$ yath help` and `$ yath help COMMAND`.
12
13This document is mainly an overview of `yath` usage and common recipes.
14
15[App::Yath](https://metacpan.org/pod/App%3A%3AYath) is an alternative to [App::Prove](https://metacpan.org/pod/App%3A%3AProve), and [Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness) is an alternative to [Test::Harness](https://metacpan.org/pod/Test%3A%3AHarness). It is not designed to
16replace [Test::Harness](https://metacpan.org/pod/Test%3A%3AHarness)/prove. [Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness) is designed to take full
17advantage of the rich data [Test2](https://metacpan.org/pod/Test2) can provide. [Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness) is also able to
18use non-core modules and provide more functionality than prove can achieve with
19its restrictions.
20
21# PLATFORM SUPPORT
22
23[Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness)/[App::Yath](https://metacpan.org/pod/App%3A%3AYath) is is focused on unix-like platforms. Most
24development happens on linux, but bsd, macos, etc should work fine as well.
25
26Patches are welcome for any/all platforms, but the primary author (Chad
27'Exodist' Granum) does not directly develop against non-unix platforms.
28
29## WINDOWS
30
31Currently windows is not supported, and it is known that the package will not
32install on windows. Patches are be welcome, and it would be great if someone
33wanted to take on the windows-support role, but it is not a primary goal for
34the project.
35
36# OVERVIEW
37
38To use [Test2::Harness](https://metacpan.org/pod/Test2%3A%3AHarness), you use the `yath` command. Yath will find the tests
39(or use the ones you specify) and run them. As it runs, it will output
40diagnostic information such as failures. At the end, yath will print a summary
41of the test run.
42
43`yath` can be thought of as a more powerful alternative to `prove`
44([Test::Harness](https://metacpan.org/pod/Test%3A%3AHarness))
45
46# RECIPES
47
48These are common recipes for using `yath`.
49
50## RUN PROJECT TESTS
51
52    $ yath
53
54Simply running yath with no arguments means "Run all tests for the current
55project". Yath will look for tests in `./t`, `./t2`, and `./test.pl` and
56run any which are found.
57
58Normally this implies the `test` command but will instead imply the `run`
59command if a persistent test runner is detected.
60
61## PRELOAD MODULES
62
63Yath has the ability to preload modules. Yath normally forks to start new
64tests, so preloading can reduce the time spent loading modules over and over in
65each test.
66
67Note that some tests may depend on certain modules not being loaded. In these
68cases you can add the `# HARNESS-NO-PRELOAD` directive to the top of the test
69files that cannot use preload.
70
71### SIMPLE PRELOAD
72
73Any module can be preloaded:
74
75    $ yath -PMoose
76
77You can preload as many modules as you want:
78
79    $ yath -PList::Util -PScalar::Util
80
81### COMPLEX PRELOAD
82
83If your preload is a subclass of [Test2::Harness::Runner::Preload](https://metacpan.org/pod/Test2%3A%3AHarness%3A%3ARunner%3A%3APreload) then more
84complex preload behavior is possible. See those docs for more info.
85
86## LOGGING
87
88### RECORDING A LOG
89
90You can turn on logging with a flag. The filename of the log will be printed at
91the end.
92
93    $ yath -L
94    ...
95    Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl
96
97The event log can be quite large. It can be compressed with bzip2.
98
99    $ yath -B
100    ...
101    Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2
102
103gzip compression is also supported.
104
105    $ yath -G
106    ...
107    Wrote log file: test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.gz
108
109`-B` and `-G` both imply `-L`.
110
111### REPLAYING FROM A LOG
112
113You can replay a test run from a log file:
114
115    $ yath test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2
116
117This will be significantly faster than the initial run as no tests are actually
118being executed. All events are simply read from the log, and processed by the
119harness.
120
121You can change display options and limit rendering/processing to specific test
122jobs from the run:
123
124    $ yath test-logs/2017-09-12~22:44:34~1505281474~25709.jsonl.bz2 -v [TEST UUID(S)]
125
126Note: This is done using the `$ yath replay ...` command. The `replay`
127command is implied if the first argument is a log file.
128
129## PER-TEST TIMING DATA
130
131The `-T` option will cause each test file to report how long it took to run.
132
133    $ yath -T
134
135    ( PASSED )  job  1    t/yath_script.t
136    (  TIME  )  job  1    Startup: 0.07692s | Events: 0.01170s | Cleanup: 0.00190s | Total: 0.09052s
137
138## PERSISTENT RUNNER
139
140yath supports starting a yath session that waits for tests to run. This is very
141useful when combined with preload.
142
143### STARTING
144
145This starts the server. Many options available to the 'test' command will work
146here but not all. See `$ yath help start` for more info.
147
148    $ yath start
149
150### RUNNING
151
152This will run tests using the persistent runner. By default, it will search for
153tests just like the 'test' command. Many options available to the `test`
154command will work for this as well. See `$ yath help run` for more details.
155
156    $ yath run
157
158### STOPPING
159
160Stopping a persistent runner is easy.
161
162    $ yath stop
163
164### INFORMATIONAL
165
166The `which` command will tell you which persistent runner will be used. Yath
167searches for the persistent runner in the current directory, then searches in
168parent directories until it either hits the root directory, or finds the
169persistent runner tracking file.
170
171    $ yath which
172
173The `watch` command will tail the runner's log files.
174
175    $ yath watch
176
177### PRELOAD + PERSISTENT RUNNER
178
179You can use preloads with the `yath start` command. In this case, yath will
180track all the modules pulled in during preload. If any of them change, the
181server will reload itself to bring in the changes. Further, modified modules
182will be blacklisted so that they are not preloaded on subsequent reloads. This
183behavior is useful if you are actively working on a module that is normally
184preloaded.
185
186## MAKING YOUR PROJECT ALWAYS USE YATH
187
188    $ yath init
189
190The above command will create `test.pl`. `test.pl` is automatically run by
191most build utils, in which case only the exit value matters. The generated
192`test.pl` will run `yath` and execute all tests in the `./t` and/or `./t2`
193directories. Tests in `./t` will ALSO be run by prove but tests in `./t2`
194will only be run by yath.
195
196## PROJECT-SPECIFIC YATH CONFIG
197
198You can write a `.yath.rc` file. The file format is very simple. Create a
199`[COMMAND]` section to start the configuration for a command and then
200provide any options normally allowed by it. When `yath` is run inside your
201project, it will use the config specified in the rc file, unless overridden
202by command line options.
203
204**Note:** You can also add pre-command options by placing them at the top of
205your config file _BEFORE_ any `[cmd]` markers.
206
207Comments start with a semi-colon.
208
209Example .yath.rc:
210
211    -pFoo ; Load the 'foo' plugin before dealing with commands.
212
213    [test]
214    -B ;Always write a bzip2-compressed log
215
216    [start]
217    -PMoose ;Always preload Moose with a persistent runner
218
219This file is normally committed into the project's repo.
220
221### SPECIAL PATH PSEUDO-FUNCTIONS
222
223Sometimes you want to specify files relative to the .yath.rc so that the config
224option works from any subdirectory of the project. Other times you may wish to
225use a shell expansion. Sometimes you want both!
226
227- rel(path/to/file)
228
229        -I rel(path/to/extra_lib)
230        -I=rel(path/to/extra_lib)
231
232    This will take the path to `.yath.rc` and prefix it to the path inside
233    `rel(...)`. If for example you have `/project/.yath.rc` then the path would
234    become `/project/path/to/extra_lib`.
235
236- glob(path/\*/file)
237
238        --default-search glob(subprojects/*/t)
239        --default-search=glob(subprojects/*/t)
240
241    This will add a `--default-search $_` for every item found in the glob. This
242    uses the perl builtin function `glob()` under the hood.
243
244- relglob(path/\*/file)
245
246        --default-search relglob(subprojects/*/t)
247        --default-search=relglob(subprojects/*/t)
248
249    Same as `glob()` except paths are relative to the `.yath.rc` file.
250
251## PROJECT-SPECIFIC YATH CONFIG USER OVERRIDES
252
253You can add a `.yath.user.rc` file. Format is the same as the regular
254`.yath.rc` file. This file will be read in addition to the regular config
255file. Directives in this file will come AFTER the directives in the primary
256config so it may be used to override config.
257
258This file should not normally be committed to the project repo.
259
260## HARNESS DIRECTIVES INSIDE TESTS
261
262`yath` will recognise a number of directive comments placed near the top of
263test files. These directives should be placed after the `#!` line but
264before any real code.
265
266Real code is defined as any line that does not start with use, require, BEGIN, package, or #
267
268- good example 1
269
270        #!/usr/bin/perl
271        # HARNESS-NO-FORK
272
273        ...
274
275- good example 2
276
277        #!/usr/bin/perl
278        use strict;
279        use warnings;
280
281        # HARNESS-NO-FORK
282
283        ...
284
285- bad example 1
286
287        #!/usr/bin/perl
288
289        # blah
290
291        # HARNESS-NO-FORK
292
293        ...
294
295- bad example 2
296
297        #!/usr/bin/perl
298
299        print "hi\n";
300
301        # HARNESS-NO-FORK
302
303        ...
304
305### HARNESS-NO-PRELOAD
306
307    #!/usr/bin/perl
308    # HARNESS-NO-PRELOAD
309
310Use this if your test will fail when modules are preloaded. This will tell yath
311to start a new perl process to run the script instead of forking with preloaded
312modules.
313
314Currently this implies HARNESS-NO-FORK, but that may not always be the case.
315
316### HARNESS-NO-FORK
317
318    #!/usr/bin/perl
319    # HARNESS-NO-FORK
320
321Use this if your test file cannot run in a forked process, but instead must be
322run directly with a new perl process.
323
324This implies HARNESS-NO-PRELOAD.
325
326### HARNESS-NO-STREAM
327
328`yath` usually uses the [Test2::Formatter::Stream](https://metacpan.org/pod/Test2%3A%3AFormatter%3A%3AStream) formatter instead of TAP.
329Some tests depend on using a TAP formatter. This option will make `yath` use
330[Test2::Formatter::TAP](https://metacpan.org/pod/Test2%3A%3AFormatter%3A%3ATAP) or [Test::Builder::Formatter](https://metacpan.org/pod/Test%3A%3ABuilder%3A%3AFormatter).
331
332### HARNESS-NO-IO-EVENTS
333
334`yath` can be configured to use the [Test2::Plugin::IOEvents](https://metacpan.org/pod/Test2%3A%3APlugin%3A%3AIOEvents) plugin. This
335plugin replaces STDERR and STDOUT in your test with tied handles that fire off
336proper [Test2::Event](https://metacpan.org/pod/Test2%3A%3AEvent)'s when they are printed to. Most of the time this is not
337an issue, but any fancy tests or modules which do anything with STDERR or
338STDOUT other than print may have really messy errors.
339
340**Note:** This plugin is disabled by default, so you only need this directive if
341you enable it globally but need to turn it back off for select tests.
342
343### HARNESS-NO-TIMEOUT
344
345`yath` will usually kill a test if no events occur within a timeout (default
34660 seconds). You can add this directive to tests that are expected to trip the
347timeout, but should be allowed to continue.
348
349NOTE: you usually are doing the wrong thing if you need to set this. See:
350`HARNESS-TIMEOUT-EVENT`.
351
352### HARNESS-TIMEOUT-EVENT 60
353
354`yath` can be told to alter the default event timeout from 60 seconds to another
355value. This is the recommended alternative to HARNESS-NO-TIMEOUT
356
357### HARNESS-TIMEOUT-POSTEXIT 15
358
359`yath` can be told to alter the default POSTEXIT timeout from 15 seconds to another value.
360
361Sometimes a test will fork producing output in the child while the parent is
362allowed to exit. In these cases we cannot rely on the original process exit to
363tell us when a test is complete. In cases where we have an exit, and partial
364output (assertions with no final plan, or a plan that has not been completed)
365we wait for a timeout period to see if any additional events come into
366
367### HARNESS-DURATION-LONG
368
369This lets you tell `yath` that the test file is long-running. This is
370primarily used when concurrency is turned on in order to run longer tests
371earlier, and concurrently with shorter ones. There is also a `yath` option to
372skip all long tests.
373
374This duration is set automatically if HARNESS-NO-TIMEOUT is set.
375
376### HARNESS-DURATION-MEDIUM
377
378This lets you tell `yath` that the test is medium.
379
380This is the default duration.
381
382### HARNESS-DURATION-SHORT
383
384This lets you tell `yath` That the test is short.
385
386### HARNESS-CATEGORY-ISOLATION
387
388This lets you tell `yath` that the test cannot be run concurrently with other
389tests. Yath will hold off and run these tests one at a time after all other
390tests.
391
392### HARNESS-CATEGORY-IMMISCIBLE
393
394This lets you tell `yath` that the test cannot be run concurrently with other
395tests of this class. This is helpful when you have multiple tests which would
396otherwise have to be run sequentially at the end of the run.
397
398Yath prioritizes running these tests above HARNESS-CATEGORY-LONG.
399
400### HARNESS-CATEGORY-GENERAL
401
402This is the default category.
403
404### HARNESS-CONFLICTS-XXX
405
406This lets you tell `yath` that no other test of type XXX can be run at the
407same time as this one. You are able to set multiple conflict types and `yath`
408will honor them.
409
410XXX can be replaced with any type of your choosing.
411
412NOTE: This directive does not alter the category of your test. You are free
413to mark the test with LONG or MEDIUM in addition to this marker.
414
415- Example with multiple lines.
416
417        #!/usr/bin/perl
418        # DASH and space are split the same way.
419        # HARNESS-CONFLICTS-DAEMON
420        # HARNESS-CONFLICTS  MYSQL
421
422        ...
423
424- Or on a single line.
425
426        #!/usr/bin/perl
427        # HARNESS-CONFLICTS DAEMON MYSQL
428
429        ...
430
431### HARNESS-RETRY-n
432
433This lets you specify a number (minimum n=1) of retries on test failure
434for a specific test. HARNESS-RETRY-1 means a failing test will be run twice
435and is equivalent to HARNESS-RETRY.
436
437### HARNESS-NO-RETRY
438
439Use this to avoid this test being retried regardless of your retry settings.
440
441# MODULE DOCS
442
443This section documents the [App::Yath](https://metacpan.org/pod/App%3A%3AYath) module itself.
444
445## SYNOPSIS
446
447In practice you should never need to write your own yath script, or construct
448an [App::Yath](https://metacpan.org/pod/App%3A%3AYath) instance, or even access themain instance when yath is running.
449However some aspects of doing so are documented here for completeness.
450
451A minimum yath script looks like this:
452
453    BEGIN {
454        package App::Yath:Script;
455
456        require Time::HiRes;
457        require App::Yath;
458        require Test2::Harness::Settings;
459
460        my $settings = Test2::Harness::Settings->new(
461            harness => {
462                orig_argv       => [@ARGV],
463                orig_inc        => [@INC],
464                script          => __FILE__,
465                start           => Time::HiRes::time(),
466                version         => $App::Yath::VERSION,
467            },
468        );
469
470        my $app = App::Yath->new(
471            argv    => \@ARGV,
472            config  => {},
473            settings => $settings,
474        );
475
476        $app->generate_run_sub('App::Yath::Script::run');
477    }
478
479    exit(App::Yath::Script::run());
480
481It is important that most logic live in a BEGIN block. This is so that
482[goto::file](https://metacpan.org/pod/goto%3A%3Afile) can be used post-fork to execute a test script.
483
484The actual yath script is significantly more complicated with the following behaviors:
485
486- pre-process essential arguments such as -D and no-scan-plugins
487- re-exec with a different yath script if in developer mode and a local copy is found
488- Parse the yath-rc config files
489- gather and store essential startup information
490
491## METHODS
492
493App::Yath does not provide many methods to use externally.
494
495- $app->generate\_run\_sub($symbol\_name)
496
497    This tells App::Yath to generate a subroutine at the specified symbol name
498    which can be run and be expected to return an exit value.
499
500- $lib\_path = $app->app\_path()
501
502    Get the include directory App::Yath was loaded from.
503
504# SOURCE
505
506The source code repository for Test2-Harness can be found at
507`http://github.com/Test-More/Test2-Harness/`.
508
509# MAINTAINERS
510
511- Chad Granum <exodist@cpan.org>
512
513# AUTHORS
514
515- Chad Granum <exodist@cpan.org>
516
517# COPYRIGHT
518
519Copyright 2020 Chad Granum <exodist7@gmail.com>.
520
521This program is free software; you can redistribute it and/or
522modify it under the same terms as Perl itself.
523
524See `http://dev.perl.org/licenses/`
525