develooper Front page | perl.perl5.porters | Postings from January 2008

Re: MM_Win32.t failures (caused by PathTools upgrade)

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
January 31, 2008 09:09
Subject:
Re: MM_Win32.t failures (caused by PathTools upgrade)
Message ID:
47A200B1.1020504@pobox.com
Steve Hay wrote:
> ExtUtils/t/MM_Win32.t has been failing two tests lately:
> 
> not ok 9 - catdir()
> #   Failed test 'catdir()'
> #   at ..\lib\ExtUtils\t\MM_Win32.t line 96.
> #          got: 'C:trick\dir\now_OK'
> #     expected: 'C:\trick\dir\now_OK'
> 
> not ok 11 - catfile()
> #   Failed test 'catfile()'
> #   at ..\lib\ExtUtils\t\MM_Win32.t line 105.
> #          got: 'C:trick\dir\now_OK\file.ext'
> #     expected: 'C:\trick\dir\now_OK\file.ext'
> 
> These are caused by the upgrade to PathTools-3.27 in #33042, which
> brought in a major rewrite of Win32's catdir, catfile and canonpath from
> PathTools-3.25_01.
> 
> In short, this program:
> 
> use File::Spec::Functions qw(catdir);
> my @path_eg = qw( c: trick dir/now_OK );
> print catdir(@path_eg);
> 
> used to output:
> 
> C:\trick\dir\now_OK
> 
> but now outputs:
> 
> C:trick\dir\now_OK
> 
> Is this new behaviour intended and correct (in which case
> ExtUtils/t/MM_Win32.t needs a simple tweak to fix), or is PathTools
> broken and needs fixing itself instead?

MakeMaker doesn't really care what the output is, as long as it's consistent. 
  The new behavior seems correct.  I'd have to go back and see what issue that 
test is actually testing.

MakeMaker runs catfile() through canonpath() to work around some old bugs. 
It's possible that canonpath() is the one translating C:trick\dir\now_OK into 
C:\trick\dir\now_OK.  If so, that's a bug.

Can you check what File::Spec->canonpath("C:trick\dir\now_OK") does?


> Either output is arguably correct (the notation "C:path" means the file
> or directory called "path" relative to the current directory on the "C:"
> drive, there being the notion of a current directory per drive), and the
> File::Spec docs don't make it clear which output is to be expected.
> 
> I can imagine that most people would expect catdir(qw(C: trick)) to
> produce "C:\trick". It currently doesn't, and it isn't clear what you
> have to do to get "C:\trick":

Probably use a blank directory to represent root.  That's what Unix does.  Try:

catdir( 'c:', '', 'trick', 'dir' );

Actually the correct answer is "none of the above" because catdir() uses 
directories, not volumes.  In reality the correct thing to use is catpath().


> and neither does this:
> 
> my @path_eg = qw( c: / trick dir/now_OK );
> print catdir(@path_eg);

That doesn't work?  Now that is odd.  Have you tried using backwhacks?

When in doubt, run it through splitpath() and splitdir().


-- 
...they shared one last kiss that left a bitter yet sweet taste in her
mouth--kind of like throwing up after eating a junior mint.
     -- Dishonorable Mention, 2005 Bulwer-Lytton Fiction Contest
            by Tami Farmer

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About