Front page | perl.perl5.porters |
Postings from October 2003
Re: 5.8.2 perldelta
From:
Stas Bekman
Date:
October 29, 2003 17:04
Subject:
Re: 5.8.2 perldelta
Message ID:
3FA063BD.80603@stason.org
Stas Bekman wrote:
> Nicholas Clark wrote:
>
>> On Wed, Oct 29, 2003 at 03:06:35PM -0800, Stas Bekman wrote:
>>
>>> Chip Salzenberg wrote:
>>>
>>>> According to Nicholas Clark:
>>>>
>>>>
>>>>> C<require> should now behave correctly when repeated attempts are made
>>>>> to load a file which fails.
>>>
>>>
>>> Hmm, may be this is the problem. Can you please point me to this
>>> patch? Indeed I fail to require the same file twice.
>>
>>
>>
>> Nick
>>
>> 21415 and 21427 integrated as 21496
>>
>> Change 21496 by nicholas@entropy on 2003/10/19 18:31:14
>
>
> Aha! This is the patch that broke mod_perl 1.0's test suite. Thanks Nick!
>
> I'm going to figure out how to provide you an easy to reproduce code
> running outside mod_perl.
unrelated to the introduced problem this test has a small problem.
>> ==== //depot/maint-5.8/perl/t/comp/require.t#6 (xtext) ====
[...]
>> +my $flag_file = 'bleah.flg';
>> +# run-time error in require
>> +for my $expected_compile (1,0) {
>> + write_file($flag_file, 1);
>> + print "not " unless -e $flag_file;
>> + print "ok ",$i++,"\n";
>> + write_file('bleah.pm', "unlink '$flag_file' or die; \$a=0;
>> \$b=1/\$a; 1;\n");
>> + print "# $@\nnot " if eval { require 'bleah.pm' };
>> + print "ok ",$i++,"\n";
>> + print "not " unless -e $flag_file xor $expected_compile;
>> + print "ok ",$i++,"\n";
>> + print "not " unless exists $INC{'bleah.pm'};
>> + print "ok ",$i++,"\n";
>> +}
it needs to be:
- print "# $@\nnot " if eval { require 'bleah.pm' };
+ eval { require 'bleah.pm' };
+ print map { "# $_\n" } split /\n/, $@ if $@;
+ print "not " unless $@;
because otherwise you never print out the debug $@, and if you did, you forgot
to prefix multiline $@ with a leading #, which may break the harness. This fix
needs to be applied to all the other places where it does:
print "# $@\nnot " if eval { require 'bleah.pm' };
Here is a standalone partial script which shows the correct debug behavior:
$i = 1;
my $flag_file = 'bleah.flg';
# run-time error in require
for my $expected_compile (1,0) {
write_file($flag_file, 1);
print "not " unless -e $flag_file;
print "ok ",$i++,"\n";
write_file('bleah.pm', qq[unlink '$flag_file' or die "\$!"; \$a=0;
\$b=1/\$a; 1;\n]);
eval { require 'bleah.pm' };
print map { "# $_\n" } split /\n/, $@ if $@;
print "not " unless $@;
print "ok ",$i++,"\n";
print "not " unless -e $flag_file xor $expected_compile;
print "ok ",$i++,"\n";
print "not " unless exists $INC{'bleah.pm'};
print "ok ",$i++,"\n";
}
sub write_file {
my($file, $data) = @_;
open my $fh, ">$file" or die $!;
print $fh $data;
close $fh;
}
__________________________________________________________________
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