On Sun, 30 May 2004, Stas Bekman wrote:
> Randy Kobes wrote:
> > I was just wondering if a consensus has been reached on the
> > issue of DOS short/long path names as used in the mp2 tests
> > (to recall, in some of the tests, one ends up comparing a
> > short path to a long path name, which fails as a string
> > comparison, but will pass if one converts them both to, eg,
> > the long path name). As it doesn't look like File::Spec is
> > intended to handle this sort of thing, as it involves
> > interaction with the file system to get the long path name,
> > there's a few options:
> > - wait for a wrapper around File::Spec to handle this
> > sort of thing?
> > - extend Apache::TestUtil to have a t_canonpath, like the
> > current t_catfile, which for Win32 uses
> > Win32::GetLongPathName() to convert to the long path name;
> > - rather than a t_canonpath and t_catfile (and possibly
> > other t_* functions as wrappers around File::Spec
> > functions), use a t_file_cmp() function which just returns
> > t_cmp for Unix and does the long path name
> > conversion/comparison for Win32?
>
> I like the idea of t_file_cmp (perhaps call it
> t_filepath_cmp), since it'll hide all the platform
> specific issues from the test. But whatever you think is
> the best is up to you (as long as it doesn't add clutter
> to the tests themselves).
>
> Thanks Randy
Thanks, Stas - the diff below implements a t_filepath_cmp
to do this, and with it, all tests pass on Win32.
I found one scenario explaining why sometimes this patch is
needed, and sometimes not. If I open up a new DOS window,
and change into the modperl-2.0 directory (which has both a
short and long pathname representation), the long pathname
is used, and the patch isn't needed. However, if I then edit
a file with the "edit" command within the window (which
invokes a terminal-based text editor), afterwards the short
pathname of the directory is used. This represents a new
level of convenience in working with Win32 ;)
Anyway, this diff should work whether the long or the short
pathname is being used.
=========================================================
Index: Apache-Test/lib/Apache/TestUtil.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestUtil.pm,v
retrieving revision 1.38
diff -u -r1.38 TestUtil.pm
--- Apache-Test/lib/Apache/TestUtil.pm 12 Apr 2004 19:53:42 -0000 1.38
+++ Apache-Test/lib/Apache/TestUtil.pm 31 May 2004 03:55:35 -0000
@@ -35,7 +35,7 @@
@ISA = qw(Exporter);
@EXPORT = qw(t_cmp t_debug t_append_file t_write_file t_open_file
- t_mkdir t_rmtree t_is_equal
+ t_mkdir t_rmtree t_is_equal t_filepath_cmp
t_server_log_error_is_expected t_server_log_warn_is_expected
t_client_log_error_is_expected t_client_log_warn_is_expected
);
@@ -105,6 +105,18 @@
t_debug("received: " . struct_as_string(0, $_[1]));
return t_is_equal($_[0], $_[1]);
}
+
+# Essentially t_cmp, but on Win32, first converts pathnames
+# to their DOS long name.
+sub t_filepath_cmp ($$;$) {
+ my @args = Apache::TestConfig::WIN32 ?
+ (Win32::GetLongPathName($_[0]), Win32::GetLongPathName($_[1])) :
+ ($_[0], $_[1]);
+ return @_ == 3 ?
+ t_cmp($args[0], $args[1], $_[2]) :
+ t_cmp($args[0], $args[1]);
+}
+
*expand = HAS_DUMPER ?
sub { map { ref $_ ? Data::Dumper::Dumper($_) : $_ } @_ } :
Index: t/response/TestCompat/apache.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache.pm,v
retrieving revision 1.11
diff -u -r1.11 apache.pm
--- t/response/TestCompat/apache.pm 5 Mar 2004 18:19:15 -0000 1.11
+++ t/response/TestCompat/apache.pm 31 May 2004 03:55:35 -0000
@@ -64,29 +64,29 @@
'Apache->httpd_conf');
$r->server->server_admin($admin);
- ok t_cmp(canonpath($Apache::Server::CWD),
- canonpath(Apache::Test::config()->{vars}->{serverroot}),
- '$Apache::Server::CWD');
+ ok t_filepath_cmp(canonpath($Apache::Server::CWD),
+ canonpath(Apache::Test::config()->{vars}->{serverroot}),
+ '$Apache::Server::CWD');
- ok t_cmp(canonpath($Apache::Server::CWD),
- canonpath($r->server_root_relative),
- '$r->server_root_relative()');
+ ok t_filepath_cmp(canonpath($Apache::Server::CWD),
+ canonpath($r->server_root_relative),
+ '$r->server_root_relative()');
- ok t_cmp(catfile($Apache::Server::CWD, 'conf'),
- canonpath($r->server_root_relative('conf')),
- "\$r->server_root_relative('conf')");
+ ok t_filepath_cmp(catfile($Apache::Server::CWD, 'conf'),
+ canonpath($r->server_root_relative('conf')),
+ "\$r->server_root_relative('conf')");
# Apache->server_root_relative
{
Apache::compat::override_mp2_api('Apache::server_root_relative');
- ok t_cmp(catfile($Apache::Server::CWD, 'conf'),
- canonpath(Apache->server_root_relative('conf')),
- "Apache->server_root_relative('conf')");
+ ok t_filepath_cmp(catfile($Apache::Server::CWD, 'conf'),
+ canonpath(Apache->server_root_relative('conf')),
+ "Apache->server_root_relative('conf')");
- ok t_cmp(canonpath($Apache::Server::CWD),
- canonpath(Apache->server_root_relative),
- 'Apache->server_root_relative()');
+ ok t_filepath_cmp(canonpath($Apache::Server::CWD),
+ canonpath(Apache->server_root_relative),
+ 'Apache->server_root_relative()');
Apache::compat::restore_mp2_api('Apache::server_root_relative');
}
Index: t/response/TestAPI/server_util.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/server_util.pm,v
retrieving revision 1.14
diff -u -r1.14 server_util.pm
--- t/response/TestAPI/server_util.pm 5 Mar 2004 18:19:15 -0000 1.14
+++ t/response/TestAPI/server_util.pm 31 May 2004 03:55:35 -0000
@@ -71,18 +71,18 @@
foreach my $p (keys %pools) {
- ok t_cmp(catfile($serverroot, 'conf'),
- canonpath(Apache::server_root_relative($pools{$p},
- 'conf')),
- "Apache:::server_root_relative($p, 'conf')");
+ ok t_filepath_cmp(catfile($serverroot, 'conf'),
+ canonpath(Apache::server_root_relative($pools{$p},
+ 'conf')),
+ "Apache:::server_root_relative($p, 'conf')");
}
# dig out the pool from valid objects
foreach my $obj (keys %objects) {
- ok t_cmp(catfile($serverroot, 'conf'),
- canonpath($objects{$obj}->server_root_relative('conf')),
- "$obj->server_root_relative('conf')");
+ ok t_filepath_cmp(catfile($serverroot, 'conf'),
+ canonpath($objects{$obj}->server_root_relative('conf')),
+ "$obj->server_root_relative('conf')");
}
# syntax - unrecognized objects don't segfault
@@ -96,26 +96,26 @@
}
# no file argument gives ServerRoot
- ok t_cmp(canonpath($serverroot),
- canonpath($r->server_root_relative),
- '$r->server_root_relative()');
-
- ok t_cmp(canonpath($serverroot),
- canonpath(Apache::server_root_relative($r->pool)),
- 'Apache::server_root_relative($r->pool)');
+ ok t_filepath_cmp(canonpath($serverroot),
+ canonpath($r->server_root_relative),
+ '$r->server_root_relative()');
+
+ ok t_filepath_cmp(canonpath($serverroot),
+ canonpath(Apache::server_root_relative($r->pool)),
+ 'Apache::server_root_relative($r->pool)');
# Apache::server_root is also the ServerRoot constant
- ok t_cmp(canonpath(Apache::server_root),
- canonpath($r->server_root_relative),
- 'Apache::server_root');
+ ok t_filepath_cmp(canonpath(Apache::server_root),
+ canonpath($r->server_root_relative),
+ 'Apache::server_root');
{
# absolute paths should resolve to themselves
my $dir = $r->server_root_relative('logs');
- ok t_cmp($r->server_root_relative($dir),
- $dir,
- "\$r->server_root_relative($dir)");
+ ok t_filepath_cmp($r->server_root_relative($dir),
+ $dir,
+ "\$r->server_root_relative($dir)");
}
t_debug('registering method FOO');
Index: t/response/TestAPI/server_const.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestAPI/server_const.pm,v
retrieving revision 1.3
diff -u -r1.3 server_const.pm
--- t/response/TestAPI/server_const.pm 5 Mar 2004 18:19:15 -0000 1.3
+++ t/response/TestAPI/server_const.pm 31 May 2004 03:55:35 -0000
@@ -28,9 +28,9 @@
# test Apache::Server constant subroutines
- ok t_cmp(canonpath($root),
- canonpath(Apache::server_root),
- 'Apache::server_root()');
+ ok t_filepath_cmp(canonpath($root),
+ canonpath(Apache::server_root),
+ 'Apache::server_root()');
ok t_cmp($built,
=================================================================
--
best regards,
randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]