Skip Menu |

This queue is for tickets about the DBI CPAN distribution.

Report information
The Basics
Id: 25004
Status: resolved
Priority: 0/
Queue: DBI

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.53
Fixed in: (no value)



Subject: ProfileDumper vs -l (with patch)
ProfileDumper does not protect itself against the setting of globals which effect print, that is $\ and $,. This results in extra newlines in the profile dump and dbiprof gets confused. The attached patch isolates ProfileDumper from this.
Subject: profile_dumper.patch
Auto-merging (0, 27417) /local/DBI to /vendor/DBI (base /vendor/DBI:27414). U t/41prof_dump.t U lib/DBI/ProfileDumper.pm ==== Patch <-> level 1 Source: 9c88509d-e914-0410-b01c-b9530614cbfe:/local/DBI:27417 Target: 9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/DBI:27414 Log: r27415@windhund: schwern | 2007-02-16 13:47:48 -0500 Local copy of DBI r27416@windhund: schwern | 2007-02-16 14:29:13 -0500 Isolate ProfileDumper from changes to globals which effect print such as when you're using -l r27417@windhund: schwern | 2007-02-16 14:33:39 -0500 Oops, $/ isn't a print thing. === t/41prof_dump.t ================================================================== --- t/41prof_dump.t (revision 27414) +++ t/41prof_dump.t (patch - level 1) @@ -1,5 +1,7 @@ -#!perl -w +#!perl -lw +# Use -l to ensure ProfileDumper is isolated from changes to $/ and $\ and such + use strict; # @@ -15,7 +17,7 @@ plan skip_all => 'profiling not supported for DBI::PurePerl'; } else { - plan tests => 12; + plan tests => 15; } } @@ -57,19 +59,24 @@ ok( -s "dbi.prof", 'Profile is on disk and nonzero size' ); open(PROF, "dbi.prof") or die $!; -my $prof = join('', <PROF>); +my @prof = <PROF>; close PROF; # has a header? -ok( $prof =~ /^DBI::ProfileDumper\s+([\d.]+)/, 'Found a version number' ); +ok( $prof[0] =~ /^DBI::ProfileDumper\s+([\d.]+)/, 'Found a version number' ); # Can't use like() because we need $1 # version matches VERSION? (DBI::ProfileDumper uses $self->VERSION so # it's a stringified version object that looks like N.N.N) is( $1, DBI::ProfileDumper->VERSION, 'Version numbers match' ); +like( $prof[1], qr{^Path\s+=\s+\[\s+\]}, 'Found the Path'); +ok( $prof[2] =~ m{^Program\s+=\s+(\S+)}, 'Found the Program'); + +is( $1, $0, 'Program matches' ); + # check that expected key is there -like($prof, qr/\+\s+1\s+\Q$sql\E/m); +like(join('', @prof), qr/\+\s+1\s+\Q$sql\E/m); # unlink("dbi.prof"); # now done by 'make clean' === lib/DBI/ProfileDumper.pm ================================================================== --- lib/DBI/ProfileDumper.pm (revision 27414) +++ lib/DBI/ProfileDumper.pm (patch - level 1) @@ -201,12 +201,22 @@ shift->{Data} = {}; } +sub _print { + my($fh) = shift; + + # isolate us against globals which effect print + local($\, $,); + + print $fh @_; +} + + # write header to a filehandle sub write_header { my ($self, $fh) = @_; # module name and version number - print $fh ref($self), " ", $self->VERSION, "\n"; + _print $fh, ref($self), " ", $self->VERSION, "\n"; # print out Path my @path_words; @@ -215,15 +225,15 @@ push @path_words, $_; } } - print $fh "Path = [ ", join(', ', @path_words), " ]\n"; + _print $fh, "Path = [ ", join(', ', @path_words), " ]\n"; # print out $0 and @ARGV - print $fh "Program = $0"; - print $fh " ", join(", ", @ARGV) if @ARGV; - print $fh "\n"; + _print $fh, "Program = $0"; + _print $fh, " ", join(", ", @ARGV) if @ARGV; + _print $fh, "\n"; # all done - print $fh "\n"; + _print $fh, "\n"; } # write data in the proscribed format @@ -235,10 +245,10 @@ while (my ($key, $value) = each(%$data)) { # output a key - print $fh "+ ", $level, " ", quote_key($key), "\n"; + _print $fh, "+ ", $level, " ", quote_key($key), "\n"; if (UNIVERSAL::isa($value,'ARRAY')) { # output a data set for a leaf node - printf $fh "= %4d %.6f %.6f %.6f %.6f %.6f %.6f\n", @$value; + _print $fh, sprintf "= %4d %.6f %.6f %.6f %.6f %.6f %.6f\n", @$value; } else { # recurse through keys - this could be rewritten to use a # stack for some small performance gain ==== BEGIN SVK PATCH BLOCK ==== Version: svk v2.0.0 (darwin) eJyNld9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