1App::Yath::Util(3) User Contributed Perl Documentation App::Yath::Util(3)
2
3
4
6 App::Yath::Util - General utilities for yath that do not fit anywhere
7 else.
8
10 This package exports several tools used throughout yath that did not
11 fit into any other package.
12
14 use App::Yath::Util qw{
15 find_pfile
16 find_in_updir
17 is_generated_test_pl
18 fit_to_width
19 isolate_stdout
20 find_yath
21 };
22
24 Note that nothing is exported by default, you must request each
25 function to import.
26
27 $path_to_pfile = find_pfile($settings, %params)
28 The first argument must be an instance of Test2::Harness::Settings.
29
30 Currently the only supported param is "vivify", when set to true
31 the pfile will be created if one does not already exist.
32
33 The pfile is a file that tells yath that a persistent runner is
34 active, and how to communicate with it.
35
36 $path_to_file = find_in_updir($file_name)
37 Look for $file_name in the current directory or any parent
38 directory.
39
40 $bool = is_generated_test_pl($path_to_test_file)
41 Check if the specified test file was generated by the "yath init"
42 command.
43
44 fit_to_width($width, $join, $text)
45 This will split the $text on space, and then recombine it using
46 $join inserting newlines as necessary in an attempt to fit the text
47 into $width horizontal characters. If any words are larger than
48 $width they will not be split and text-wrapping may occur if used
49 for terminal display.
50
51 $stdout = isolate_stdout()
52 This will close STDOUT and reopen it to point at STDERR. The result
53 of this is that any print statement that does not specify a
54 fielhandle will print to STDERR instead of STDOUT, in addition any
55 print directly to STDOUT will instead go to STDERR. A filehandle to
56 the real STDOUT is returned for you to use when you actually want
57 to write to STDOUT.
58
59 This is used by some yath processes that need to print structured
60 data to STDOUT without letting any third part modules they may load
61 write to the real STDOUT.
62
63 $path_to_script = find_yath()
64 This will attempt to find the "yath" command line script. When
65 possible this will return the path that was used to launch yath. If
66 yath was not run to start the process it will search the paths
67 specified in the Config module. This will throw an exception if the
68 script cannot be found.
69
70 Note: The result is cached so that subsequent calls will return the
71 same path even if something installs a new yath script in another
72 location that would otherwise be found first. This guarentees that
73 a single process will not switch scripts.
74
76 The source code repository for Test2-Harness can be found at
77 http://github.com/Test-More/Test2-Harness/.
78
80 Chad Granum <exodist@cpan.org>
81
83 Chad Granum <exodist@cpan.org>
84
86 Copyright 2020 Chad Granum <exodist7@gmail.com>.
87
88 This program is free software; you can redistribute it and/or modify it
89 under the same terms as Perl itself.
90
91 See http://dev.perl.org/licenses/
92
93
94
95perl v5.36.0 2022-09-08 App::Yath::Util(3)