blib/lib/WebDyne/Util.pm

filter: Statementstmt 62.1% 166 / 267 Branchbran 33.8% 46 / 136 Conditioncond 22.9% 22 / 96 MC/DCmcdc 7.4% 4 / 54 Subroutinesub 79.3% 23 / 29 Podpod 0.0% 0 / 12 totaltotal 43.9% 261 / 594 CC 112 SCAR 50.0
CC
112
Cov
47%
debug
578.0
import
232.6
__ANON__
72.0
CRAP 149.0
« bin/wdrender ↑ Summary lib/WebDyne/Install/Apache/Constant.pm »
1 #
2 # This file is part of WebDyne.
3 #
4 # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 # Full license text is available at:
10 #
11 # <http://dev.perl.org/licenses/>
12 #
13 package WebDyne::Util;
14  
15  
16 # Compiler Pragma
17 #
18 70 ▶sub BEGIN {$^W=0}
Subroutine BEGIN: called CC=1 SCAR=0.0
19 70 ▶use strict qw(vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 70 ▶use vars qw($VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 70 ▶no warnings qw(uninitialized redefine once);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24  
25 # Package wide vars and defaults, initialised in BEGIN
26 #
27 our (
28 70 $WEBDYNE_DEBUG,
29 $WEBDYNE_DEBUG_FILE,
30 $WEBDYNE_DEBUG_FILTER,
31 $WEBDYNE_DEBUG_MAX_LINES,
32 $WEBDYNE_DEBUG_MAX_LENGTH,
33 $WEBDYNE_DEBUG_NO_COLOUR,
34 $WEBDYNE_ERROR_TEXT_SHOW_ALL,
35 $WEBDYNE_ERROR_TEXT_CHAR_MAX
36 );
37  
38  
39 # External modules
40 #
41 70 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 70 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 70 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 70 ▶use Fcntl;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 70 ▶use POSIX qw(strftime);
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47  
48 # Use Exporter
49 #
50 70 require Exporter;
51  
52  
53 # Exports
54 #
55 70 @EXPORT=qw(err errstr errclr errdump errsubst errstack errnofatal debug);
56 70 @EXPORT_OK=qw(perl_inc_dn apache_startup apache_shutdown);
57 70 %EXPORT_TAGS=(all => [@EXPORT, @EXPORT_OK]);
58  
59  
60 # Version information
61 #
62 70 $VERSION='3.029';
63  
64  
65 # Var to hold package wide hash, for data shared across package, and error stack
66 #
67 70 my (%Package, @Err);
68  
69  
70 # All done. Positive return
71 #
72 70 1;
73  
74  
75 #==================================================================================================
76  
77 # Packace init, attempt to load optional Time::HiRes module
78 #
79 70 ▶BEGIN {
Subroutine BEGIN: called CC=4 SCAR=14.0
80 70 eval {require Time::HiRes; Time::HiRes->import(qw(time gettimeofday))};
81 my %config=(
82 WEBDYNE_DEBUG => '',
83 WEBDYNE_DEBUG_FILE => '',
84 WEBDYNE_DEBUG_FILTER => '',
85 WEBDYNE_DEBUG_MAX_LINES => 6,
86 WEBDYNE_DEBUG_MAX_LENGTH => 1024,
87 WEBDYNE_DEBUG_NO_COLOUR => $ENV{'WEBDYNE_DEBUG_NO_COLOR'},
88 WEBDYNE_ERROR_TEXT_SHOW_ALL => '',
89 70 ▶ WEBDYNE_ERROR_TEXT_CHAR_MAX => $ENV{'WEBDYNE_ERROR_TEXT_CHAR_MAX'} || 72,
Condition50%1/2
$ENV{'WEBDYNE_ERROR_TEXT_CHAR_MAX'} || 72
l!l
070
MC/DC0%0/1
$ENV{'WEBDYNE_ERROR_TEXT_CHAR_MAX'} || 72
$ENV{'WEBDYNE_ERROR_TEXT_CHAR_MAX'}
Truth table50%1/2
A
A= $ENV{'WEBDYNE_ERROR_TEXT_CHAR_MAX'}
Aresult
11
00
90 );
91 70 ▶ while (my($name, $value)=each(%config)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %config) 560 70 630
92 560 ▶ ${__PACKAGE__."::${name}"}=defined($ENV{$name}) ? $ENV{$name} : $value;
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{$name} ? : 0 560 560
93 }
94 }
95  
96  
97 424 ▶sub import {
Subroutine import: called CC=20 SCAR=54.5
98  
99  
100 # Get message
101 #
102 424 my ($message, @param)=@_;
103  
104  
105 # Get who is calling us
106 #
107 424 ▶ my $caller=(caller(0))[0] || return undef;
Condition50%1/2
(caller 0)[0] || (return undef)
l!l
4240
MC/DC0%0/1
(caller 0)[0] || (return undef)
(caller 0)[0]
Truth table50%1/2
A
A= (caller 0)[0]
Aresult
11
00
108  
109  
110 # fn, fh we will write to
111 #
112 424 my ($debug_fn, $debug_fh);
113  
114  
115 # Environment var overrides all
116 #
117 424 ▶ if ($debug_fn=$WEBDYNE_DEBUG_FILE) {
Branch: 4 branches
BranchTrueFalseTotal
if ($debug_fn = $WebDyne::Util::WEBDYNE_DEBUG_FILE) { } 0 424 424
elsif ($WebDyne::Util::WEBDYNE_DEBUG) { } 0 424 424
elsif (ref(my $debug_hr = ${"${caller}::DEBUG";}) eq 'HASH') { } 0 424 424
elsif (not ref($debug_fn = ${"${caller}::DEBUG";}) and ${"${caller}::DEBUG";}) { } 0 424 424
118  
119 # fn is whatever spec'd
120 #
121 0 ▶ $debug_fh=IO::File->new($debug_fn, O_CREAT | O_APPEND | O_WRONLY) || do {
Condition0%0/3
'IO::File'->new($debug_fn, 1089) || do { warn "unable to open file '${debug_fn}', $!"; undef }
l!l&&r!l&&!r
000
MC/DC0%0/2
'IO::File'->new($debug_fn, 1089) || do { warn "unable to open file '${debug_fn}', $!"; undef }
'IO::File'->new($debug_fn, 1089) do { warn "unable to open file '${debug_fn}', $!"; undef }
Truth table0%0/3
A || B
A= 'IO::File'->new($debug_fn, 1089)B= do { warn "unable to open file '${debug_fn}', $!"; undef }
ABresult
1X1
011
000
122 0 warn("unable to open file '$debug_fn', $!");
123 0 undef;
124 };
125  
126 }
127 elsif ($WEBDYNE_DEBUG) {
128  
129  
130 # fh is stderr
131 #
132 0 $debug_fh=\*STDERR;
133  
134  
135 }
136 424 elsif (ref(my $debug_hr=${"${caller}::DEBUG"}) eq 'HASH') {
137  
138  
139 # Debug is hash ref, extract filename etc and open
140 #
141 0 ▶ $debug_fn=$debug_hr->{'file'} || $debug_hr->{'filename'};
Condition0%0/3
$debug_hr->{'file'} || $debug_hr->{'filename'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$debug_hr->{'file'} || $debug_hr->{'filename'}
$debug_hr->{'file'} $debug_hr->{'filename'}
Truth table0%0/3
A || B
A= $debug_hr->{'file'}B= $debug_hr->{'filename'}
ABresult
1X1
011
000
142 0 my ($mode, $package)=@{$debug_hr}{qw(mode package)};
143 0 ▶ if ($debug_fn && ($package ? ($package eq $caller) : 1)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($debug_fn and $package ? $package eq $caller : 1) { } 0 0 0
elsif (not $debug_fn) { } 0 0 0
$package ? : 0 0 0
Condition0%0/3
$debug_fn and $package ? $package eq $caller : 1
!ll&&!rl&&r
000
MC/DC0%0/2
$debug_fn and $package ? $package eq $caller : 1
$debug_fn $package ? $package eq $caller : 1
Truth table0%0/3
A and B
A= $debug_fnB= $package ? $package eq $caller : 1
ABresult
0X0
100
111
144 0 ▶ $mode ||= O_CREAT | O_APPEND | O_WRONLY;
Condition0%0/2
$mode ||= 1089
l!l
00
MC/DC0%0/1
$mode ||= 1089
$mode
Truth table0%0/2
A
A= $mode
Aresult
11
00
145 $debug_fh=(
146 $Package{'debug_fh'}{$debug_fn} ||= (
147 0 ▶ IO::File->new($debug_fn, $mode) || do {
Condition0%0/6
$Package{"debug_fh"}{$debug_fn} ||= "IO::File"->new($debug_fn, $mode) || do { warn "unable to open file '${debug_fn}', $!"; undef }
l!l&&r!l&&!r
000
'IO::File'->new($debug_fn, $mode) || do { warn "unable to open file '${debug_fn}', $!"; undef }
l!l&&r!l&&!r
000
MC/DC0%0/3
$Package{"debug_fh"}{$debug_fn} ||= "IO::File"->new($debug_fn, $mode) || do { warn "unable to open file '${debug_fn}', $!"; undef }
$Package{"debug_fh"}{$debug_fn} 'IO::File'->new($debug_fn, $mode) do { warn "unable to open file '${debug_fn}', $!"; undef }
Truth table0%0/4
A ||= B || C
A= $Package{"debug_fh"}{$debug_fn}B= 'IO::File'->new($debug_fn, $mode)C= do { warn "unable to open file '${debug_fn}', $!"; undef }
ABCresult
1XX1
01X1
0011
0000
148 0 warn("unable to open file '$debug_fn', $!");
149 0 undef;
150 }
151 ));
152 }
153 elsif (!$debug_fn) {
154 0 warn(sprintf('no file name specified in DEBUG hash %s', Dumper($debug_hr)));
155 }
156  
157 }
158 424 ▶ elsif (!ref($debug_fn=${"${caller}::DEBUG"}) && ${"${caller}::DEBUG"}) {
Condition33%1/3
not ref($debug_fn = ${"${caller}::DEBUG";}) and ${"${caller}::DEBUG";}
!ll&&!rl&&r
04240
MC/DC0%0/2
not ref($debug_fn = ${"${caller}::DEBUG";}) and ${"${caller}::DEBUG";}
not ref($debug_fn = ${"${caller}::DEBUG";}) ${"${caller}::DEBUG";}
Truth table33%1/3
not(A) and B
A= not ref($debug_fn = ${"${caller}::DEBUG";})B= ${"${caller}::DEBUG";}
ABresult
0X0
100
111
159  
160 # Just file name spec'd. Open
161 #
162 $debug_fh=(
163 $Package{'debug_fh'}{$debug_fn} ||= (
164 0 ▶ IO::File->new($debug_fn, O_CREAT | O_APPEND | O_WRONLY) || do {
Condition0%0/6
$Package{"debug_fh"}{$debug_fn} ||= "IO::File"->new($debug_fn, 1089) || do { warn "unable to open file '${debug_fn}', $!"; undef }
l!l&&r!l&&!r
000
'IO::File'->new($debug_fn, 1089) || do { warn "unable to open file '${debug_fn}', $!"; undef }
l!l&&r!l&&!r
000
MC/DC0%0/3
$Package{"debug_fh"}{$debug_fn} ||= "IO::File"->new($debug_fn, 1089) || do { warn "unable to open file '${debug_fn}', $!"; undef }
$Package{"debug_fh"}{$debug_fn} 'IO::File'->new($debug_fn, 1089) do { warn "unable to open file '${debug_fn}', $!"; undef }
Truth table0%0/4
A ||= B || C
A= $Package{"debug_fh"}{$debug_fn}B= 'IO::File'->new($debug_fn, 1089)C= do { warn "unable to open file '${debug_fn}', $!"; undef }
ABCresult
1XX1
01X1
0011
0000
165 0 warn("unable to open file '$debug_fn', $!");
166 0 undef;
167 }
168 ));
169 }
170  
171  
172 # After all that did we get a file handle ? If so, import the debug handler
173 #
174 424 ▶ if ($debug_fh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug_fh) { } 0 424 424
175  
176 # Yes, setup debug routine
177 #
178 0 $debug_fh->autoflush(1);
179 0 $Package{'debug_fh'}=$debug_fh;
180  
181 0 if (0) { # Don't do it this way anymore, use a proper debug function and export
182 0 ▶ *{"${caller}::debug"}=sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
183 0 local $|=1;
184 0 ▶ my $method=(caller(1))[3] || 'main';
Condition0%0/2
(caller 1)[3] || 'main'
l!l
00
MC/DC0%0/1
(caller 1)[3] || 'main'
(caller 1)[3]
Truth table0%0/2
A
A= (caller 1)[3]
Aresult
11
00
185 0 (my $subroutine=$method)=~s/^.*:://;
186 0 ▶ if ($ENV{'WEBDYNE_DEBUG'} && ($ENV{'WEBDYNE_DEBUG'} ne '1')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'WEBDYNE_DEBUG'} and $ENV{'WEBDYNE_DEBUG'} ne '1') { } 0 0 0
Condition0%0/3
$ENV{"WEBDYNE_DEBUG"} and $ENV{"WEBDYNE_DEBUG"} ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"WEBDYNE_DEBUG"} and $ENV{"WEBDYNE_DEBUG"} ne 1
$ENV{"WEBDYNE_DEBUG"} $ENV{"WEBDYNE_DEBUG"} ne 1
Truth table0%0/3
A and B
A= $ENV{"WEBDYNE_DEBUG"}B= $ENV{"WEBDYNE_DEBUG"} ne 1
ABresult
0X0
100
111
187 0 my @debug_target=split(/[,;]/, $ENV{'WEBDYNE_DEBUG'});
188 0 foreach my $debug_target (@debug_target) {
189 0 ▶ if (($caller eq $debug_target) || ($method=~/\Q$debug_target\E$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller eq $debug_target or $method =~ /\Q$debug_target\E$/) 0 0 0
Condition0%0/3
$caller eq $debug_target or $method =~ /\Q$debug_target\E$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$caller eq $debug_target or $method =~ /\Q$debug_target\E$/
$caller eq $debug_target $method =~ /\Q$debug_target\E$/
Truth table0%0/3
A or B
A= $caller eq $debug_targetB= $method =~ /\Q$debug_target\E$/
ABresult
1X1
011
000
190 0 CORE::print $debug_fh "[$subroutine] ", sprintf(shift(), @_), $/;
191 }
192 }
193 }
194 else {
195 0 ▶ CORE::print $debug_fh "[$subroutine] ", $_[1] ? sprintf(shift(), @_) : $_[0], $/;
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
196 }
197 }
198 unless UNIVERSAL::can($caller, 'debug');
199 *{"${caller}::Dumper"}=\&Data::Dumper::Dumper
200 unless UNIVERSAL::can($caller, 'Dumper');
201 }
202  
203 }
204 else {
205  
206 # No, null our debug and Dumper routine
207 #
208 #*{"${caller}::debug"}=sub { }
209 # unless UNIVERSAL::can($caller, 'debug');
210 #*{"${caller}::Dumper"}=sub { }
211 # unless UNIVERSAL::can($caller, 'Dumper');
212  
213 }
214  
215  
216 # Setup file handle for error backtrace
217 #
218 424 ▶ if (my $fn=${"${caller}::ERROR"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fn = ${"${caller}::ERROR";}) 0 424 424
219  
220 # Just file name spec'd. Log
221 #
222 0 $Package{'error_fn'}{$fn}++
223  
224 }
225  
226  
227 # Done
228 #
229 424 goto &Exporter::import;
230  
231 }
232  
233  
234 1763 ▶sub debug {
Subroutine debug: called CC=25 SCAR=63.6
Pod undocumented
235  
236  
237 # Send debug message to log file. Turn off buffering and get file handle
238 #
239 1763 my ($debug, @param)=@_;
240 1763 local $|=1;
241 1763 ▶ my $debug_fh=$Package{'debug_fh'} ||
Condition50%1/2
$Package{'debug_fh'} || (return undef)
l!l
01763
MC/DC0%0/1
$Package{'debug_fh'} || (return undef)
$Package{'debug_fh'}
Truth table50%1/2
A
A= $Package{'debug_fh'}
Aresult
11
00
242 return undef;
243  
244  
245 # Get caller, iterate until not eval
246 #
247 0 ▶ my $caller=(caller(0))[0] ||
Condition0%0/2
(caller 0)[0] || (return undef)
l!l
00
MC/DC0%0/1
(caller 0)[0] || (return undef)
(caller 0)[0]
Truth table0%0/2
A
A= (caller 0)[0]
Aresult
11
00
248 return undef;
249 0 my ($eval_fg, $method);
250 0 { my $i=1; while(1) {
251 0 my @caller=caller($i++);
252 0 ▶ last unless @caller;
Branch: 1 branch
BranchTrueFalseTotal
unless @caller 0 0 0
253 0 ▶ $method=$caller[3] || 'main';
Condition0%0/2
$caller[3] || 'main'
l!l
00
MC/DC0%0/1
$caller[3] || 'main'
$caller[3]
Truth table0%0/2
A
A= $caller[3]
Aresult
11
00
254 0 ▶ if ($method=~/\(eval\)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method =~ /\(eval\)/) 0 0 0
255 0 $eval_fg++;
256 0 next;
257 }
258 0 last;
259 }}
260 0 (my $subroutine=$method)=~s/^.*:://;
261 0 (my $class=$method)=~s/::\Q${subroutine}\E$//;
262 0 ▶ $subroutine.='(eval)' if $eval_fg;
Branch: 1 branch
BranchTrueFalseTotal
if $eval_fg 0 0 0
263  
264  
265 # Time in human readable format
266 #
267 0 my ($sec, $msec)=gettimeofday();
268 0 my $timestamp=strftime("%H:%M:%S", localtime($sec)) . sprintf('.%06d', $msec);
269  
270  
271 # Get the debug message
272 #
273 #local $SIG{__WARN__}=sub { CORE::die("SPRINTF: ". Dumper([$debug, @param])) }; #uncomment if want to trace any missing sprintf params
274 #local $SIG{__WARN__}=sub { require Carp; &Carp::confess(@_) }; #uncomment if want to trace any missing sprintf params
275 0 ▶ $debug=@param ? sprintf($debug, map { defined($_) ? $_ : 'undef' } @param) : $debug;
Branch: 2 branches
BranchTrueFalseTotal
@param ? : 0 0 0
defined $_ ? : 0 0 0
276
277
278 # Truncate ?
279 #
280 0 ▶ if ($WEBDYNE_DEBUG_MAX_LINES && (length($debug) > $WEBDYNE_DEBUG_MAX_LENGTH)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES and length $debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LENGTH) 0 0 0
Condition0%0/3
$WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES and length $debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LENGTH
!ll&&!rl&&r
000
MC/DC0%0/2
$WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES and length $debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LENGTH
$WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES length $debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LENGTH
Truth table0%0/3
A and B
A= $WebDyne::Util::WEBDYNE_DEBUG_MAX_LINESB= length $debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LENGTH
ABresult
0X0
100
111
281 0 $debug=substr($debug, 0, $WEBDYNE_DEBUG_MAX_LENGTH);
282 }
283
284
285 # Wrap lines ?
286 #
287 0 $debug =~ s/\n(?!\z)/\n /g;
288
289
290 # Truncate lines ?
291 #
292 0 ▶ if ($WEBDYNE_DEBUG_MAX_LINES) {
Branch: 1 branch
BranchTrueFalseTotal
if ($WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES) 0 0 0
293 0 my @debug=split(/\n/, $debug, $WEBDYNE_DEBUG_MAX_LINES+1);
294 0 ▶ if (@debug > $WEBDYNE_DEBUG_MAX_LINES) {
Branch: 1 branch
BranchTrueFalseTotal
if (@debug > $WebDyne::Util::WEBDYNE_DEBUG_MAX_LINES) 0 0 0
295 0 splice(@debug, $WEBDYNE_DEBUG_MAX_LINES);
296 0 push @debug, '...';
297 }
298 0 $debug=join("\n", @debug);
299 }
300 0 chomp($debug);
301
302
303 # Colourise
304 #
305 0 ▶ if (-t STDOUT && !($WEBDYNE_DEBUG_NO_COLOUR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (-t STDOUT and not $WebDyne::Util::WEBDYNE_DEBUG_NO_COLOUR) 0 0 0
Condition0%0/3
-t STDOUT and not $WebDyne::Util::WEBDYNE_DEBUG_NO_COLOUR
!ll&&!rl&&r
000
MC/DC0%0/2
-t STDOUT and not $WebDyne::Util::WEBDYNE_DEBUG_NO_COLOUR
-t STDOUT not $WebDyne::Util::WEBDYNE_DEBUG_NO_COLOUR
Truth table0%0/3
A and not(B)
A= -t STDOUTB= not $WebDyne::Util::WEBDYNE_DEBUG_NO_COLOUR
ABresult
0X0
100
111
306 0 eval {
307 0 require Term::ANSIColor;
308 0 $timestamp=Term::ANSIColor::color('cyan') . $timestamp;
309 0 $class=Term::ANSIColor::color('magenta') . $class;
310 0 $subroutine=Term::ANSIColor::color('bold green') . $subroutine;
311 0 $debug=Term::ANSIColor::color('reset') . $debug;
312 };
313 0 ▶ eval {} if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
314 }
315
316
317 # Filtering ?
318 #
319 0 ▶ if ($WEBDYNE_DEBUG && ($WEBDYNE_DEBUG ne '1')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($WebDyne::Util::WEBDYNE_DEBUG and $WebDyne::Util::WEBDYNE_DEBUG ne '1') { } 0 0 0
Condition0%0/3
$WebDyne::Util::WEBDYNE_DEBUG and $WebDyne::Util::WEBDYNE_DEBUG ne 1
!ll&&!rl&&r
000
MC/DC0%0/2
$WebDyne::Util::WEBDYNE_DEBUG and $WebDyne::Util::WEBDYNE_DEBUG ne 1
$WebDyne::Util::WEBDYNE_DEBUG $WebDyne::Util::WEBDYNE_DEBUG ne 1
Truth table0%0/3
A and B
A= $WebDyne::Util::WEBDYNE_DEBUGB= $WebDyne::Util::WEBDYNE_DEBUG ne 1
ABresult
0X0
100
111
320  
321  
322 # Yes - check we are getting from caller we are interested in
323 #
324 0 my @debug_target=split(/[,;]/, $WEBDYNE_DEBUG);
325 0 foreach my $debug_target (@debug_target) {
326 0 ▶ if (($caller eq $debug_target) || ($method=~/\Q$debug_target\E$/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller eq $debug_target or $method =~ /\Q$debug_target\E$/) 0 0 0
Condition0%0/3
$caller eq $debug_target or $method =~ /\Q$debug_target\E$/
l!l&&r!l&&!r
000
MC/DC0%0/2
$caller eq $debug_target or $method =~ /\Q$debug_target\E$/
$caller eq $debug_target $method =~ /\Q$debug_target\E$/
Truth table0%0/3
A or B
A= $caller eq $debug_targetB= $method =~ /\Q$debug_target\E$/
ABresult
1X1
011
000
327
328 # Print debug after checking for any regexp wanted
329 #
330 0 ▶ if (my $regexp=$WEBDYNE_DEBUG_FILTER) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $regexp = $WebDyne::Util::WEBDYNE_DEBUG_FILTER) 0 0 0
331 0 ▶ next unless $debug=~qr/$regexp/m;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug =~ qr/$regexp/m 0 0 0
332 }
333 0 CORE::print $debug_fh "[$timestamp $class ($subroutine)] ", $debug, $/;
334 }
335 }
336 }
337 else {
338  
339 # No filtering. Open floodgates but still apply any regexp
340 #
341 0 ▶ if (my $regexp=$WEBDYNE_DEBUG_FILTER) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $regexp = $WebDyne::Util::WEBDYNE_DEBUG_FILTER) 0 0 0
342 0 ▶ return unless $debug=~qr/$regexp/;
Branch: 1 branch
BranchTrueFalseTotal
unless $debug =~ qr/$regexp/ 0 0 0
343 }
344 0 CORE::print $debug_fh "[$timestamp $class ($subroutine)] ", $debug, $/;
345 }
346  
347 }
348  
349  
350 48 ▶sub errnofatal {
Subroutine errnofatal: called CC=2 SCAR=7.6
Pod undocumented
351  
352  
353 #
354 #
355 48 ▶ @_ ? $Package{'nofatal'}=@_ : $Package{'nofatal'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 48 0 48
356  
357  
358 }
359  
360  
361 22 ▶sub err {
Subroutine err: called CC=16 SCAR=32.6
Pod undocumented
362  
363  
364 # Get the message and any sprintf params
365 #
366 22 my ($message, @param)=@_;
367  
368  
369 # If no message supplied return last one seen
370 #
371 22 ▶ unless ($message) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message) { } 7 15 22
372 15 ▶ $message=@Err ? ($Err[$#Err]->[0] && return undef) : 'undefined error';
Branch: 1 branch
BranchTrueFalseTotal
@Err ? : 15 0 15
Condition50%1/2
$Err[$#Err][0] and return undef
!ll
015
MC/DC0%0/1
$Err[$#Err][0] and return undef
$Err[$#Err][0]
Truth table50%1/2
A
A= $Err[$#Err][0]
Aresult
00
11
373 }
374 else {
375 0 ▶ $message=@param ? sprintf($message, map { defined($_) ? $_ : 'undef' } @param) : $message;
Branch: 2 branches
BranchTrueFalseTotal
@param ? : 0 7 7
defined $_ ? : 0 0 0
376 }
377  
378  
379 # Init the caller var and array
380 #
381 7 my @caller;
382 7 my $caller=(caller(0))[0];
383  
384  
385 # Populate the caller array
386 #
387 7 ▶ for (my $i=0; my @info=(caller($i))[0..3]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@info) = (caller $i)[0..3]) 65 7 72
388  
389  
390 # Push onto the caller array
391 #
392 65 push @caller, \@info;
393  
394  
395 }
396 7 0 && debug("err: $message, caller:%s", Dumper(\@caller));
397  
398  
399  
400 # If this message is *not* the same as the last one we saw,
401 # we will log it
402 #
403 7 ▶ unless ($message eq (@Err && $Err[0]->[0])) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($message eq (@Err && $Err[0][0])) 4 3 7
Condition66%2/3
@Err && $Err[0][0]
!ll&&!rl&&r
403
MC/DC50%1/2
@Err && $Err[0][0]
@Err $Err[0][0]
Truth table66%2/3
A && B
A= @ErrB= $Err[0][0]
ABresult
0X0
100
111
404  
405  
406 # Add to stack
407 #
408 4 unshift @Err, [$message, @caller];
409  
410  
411 # If caller has a debug function enabled, call this with the warning
412 #
413 4 ▶ if (UNIVERSAL::can($caller, 'debug')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::can($caller, "debug")) 4 0 4
414  
415  
416 # Yes, they are using the debug module, so can we call it
417 #
418 4 &{"${caller}::debug"}($message);
419  
420  
421 }
422  
423  
424 # Dump to backtrace file if enabled
425 #
426 4 foreach my $fn (keys %{$Package{'error_fn'}}) {
427  
428 0 ▶ unless (my $fh=IO::File->new($fn, O_CREAT | O_APPEND | O_WRONLY)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $fh = 'IO::File'->new($fn, 1089)) { } 0 0 0
429 0 warn("unable to open file '$fn', $!");
430 }
431 else {
432 0 seek($fh, 0, 2); # Seek to EOF
433 0 my $errdump=&errdump();
434 0 CORE::print $fh $errdump, $/, $/;
435 0 $fh->close();
436 }
437  
438 }
439  
440  
441 }
442  
443  
444 # If operating under eval and withing a WebDyne::<inode> block call CORE::die;
445 #
446 7 foreach my $caller_ar (@caller) {
447 38 ▶ if ($caller_ar->[0]=~/^WebDyne::[a-f0-9]{32}$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller_ar->[0] =~ /^WebDyne::[a-f0-9]{32}$/) 3 35 38
448 3 0 && debug("die with WebDyne::<inode> eval detected, calling CORE::die");
449 3 CORE::die($message);
450 }
451 }
452 4 0 && debug('not under WebDyne eval, proceeding');
453  
454  
455 # Return undef
456 #
457 4 ▶ return $Package{'nofatal'} ? undef : die(&errdump || 'undefined webdyne error');
Branch: 1 branch
BranchTrueFalseTotal
$Package{'nofatal'} ? : 4 0 4
Condition0%0/2
&errdump || 'undefined webdyne error'
l!l
00
MC/DC0%0/1
&errdump || 'undefined webdyne error'
&errdump
Truth table0%0/2
A
A= &errdump
Aresult
11
00
458  
459 }
460  
461  
462 2377 ▶sub errstr {
Subroutine errstr: called CC=2 SCAR=6.9
Pod undocumented
463  
464  
465 # Check that there are messages in the stack before trying to get
466 # the last one
467 #
468 2377 ▶ if (my $count=@Err) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $count = @Err) { } 6 2371 2377
469  
470  
471 # There are objects in the array, so it is safe to do a fetch
472 # on the last (-1) array slot
473 #
474 6 my $errstr=$Err[--$count]->[0];
475  
476  
477 # And return the errstr
478 #
479 6 return $errstr;
480  
481 }
482 else {
483  
484  
485 # Nothing in the array stack, return undef
486 #
487 2371 return undef;
488  
489  
490 }
491  
492 }
493  
494  
495 5 ▶sub errclr {
Subroutine errclr: called CC=2 SCAR=7.1
Pod undocumented
496  
497  
498 # Clear the warning stack
499 #
500 5 undef @Err;
501  
502  
503 # Replace errors if args
504 #
505 5 ▶ @_ && (return &err(@_));
Branch: 1 branch
BranchTrueFalseTotal
@_ and return &err(@_) 0 5 5
506  
507  
508 # Return OK always
509 #
510 5 return 1;
511  
512 }
513  
514  
515 0 ▶sub errsubst {
Subroutine errsubst: not called CC=5 SCAR=34.0
Pod undocumented
516  
517  
518 # Replace the current error message with a new one, keeping callback
519 # stack
520 #
521 0 my ($message, @param)=@_;
522  
523 # If no message supplied return last one seen
524 #
525 0 ▶ unless ($message) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message) { } 0 0 0
526 0 ▶ $message=@Err ? $Err[$#Err]->[0] && return undef : 'undefined error';
Branch: 1 branch
BranchTrueFalseTotal
@Err ? : 0 0 0
Condition0%0/2
$Err[$#Err][0] and return undef
!ll
00
MC/DC0%0/1
$Err[$#Err][0] and return undef
$Err[$#Err][0]
Truth table0%0/2
A
A= $Err[$#Err][0]
Aresult
00
11
527 }
528 else {
529 0 $message=sprintf($message, @param);
530 }
531  
532 # Chomp the message
533 #
534 0 chomp($message);
535  
536  
537 # Replace if present, define if not
538 #
539 0 ▶ @Err ? ($Err[$#Err]->[0]=$message) : goto &err;
Branch: 1 branch
BranchTrueFalseTotal
@Err ? : 0 0 0
540  
541  
542 # Return
543 #
544 0 return undef;
545  
546  
547 }
548  
549  
550 1 ▶sub errdump {
Subroutine errdump: called CC=17 SCAR=28.9
Pod undocumented
551  
552  
553 # Use can send additional info to dump as key/value pairs in hash ref
554 # supplied as arg
555 #
556 1 my $info_hr=shift();
557  
558 # formline writes to the global format accumulator. Keep errdump output
559 # isolated and restore any outer accumulator automatically on return.
560 1 local $^A=q();
561  
562  
563 # Return a dump of error in a nice format, no params. Do this with
564 # format strings, so define the ones we will use
565 #
566 1 my @format=(
567  
568 #'+' . ('-' x 78) . "+\n",
569 #"| @<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |\n",
570 #"| | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ |\n"
571 '+' . ('-' x ($WEBDYNE_ERROR_TEXT_CHAR_MAX + 12)) . "+\n",
572 sprintf('| @<<<<< | ^%s |'."\n", ('<' x $WEBDYNE_ERROR_TEXT_CHAR_MAX)),
573 sprintf('| | ^%s~~ |'."\n", ('<' x ($WEBDYNE_ERROR_TEXT_CHAR_MAX-2) ))
574  
575 );
576  
577 # Go through the message stack on error at a time in reverse order
578 #
579 1 foreach my $err_ar (reverse @Err) {
580  
581  
582 # Get message, clean up
583 #
584 1 my $message=ucfirst($err_ar->[0]);
585 1 $message=~s/\s+$//;
586 1 ▶ $message.='.' unless $message=~/[\.\!\?]$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $message =~ /[\.\!\?]$/ 1 0 1
587 1 my @message=split("\n", $message);
588 1 ▶ $message=shift @message if @message;
Branch: 1 branch
BranchTrueFalseTotal
if @message 1 0 1
589  
590  
591 # Print out date, time, error message
592 #
593 1 formline $format[0];
594 1 formline $format[1], 'Date', scalar(localtime());
595 1 formline $format[0];
596 1 formline $format[1], 'Error', $message;
597 1 ▶ (formline $format[2], $message) if $message;
Branch: 1 branch
BranchTrueFalseTotal
if $message 0 1 1
598 1 ▶ map {formline $format[2], $_} @message if @message;
Branch: 1 branch
BranchTrueFalseTotal
if @message 1 0 1
599 1 formline $format[0];
600  
601  
602 # Flag so we know we have printed the caller field
603 #
604 1 my $caller_fg;
605  
606  
607 # Go through callback stack
608 #
609 1 ▶ for (my $i=1; defined($err_ar->[$i]); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $err_ar->[$i]) 13 0 13
610  
611  
612 # Get method, line no and file
613 #
614 13 ▶ my $method=$err_ar->[$i+1][3] || $err_ar->[$i][0] || last;
Condition100%5/5
$$err_ar[$i + 1][3] || $err_ar->[$i][0] || (last)
l!l
121
$$err_ar[$i + 1][3] or $err_ar->[$i][0]
l!l&&r!l&&!r
1111
MC/DC100%2/2
$$err_ar[$i + 1][3] || $err_ar->[$i][0] || (last)
$$err_ar[$i + 1][3] $err_ar->[$i][0]
Truth table100%3/3
A or B
A= $$err_ar[$i + 1][3]B= $err_ar->[$i][0]
ABresult
1X1
011
000
615 12 ▶ my $lineno=$err_ar->[$i][2] || next;
Condition50%1/2
$err_ar->[$i][2] || (next)
l!l
120
MC/DC0%0/1
$err_ar->[$i][2] || (next)
$err_ar->[$i][2]
Truth table50%1/2
A
A= $err_ar->[$i][2]
Aresult
11
00
616 12 my $filenm=$err_ar->[$i][1];
617  
618  
619 # Print them out, print out caller label unless we
620 # have already done so
621 #
622 12 ▶ formline $format[1],
Branch: 1 branch
BranchTrueFalseTotal
$caller_fg++ ? : 11 1 12
623 $caller_fg++ ? '' : 'Caller', "$method, line $lineno";
624  
625 }
626  
627  
628 # Include any user supplied info
629 #
630 #while (my ($key, $value)=each %{$info_hr}) {
631 1 foreach my $key (sort keys %{$info_hr}) {
632 2 my $value=$info_hr->{$key};
633  
634 # Older perls can interact badly with overloaded objects during
635 # formline formatting, so keep diagnostic fields as plain scalars.
636 2 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 1 1 2
637 1 my $string=eval {
638 1 ▶ UNIVERSAL::can($value, 'as_string') ? $value->as_string() : "$value";
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::can($value, 'as_string') ? : 1 0 1
639 };
640 1 ▶ $value=defined($string) ? $string : ref($value);
Branch: 1 branch
BranchTrueFalseTotal
defined $string ? : 1 0 1
641 }
642  
643 # Print separator, info
644 #
645 2 formline $format[0];
646 2 formline $format[1], $key, $value;
647 2 ▶ (formline $format[2], $value) if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 0 2 2
648  
649 }
650  
651  
652 # Finish off formatting, print PID. Dont ask me why $$ has to be "$$",
653 # it does not show up any other way
654 #
655 1 formline $format[0];
656 1 formline $format[1], 'PID', "$$";
657 1 formline $format[0];
658 1 formline "\n";
659
660
661 # Only show first error message
662 #
663 1 ▶ last unless $WEBDYNE_ERROR_TEXT_SHOW_ALL;
Branch: 1 branch
BranchTrueFalseTotal
unless $WebDyne::Util::WEBDYNE_ERROR_TEXT_SHOW_ALL 1 0 1
664  
665  
666 }
667  
668  
669 # Return the localized format accumulator.
670 #
671 1 return $^A;
672  
673 }
674  
675  
676 2 ▶sub errstack {
Subroutine errstack: called CC=2 SCAR=9.2
Pod undocumented
677  
678 # Return or push the raw error stack
679 #
680 0 ▶ return @_ ? \(@Err=@{$_[1]}) : \@Err;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 2 2
681  
682 }
683  
684  
685 2 ▶sub perl_inc_dn {
Subroutine perl_inc_dn: called CC=6 SCAR=20.2
Pod undocumented
686  
687 # Return array ref of any additional libraries specified via command line (-I)
688 #
689 2 ▶ my %default_inc=map { $_ => 1 } @{ perl_inc_dn_default() || [] };
Condition50%1/2
perl_inc_dn_default() || []
l!l
20
MC/DC0%0/1
perl_inc_dn_default() || []
perl_inc_dn_default()
Truth table50%1/2
A
A= perl_inc_dn_default()
Aresult
11
00
690 2 my %seen;
691 my @lib=grep {
692 20 ▶ !$default_inc{$_} && !$seen{$_}++
Condition66%2/3
$default_inc{$_} || $seen{$_}++
l!l&&r!l&&!r
1604
MC/DC50%1/2
$default_inc{$_} || $seen{$_}++
$default_inc{$_} $seen{$_}++
Truth table66%2/3
A || B
A= $default_inc{$_}B= $seen{$_}++
ABresult
1X1
011
000
693 } map {
694 20 File::Spec->rel2abs($_)
695 } grep {
696 2 ▶ defined($_) && !ref($_) && length($_) && -d $_
Condition33%3/9
defined $_ && !ref($_) && length $_ && -d $_
!ll&&!rl&&r
0020
defined $_ and not ref $_ and length $_
!ll&&!rl&&r
0020
defined $_ and not ref $_
!ll&&!rl&&r
0020
MC/DC0%0/4
defined $_ && !ref($_) && length $_ && -d $_
defined $_ not ref $_ length $_ -d $_
Truth table20%1/5
A and not(B) and C && D
A= defined $_B= not ref $_C= length $_D= -d $_
ABCDresult
0XXX0
10XX0
110X0
11100
11111
697 } @INC;
698  
699 2 return \@lib;
700 }
701  
702  
703 2 ▶sub perl_inc_dn_default {
Subroutine perl_inc_dn_default: called CC=3 SCAR=11.1
Pod undocumented
704  
705 2 my @default_inc;
706 #local %ENV=%ENV;
707 #delete @ENV{qw(PERL5LIB PERLLIB PERL_USE_UNSAFE_INC)};
708  
709 2 ▶ if (open(my $perl_fh, '-|', $^X, '-e', 'print join qq(\0), grep { defined && !ref && length && -d } @INC')) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $perl_fh, "-|", $^X, "-e", "print join qq(\\0), grep { defined && !ref && length && -d } \@INC") 2 0 2
710 2 local $/;
711 2 my $inc=<$perl_fh>;
712 2 close($perl_fh);
713 @default_inc=map {
714 2 ▶ File::Spec->rel2abs($_)
Condition50%1/2
$inc || ''
l!l
20
MC/DC0%0/1
$inc || ''
$inc
Truth table50%1/2
A
A= $inc
Aresult
11
00
715 } split(/\0/, ($inc || ''));
716 }
717  
718 2 return \@default_inc;
719 }
720  
721  
722 2 ▶sub apache_startup {
Subroutine apache_startup: called CC=10 SCAR=27.9
Pod undocumented
723  
724 2 ▶ my $opt_hr=shift() || {};
Condition50%1/2
shift() || {}
l!l
20
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
725  
726 # Use an Apache::Test server root under tmp. By default File::Temp cleans
727 # this at process exit; --keep_tmp flips CLEANUP off for debugging.
728 #
729 2 require File::Temp;
730 my $svr_root_dn=$opt_hr->{'serverroot'} || File::Temp::tempdir(
731 'webdyne_apache_XXXXXXXX',
732 TMPDIR => 1,
733 2 ▶ CLEANUP => exists($opt_hr->{'keep_tmp'}) ? !$opt_hr->{'keep_tmp'} : 1,
Branch: 1 branch
BranchTrueFalseTotal
exists $opt_hr->{'keep_tmp'} ? : 2 0 2
Condition33%1/3
$opt_hr->{'serverroot'} || File::Temp::tempdir('webdyne_apache_XXXXXXXX', 'TMPDIR', 1, 'CLEANUP', exists $opt_hr->{'keep_tmp'} ? !$opt_hr->{'keep_tmp'} : 1)
l!l&&r!l&&!r
020
MC/DC0%0/2
$opt_hr->{'serverroot'} || File::Temp::tempdir('webdyne_apache_XXXXXXXX', 'TMPDIR', 1, 'CLEANUP', exists $opt_hr->{'keep_tmp'} ? !$opt_hr->{'keep_tmp'} : 1)
$opt_hr->{'serverroot'} File::Temp::tempdir('webdyne_apache_XXXXXXXX', 'TMPDIR', 1, 'CLEANUP', exists $opt_hr->{'keep_tmp'} ? !$opt_hr->{'keep_tmp'} : 1)
Truth table33%1/3
A || B
A= $opt_hr->{'serverroot'}B= File::Temp::tempdir('webdyne_apache_XXXXXXXX', 'TMPDIR', 1, 'CLEANUP', exists $opt_hr->{'keep_tmp'} ? !$opt_hr->{'keep_tmp'} : 1)
ABresult
1X1
011
000
734 );
735  
736 # Some command-line helpers run best with an isolated cache inside the
737 # temporary server root, rather than the system/default WebDyne cache.
738 #
739 2 ▶ if ($opt_hr->{'cache_dn_env'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt_hr->{"cache_dn_env"}) 2 0 2
740 2 mkdir(my $cache_dn=File::Spec->catdir($svr_root_dn, 'cache'));
741 2 $ENV{'WEBDYNE_CACHE_DN'}=$cache_dn;
742 }
743  
744 # Apache::Test may warn about duplicate inherited options; they are noisy
745 # but benign for these one-process throwaway instances.
746 #
747 0 ▶ local $SIG{__WARN__}=sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
748 0 ▶ return if $_[0] =~ /Duplicate specification/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /Duplicate specification/ 0 0 0
749 0 CORE::warn @_;
750 2 };
751  
752 # Avoid Apache::Test attempting to adjust process ulimits in environments
753 # where that is either unnecessary or not permitted.
754 #
755 2 $ENV{'APACHE_TEST_ULIMIT_SET'}++;
756  
757 # Apache::Test normally writes startup.pl and index.html helpers. WebDyne
758 # supplies the whole runtime config via the caller's postamble instead.
759 #
760 70 ▶ no warnings qw(once redefine);
Subroutine BEGIN: called CC=1 SCAR=0.0
761 2 require Apache::TestConfig;
762 2 ▶ *Apache::TestConfig::generate_index_html=sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
763 2 ▶ *Apache::TestConfig::configure_startup_pl=sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
764  
765 # Load Apache::Test lazily so WebDyne::Util can be used without mod_perl
766 # development dependencies unless an Apache helper is actually invoked.
767 #
768 2 require Apache::TestRunPerl;
769 2 my $runner=Apache::TestRunPerl->new();
770 2 ▶ unless ($runner) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($runner) 0 2 2
771 0 my $message='unable to create Apache::TestRunPerl instance';
772 0 ▶ die "$message\n" if $opt_hr->{'die_on_error'};
Branch: 1 branch
BranchTrueFalseTotal
if $opt_hr->{"die_on_error"} 0 0 0
773 0 return err($message);
774 }
775  
776 # The postamble is caller-owned because wdrender, webdyne.apache, and the
777 # test harness each need subtly different Apache configuration fragments.
778 #
779 my @argv=(
780 '-port' => defined($opt_hr->{'port'}) ? $opt_hr->{'port'} : 'select',
781 '-serverroot' => $svr_root_dn,
782 '-documentroot' => $opt_hr->{'documentroot'},
783 2 ▶ '-postamble' => $opt_hr->{'postamble'},
Branch: 1 branch
BranchTrueFalseTotal
defined $opt_hr->{'port'} ? : 2 0 2
784 '-one-process',
785 '-start-httpd',
786 );
787 unshift(@argv, '-apxs', $ENV{'APACHE_TEST_APXS'})
788 2 ▶ if $ENV{'APACHE_TEST_APXS'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"APACHE_TEST_APXS"} 2 0 2
789 unshift(@argv, '-httpd', $ENV{'APACHE_TEST_HTTPD'})
790 2 ▶ if $ENV{'APACHE_TEST_HTTPD'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"APACHE_TEST_HTTPD"} 2 0 2
791  
792 2 $runner->run(@argv);
793 0 return $runner;
794 }
795  
796  
797 0 ▶sub apache_shutdown {
Subroutine apache_shutdown: not called CC=3 SCAR=24.8
Pod undocumented
798  
799 0 my $runner=shift();
800 0 ▶ return unless $runner && $runner->{'server'};
Branch: 1 branch
BranchTrueFalseTotal
unless $runner and $runner->{"server"} 0 0 0
Condition0%0/3
$runner and $runner->{"server"}
!ll&&!rl&&r
000
MC/DC0%0/2
$runner and $runner->{"server"}
$runner $runner->{"server"}
Truth table0%0/3
A and B
A= $runnerB= $runner->{"server"}
ABresult
0X0
100
111
801 0 $runner->{'server'}->stop();
802 0 return;
803 }
804  
805 70 1;__END__
806  
807 =begin markdown
808  
809 # WebDyne::Util #
810  
811 # NAME #
812  
813 WebDyne::Util - debugging and error-stack utility functions for WebDyne
814  
815 # SYNOPSIS #
816  
817 ```perl
818 use WebDyne::Util;
819  
820 0 && debug('message: %s', $value);
821 err('something failed');
822 my $msg = errstr();
823 ```
824  
825 # DESCRIPTION #
826  
827 `WebDyne::Util` provides the common debugging, error-stack, and error-formatting functions used throughout the WebDyne codebase.
828  
829 It exports the standard utility functions by default and uses environment variables such as `WEBDYNE_DEBUG`, `WEBDYNE_DEBUG_FILE`, `WEBDYNE_DEBUG_FILTER`, and related settings to control runtime debug output.
830  
831 `perl_inc_dn` is exported by default and can also be requested explicitly. `apache_startup` and `apache_shutdown` are available on request, or through the `:all` export tag.
832  
833 # FUNCTIONS #
834  
835 * **debug($message, @args)**
836  
837 Emit a formatted debug message if debugging is enabled for the calling package or environment.
838  
839 * **err($message, @args)**
840  
841 Push an error message onto the WebDyne error stack.
842  
843 * **errstr()**
844  
845 Return the current error string.
846  
847 * **errclr()**
848  
849 Clear the current error state.
850  
851 * **errsubst(...)**
852  
853 Apply error-text substitutions and formatting helpers.
854  
855 * **errdump(...)**
856  
857 Produce a formatted dump of the current error stack and related diagnostics.
858  
859 * **errstack()**
860  
861 Return the current error stack.
862  
863 * **errnofatal($bool)**
864  
865 Control whether errors are treated as fatal by the utility layer.
866  
867 * **perl_inc_dn()**
868  
869 Return non-default library directories from `@INC`.
870  
871 * **apache_startup(\%options)**
872  
873 Start an Apache::Test runner instance with a caller-supplied postamble.
874  
875 * **apache_shutdown($runner)**
876  
877 Stop an Apache::Test runner instance if it is active.
878  
879 # NOTES #
880  
881 This module is foundational to the rest of WebDyne. Most other modules import it for debug and error handling.
882  
883 # AUTHOR #
884  
885 Andrew Speer <andrew.speer@isolutions.com.au>
886  
887 # LICENSE and COPYRIGHT
888  
889 This file is part of WebDyne.
890  
891 This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>.
892  
893 This is free software; you can redistribute it and/or modify it under
894 the same terms as the Perl 5 programming language system itself.
895  
896 Full license text is available at:
897  
898 <http://dev.perl.org/licenses/>
899  
900  
901 =end markdown
902  
903  
904 =head1 WebDyne::Util
905  
906  
907 =head1 NAME
908  
909 WebDyne::Util - debugging and error-stack utility functions for WebDyne
910  
911  
912 =head1 SYNOPSIS
913  
914  
915 use WebDyne::Util;
916
917 0 && debug('message: %s', $value);
918 err('something failed');
919 my $msg = errstr();
920  
921 =head1 DESCRIPTION
922  
923 C<WebDyne::Util> provides the common debugging, error-stack, and error-formatting functions used throughout the WebDyne codebase.
924  
925 It exports the standard utility functions by default and uses environment variables such as C<WEBDYNE_DEBUG>, C<WEBDYNE_DEBUG_FILE>, C<WEBDYNE_DEBUG_FILTER>, and related settings to control runtime debug output.
926  
927 C<perl_inc_dn> is exported by default and can also be requested explicitly. C<apache_startup> and C<apache_shutdown> are available on request, or through the C<:all> export tag.
928  
929  
930 =head1 FUNCTIONS
931  
932 =over
933  
934 =item *
935  
936 B<debug($message, @args)>
937  
938 Emit a formatted debug message if debugging is enabled for the calling package or environment.
939  
940  
941  
942 =item *
943  
944 B<err($message, @args)>
945  
946 Push an error message onto the WebDyne error stack.
947  
948  
949  
950 =item *
951  
952 B<errstr()>
953  
954 Return the current error string.
955  
956  
957  
958 =item *
959  
960 B<errclr()>
961  
962 Clear the current error state.
963  
964  
965  
966 =item *
967  
968 B<errsubst(...)>
969  
970 Apply error-text substitutions and formatting helpers.
971  
972  
973  
974 =item *
975  
976 B<errdump(...)>
977  
978 Produce a formatted dump of the current error stack and related diagnostics.
979  
980  
981  
982 =item *
983  
984 B<errstack()>
985  
986 Return the current error stack.
987  
988  
989  
990 =item *
991  
992 B<errnofatal($bool)>
993  
994 Control whether errors are treated as fatal by the utility layer.
995  
996  
997  
998 =item *
999  
1000 B<perl_inc_dn()>
1001  
1002 Return non-default library directories from C<@INC>.
1003  
1004  
1005  
1006 =item *
1007  
1008 B<apache_startup(\%options)>
1009  
1010 Start an Apache::Test runner instance with a caller-supplied postamble.
1011  
1012  
1013  
1014 =item *
1015  
1016 B<apache_shutdown($runner)>
1017  
1018 Stop an Apache::Test runner instance if it is active.
1019  
1020  
1021  
1022 =back
1023  
1024  
1025 =head1 NOTES
1026  
1027 This module is foundational to the rest of WebDyne. Most other modules import it for debug and error handling.
1028  
1029  
1030 =head1 AUTHOR
1031  
1032 Andrew Speer L<mailto:andrew.speer@isolutions.com.au>
1033  
1034  
1035 =head1 LICENSE and COPYRIGHT
1036  
1037 This file is part of WebDyne.
1038  
1039 This software is copyright (c) 2026 by Andrew Speer L<mailto:andrew.speer@isolutions.com.au>.
1040  
1041 This is free software; you can redistribute it and/or modify it under
1042 the same terms as the Perl 5 programming language system itself.
1043  
1044 Full license text is available at:
1045  
1046 L<http://dev.perl.org/licenses/>
1047  
1048 =cut
« bin/wdrender ↑ Summary lib/WebDyne/Install/Apache/Constant.pm »