httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject [patch] better failure diagnostics for config token substitution
Date Sun, 23 Dec 2001 16:43:26 GMT
if the config token get mistyped, e.g. @servrename@ the current replace()
sub will simply die without helping to locate which token is unknown to
Apache-Test. This patch reports the offensive token (of course it'd be
nice to tell which file it comes from but the current implementation
doesn't allow that)

Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.117
diff -u -r1.117 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	2001/12/21 12:44:16	1.117
+++ Apache-Test/lib/Apache/TestConfig.pm	2001/12/23 16:36:50
@@ -755,7 +755,12 @@

 sub replace {
     my $self = shift;
-    s/@(\w+)@/$self->{vars}->{lc $1}/g;
+    s[@(\w+)@]
+     [ my $key = lc $1;
+      exists $self->{vars}->{$key}
+      ? $self->{vars}->{$key}
+      : die qq{cannot substitute "\@$key\@" token}
+     ]ge;
 }

 #need to configure the vhost port for redirects and $ENV{SERVER_PORT}

we could do simpler:

+    s[@(\w+)@]
+     [ $self->{vars}->{lc $1}
+       || die qq{cannot substitute "\@$1\@" token}
+     ]ge;

But the value can be false (while valid), so it won't work for all cases.

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Mime
View raw message