DBI-1.58 test failure on Windows

DBI-1.58 test failure on Windows

am 26.06.2007 14:54:52 von szabgab

Hi,

both
t\41prof_dump.t
t\zvg_41prof_dump.t
fail on plain ActivePerl 5.8.4 on Windows

C:\gabor\DBI-1.58>nmake

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.


see the rest of the output here:


C:\gabor\DBI-1.58>prove -vb t\41prof_dump.t
t\41prof_dump....1..16
ok 1 - use DBI;
ok 2 - use DBI::ProfileDumper;
ok 3 - The object isa DBI::db
ok 4 - The object isa DBI::ProfileDumper
ok 5 - The object isa HASH
ok 6 - The object isa ARRAY
ok 7 - The object isa DBI::st
ok 8
ok 9 - Profile is on disk and nonzero size
DBI::ProfileDumper 2.009658
Path = [ ]
Program = t\\41prof_dump.t

+ 1
= 7 0 0 0 0 1182858717.84375 1182858717.84375
+ 1 select mode,size,name from ?
= 2 0 0 0 0 1182858717.84375 1182858717.84375
+ 1
= 2 0 0 0 0 1182858717.85938 1182858717.85938
+ 1 select mode,size,name from ?
= 50 0.015625 0 0 0.015625 1182858717.84375 1182858717.85938

ok 10 - Found a version number
ok 11 - Version numbers match in DBI::ProfileDumper 2.009658
#
ok 12 - Found the Path
ok 13 - Found the Program
# Failed test (t\41prof_dump.t at line 79)
not ok 14 - Program matches
# got: 't\\41prof_dump.t'
# expected: 't\41prof_dump.t'
ok 15
ok 16 # skip developer-only test
# Looks like you failed 1 tests of 16.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 14
Failed 1/16 tests, 93.75% okay (less 1 skipped test: 14 okay, 87.50%)
Failed Test Stat Wstat Total Fail Failed List of Failed
------------------------------------------------------------ -------------------
t\41prof_dump.t 1 256 16 1 6.25% 14
1 subtest skipped.
Failed 1/1 test scripts, 0.00% okay. 1/16 subtests failed, 93.75% okay.

C:\gabor\DBI-1.58>prove -vb t\zvg_41prof_dump.t
t\zvg_41prof_dump....1..16
ok 1 - use DBI;
ok 2 - use DBI::ProfileDumper;
ok 3 - The object isa DBI::db
ok 4 - The object isa DBI::ProfileDumper
ok 5 - The object isa HASH
ok 6 - The object isa ARRAY
ok 7 - The object isa DBI::st
ok 8
ok 9 - Profile is on disk and nonzero size
DBI::ProfileDumper 2.009658
Path = [ ]
Program = t\\zvg_41prof_dump.t

+ 1
= 7 0 0 0 0 1182858728.45313 1182858728.45313
+ 1 select mode,size,name from ?
= 2 0.03125 0.015625 0.015625 0.015625 1182858728.45313 1182858728.46875
+ 1
= 1 0 0 0 0 1182858728.48438 1182858728.48438
+ 1 select mode,size,name from ?
= 50 0 0 0 0 1182858728.48438 1182858728.48438
ok 10 - Found a version number
ok 11 - Version numbers match in DBI::ProfileDumper 2.009658
#
ok 12 - Found the Path
# Failed test (./t/41prof_dump.t at line 79)
ok 13 - Found the Program
# got: 't\\zvg_41prof_dump.t'
not ok 14 - Program matches
# expected: 't\zvg_41prof_dump.t'
ok 15
ok 16 # skip developer-only test
# Looks like you failed 1 tests of 16.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 14
Failed 1/16 tests, 93.75% okay (less 1 skipped test: 14 okay, 87.50%)
Failed Test Stat Wstat Total Fail Failed List of Failed
------------------------------------------------------------ -------------------
t\zvg_41prof_dump.t 1 256 16 1 6.25% 14
1 subtest skipped.
Failed 1/1 test scripts, 0.00% okay. 1/16 subtests failed, 93.75% okay.



Summary of my perl5 (revision 5 version 8 subversion 4) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH
SEED -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO
-DPERL_MSVCRT_READFIX',
optimize='-MD -Zi -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"C:\Perl\lib\CORE" -machine:x86'
libpth=C:\PROGRA~1\MICROS~3\VC98\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32
lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x8
'


Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 810
22751 Update to Test.pm 1.25
21540 Fix backward-compatibility issues in if.pm
Built under MSWin32
Compiled at Jun 1 2004 11:52:21
%ENV:
PERL5LIB="c:\gabor\p\lib"
@INC:
c:\gabor\p\lib/MSWin32-x86-multi-thread
c:\gabor\p\lib
C:/Perl/lib
C:/Perl/site/lib
.

--
Gabor Szabo
http://www.szabgab.com/
Perl Training in Israel http://www.pti.co.il/

Re: DBI-1.58 test failure on Windows

am 26.06.2007 15:25:05 von steve.hay

--------------030305010400000106080109
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Gabor Szabo wrote:
> Hi,
>
> both
> t\41prof_dump.t
> t\zvg_41prof_dump.t
> fail on plain ActivePerl 5.8.4 on Windows
>
[...]
> # Failed test (t\41prof_dump.t at line 79)
> not ok 14 - Program matches
> # got: 't\\41prof_dump.t'
> # expected: 't\41prof_dump.t'

Works fine for me (using bleadperl) when I just run "nmake test", but if
I explicitly run "perl -Mblib t\41prof_dump.t" then it fails as above.

Running "perl -Mblib t/41prof_dump.t" is fine, though, which explains
why "nmake test" works, given also that the Makefile has
"TEST_FILES=t/*.t" rather than "TEST_FILES=t\*.t".

Attached patch fixes it, but it's arguably just hiding the real problem
of having \\ where only \ was expected.

--

--------------030305010400000106080109
Content-Type: text/plain;
name="41prof_dump.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="41prof_dump.patch"

diff -ruN DBI-1.58.orig/t/41prof_dump.t DBI-1.58/t/41prof_dump.t
--- DBI-1.58.orig/t/41prof_dump.t 2007-06-15 22:49:16.000000000 +0100
+++ DBI-1.58/t/41prof_dump.t 2007-06-26 14:16:35.482433600 +0100
@@ -11,6 +11,7 @@

use DBI;

+use File::Spec::Functions qw(canonpath);
use Test::More;

BEGIN {
@@ -76,7 +77,7 @@
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' );
+is( canonpath($1), canonpath($0), 'Program matches' );

# check that expected key is there
like(join('', @prof), qr/\+\s+1\s+\Q$sql\E/m);

--------------030305010400000106080109--

Re: DBI-1.58 test failure on Windows

am 27.06.2007 11:09:15 von Tim.Bunce

--82I3+IH0IqGh5yIs
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Jun 26, 2007 at 02:25:05PM +0100, Steve Hay wrote:
> Gabor Szabo wrote:
> >Hi,
> >
> >both
> >t\41prof_dump.t
> >t\zvg_41prof_dump.t
> >fail on plain ActivePerl 5.8.4 on Windows
> >
> [...]
> ># Failed test (t\41prof_dump.t at line 79)
> >not ok 14 - Program matches
> ># got: 't\\41prof_dump.t'
> ># expected: 't\41prof_dump.t'
>
> Works fine for me (using bleadperl) when I just run "nmake test", but if
> I explicitly run "perl -Mblib t\41prof_dump.t" then it fails as above.
>
> Running "perl -Mblib t/41prof_dump.t" is fine, though, which explains
> why "nmake test" works, given also that the Makefile has
> "TEST_FILES=t/*.t" rather than "TEST_FILES=t\*.t".
>
> Attached patch fixes it, but it's arguably just hiding the real problem
> of having \\ where only \ was expected.

The bug is that DBI::ProfileDumper is 'escaping' the header strings but
DBI::ProfileData isn't unescaping them.

Please try the attached and let me know if it works for you.
Thanks!

Tim.

> --

> diff -ruN DBI-1.58.orig/t/41prof_dump.t DBI-1.58/t/41prof_dump.t
> --- DBI-1.58.orig/t/41prof_dump.t 2007-06-15 22:49:16.000000000 +0100
> +++ DBI-1.58/t/41prof_dump.t 2007-06-26 14:16:35.482433600 +0100
> @@ -11,6 +11,7 @@
>
> use DBI;
>
> +use File::Spec::Functions qw(canonpath);
> use Test::More;
>
> BEGIN {
> @@ -76,7 +77,7 @@
> 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' );
> +is( canonpath($1), canonpath($0), 'Program matches' );
>
> # check that expected key is there
> like(join('', @prof), qr/\+\s+1\s+\Q$sql\E/m);


--82I3+IH0IqGh5yIs
Content-Type: text/x-patch; charset=us-ascii
Content-Disposition: attachment; filename="ProfileData.pm.patch"

Index: lib/DBI/ProfileData.pm
============================================================ =======
--- lib/DBI/ProfileData.pm (revision 9676)
+++ lib/DBI/ProfileData.pm (working copy)
@@ -240,6 +240,16 @@
}
}

+
+sub unescape_key { # inverse of escape_key() in DBI::ProfileDumper
+ local $_ = shift;
+ s/(? + s/(? + s/\\\\/\\/g; # \\ to \
+ return $_;
+}
+
+
# reads the body of the profile data
sub _read_body {
my ($self, $fh, $filename) = @_;
@@ -249,20 +259,15 @@

# build up node array
my @path = ("");
- my (@data, $index, $key, $path_key);
+ my (@data, $path_key);
while (<$fh>) {
chomp;
if (/^\+\s+(\d+)\s?(.*)/) {
# it's a key
- ($key, $index) = ($2, $1 - 1);
+ my ($key, $index) = ($2, $1 - 1);

- # unmangle key
- $key =~ s/(? - $key =~ s/(? - $key =~ s/\\\\/\\/g; # \\ to \
-
$#path = $index; # truncate path to new length
- $path[$index] = $key; # place new key at end
+ $path[$index] = unescape_key($key); # place new key at end

}
elsif (s/^=\s+//) {

--82I3+IH0IqGh5yIs--

Re: DBI-1.58 test failure on Windows

am 27.06.2007 14:32:05 von steve.hay

Tim Bunce wrote:
> On Tue, Jun 26, 2007 at 02:25:05PM +0100, Steve Hay wrote:
>> Gabor Szabo wrote:
>>> Hi,
>>>
>>> both
>>> t\41prof_dump.t
>>> t\zvg_41prof_dump.t
>>> fail on plain ActivePerl 5.8.4 on Windows
>>>
>> [...]
>>> # Failed test (t\41prof_dump.t at line 79)
>>> not ok 14 - Program matches
>>> # got: 't\\41prof_dump.t'
>>> # expected: 't\41prof_dump.t'
>> Works fine for me (using bleadperl) when I just run "nmake test", but if
>> I explicitly run "perl -Mblib t\41prof_dump.t" then it fails as above.
>>
>> Running "perl -Mblib t/41prof_dump.t" is fine, though, which explains
>> why "nmake test" works, given also that the Makefile has
>> "TEST_FILES=t/*.t" rather than "TEST_FILES=t\*.t".
>>
>> Attached patch fixes it, but it's arguably just hiding the real problem
>> of having \\ where only \ was expected.
>
> The bug is that DBI::ProfileDumper is 'escaping' the header strings but
> DBI::ProfileData isn't unescaping them.
>
> Please try the attached and let me know if it works for you.
> Thanks!

Sorry, it still doesn't work:

not ok 14 - Program matches
# Failed test 'Program matches'
# at t\41prof_dump.t line 79.
# got: 't\\41prof_dump.t'
# expected: 't\41prof_dump.t'

Putting some debug into unescape_key() and escape_key() I see some
output from escape_key(), changing the \ to \\, but none from
unescape_key(). Are you sure DBI::ProfileData is even involved here?

--

Re: DBI-1.58 test failure on Windows

am 27.06.2007 23:34:01 von Tim.Bunce

On Wed, Jun 27, 2007 at 01:32:05PM +0100, Steve Hay wrote:
> Tim Bunce wrote:
> >Please try the attached and let me know if it works for you.
>
> Sorry, it still doesn't work:
>
> not ok 14 - Program matches
> # Failed test 'Program matches'
> # at t\41prof_dump.t line 79.
> # got: 't\\41prof_dump.t'
> # expected: 't\41prof_dump.t'
>
> Putting some debug into unescape_key() and escape_key() I see some
> output from escape_key(), changing the \ to \\, but none from
> unescape_key(). Are you sure DBI::ProfileData is even involved here?

D'oh! The test is reading the file directly, naughty.
I've just deleted that test.

Still, thanks for finding that bug, even if it wasn't what the test was showing :)

Tim.