On Tue, 17 Feb 2004, Stas Bekman wrote:

> Randy Kobes wrote:
> > On Tue, 3 Feb 2004, Christopher H. Laco wrote:
> >
> >
> >>I've installed Apache::Test 1.07 on ActiveState perl 5.6.1
> >>build 630 and am trying to make test scripts for a pile of
> >>pages in a package I'm workin on.
> >>
> >>If I pass in an -httpd path that has spaces in the path,
> >>it fails.
> >>
> >>    use ExtUtils::MakeMaker;
> >>    use Apache::TestMM qw(test clean);
> >>
> >>    push @ARGV, '-httpd', 'C:\Program Files\Apache Group\Apache\Apache.exe';
> >
> > [ .. ]
> >
> >>Is this an Apache::Test problem, or possible an nmake issue?
> >
> >
> > This case should be handled I'd think on the Apache::Test
> > side. Does
> >    my $exe = 'C:\Program Files\Apache Group\Apache\Apache.exe';
> >    $exe = Win32::GetShortPathName($exe);
> >    push @ARGV, '-httpd', $exe;
> > work? If so, I'll look at seeing where this could be added
> > within Apache::Test.
>
> This patch should probably take care of it. It's untested.

Thanks, Stas - it looks good (applied manually, and
informally tested, as I don't have Perl in a place with
spaces in the directory name). A couple of comments below:

> Index: lib/Apache/TestConfig.pm
> ===================================================================
> RCS file:
> /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
> retrieving revision 1.205
> diff -u -r1.205 TestConfig.pm
> --- lib/Apache/TestConfig.pm  18 Feb 2004 00:30:57 -0000      1.205
> +++ lib/Apache/TestConfig.pm  18 Feb 2004 04:40:21 -0000
> @@ -67,6 +67,16 @@
>      (map { $_ . '_module_name', "$_ module name"} qw(cgi ssl thread access
> auth)),
>   );
>
> +my %filepath_conf_opts = map { $_ => 1 }
> +    qw(top_dir t_dir t_conf t_logs t_conf_file src_dir serverroot
> +       documentroot bindir sbindir httpd apxs httpd_conf perlpod sslca
> +       libmodperl);
> +
> +sub conf_opt_is_a_filepath {
> +    my $opt = shift;
> +    $opt && exists $filepath_conf_opts{$opt};
> +}
> +
>   sub usage {
>       for my $hash (\%Usage) {
>           for (sort keys %$hash){
> Index: lib/Apache/TestRun.pm
> ===================================================================
> RCS file: 
> /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
> retrieving revision 1.149
> diff -u -r1.149 TestRun.pm
> --- lib/Apache/TestRun.pm     18 Feb 2004 04:09:08 -0000      1.149
> +++ lib/Apache/TestRun.pm     18 Feb 2004 04:40:21 -0000
> @@ -238,6 +238,15 @@
>           push @argv, $val;
>       }
>
> +    # fixup the filepath options on win32 (spaces, short names, etc.)
> +    if (Apache::TestConfig::WIN32) {
> +        require Win32::GetShortPathName;
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The require isn't required, as Win32::GetShortPathName is
a core function.

> +        for my $key (keys %conf_opts) {
> +            next unless Apache::TestConfig::conf_opt_is_a_filepath($key);
> +            $conf_opts{$key} = Win32::GetShortPathName($conf_opts{$key});
                                  ^^^^^^^^^^^^^^^^^^^^^^^
I think if one calls Win32::GetShortPathName
on something that has no short path name, then
nothing is returned. For example,
======================================================
use strict;
use warnings;
for ('C:\Program Files', 'C:\ProgramFiles') {
    my $x = Win32::GetShortPathName($_);
    if ($x) {
        print "$_ has a short name of $x\n";
    }
    else {
        print "$_ has no short name\n";
    }
}
=======================================================
prints
=======================================================
C:\Program Files has a short name of C:\PROGRA~1
C:\ProgramFiles has no short name
========================================================

Thus, the above should probably include

> +        for my $key (keys %conf_opts) {
> +            next unless Apache::TestConfig::conf_opt_is_a_filepath($key);
> + +          next unless $conf_opts{$key} =~ / /;
> +            $conf_opts{$key} = Win32::GetShortPathName($conf_opts{$key});

-- 
best regards,
randy

Reply via email to