Front page | perl.perl5.porters |
Postings from April 2002
[PATCH pp_ctl.c] a better formatting for @INC's printout for failedrequire()
From:
Stas Bekman
Date:
April 14, 2002 11:10
Subject:
[PATCH pp_ctl.c] a better formatting for @INC's printout for failedrequire()
Message ID:
3CB9C611.20801@stason.org
In certain apps you end up with 10 and more paths in @INC. When require
fails, it's a pain to look over the many paths printed all in one line.
This usually happens when you try to setup the right @INC in testing
suites. Currently I'm debugging @INC for a mod_perl-2.0 subproject which
has its own blib, lib needs blib and lib from mod_perl, and has the core
@INC. Now add all the ithread subdirs and you get some 16 paths or so --
big pain to debug. So I always end up manually printing @INC, path per
line. But then I thought why the error message couldn't be more
developer friendly.
This patch makes the require failure print an error with single path per
line making it much easier to debug the problem.
I hope this doesn't create a back compatibility problem. Most regexes
catching this error, just need to add /s to search for multiline pattern
instead of one line, which will work with older perls the same way.
all tests pass with little patches in lib/base.pm and fail-more.t (attached)
--- pp_ctl.c Mon Apr 15 01:42:41 2002
+++ pp_ctl.c.new Mon Apr 15 01:42:25 2002
@@ -3159,10 +3159,10 @@
sv_catpv(msg, " (change .h to .ph maybe?)");
if (instr(SvPVX(msg), ".ph "))
sv_catpv(msg, " (did you run h2ph?)");
-
sv_catpv(msg, " (@INC contains:");
+
sv_catpv(msg, " (@INC contains:\n");
for (i = 0; i <= AvFILL(ar); i++) {
char *dir = SvPVx(*av_fetch(ar, i, TRUE), n_a);
-
Perl_sv_setpvf(aTHX_ dirmsgsv, " %s", dir);
+
Perl_sv_setpvf(aTHX_ dirmsgsv, "%s\n", dir);
sv_catsv(msg, dirmsgsv);
}
sv_catpvn(msg, ")", 1);
--- lib/base.pm.orig Mon Apr 15 01:51:58 2002
+++ lib/base.pm Mon Apr 15 01:53:21 2002
@@ -60,7 +60,7 @@
eval "require $base";
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
-
die if $@ && $@ !~ /^Can't locate .*? at \(eval /;
+
die if $@ && $@ !~ /^Can't locate .*? at \(eval /s;
unless (%{"$base\::"}) {
require Carp;
Carp::croak("Base class package \"$base\" is empty.\n",
--- lib/Test/Simple/t/fail-more.t.orig Mon Apr 15 02:03:59 2002
+++ lib/Test/Simple/t/fail-more.t Mon Apr 15 02:04:06 2002
@@ -214,7 +214,7 @@
# Looks like you failed $Total tests of $Total.
ERR
- unless( My::Test::ok($$err =~ /^\Q$err_re\E$more_err_re$/,
+ unless( My::Test::ok($$err =~ /^\Q$err_re\E$more_err_re$/s,
'failing errors') ) {
print $$err;
}
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com