Subject: | Domain/Node fix + odd '&' => '&&' fix |
Hi Rob,
Was just looking at some test failures (via CPAN-YACSmoke obviously) and picked up that File-HomeDir-Win32-0.03 wasn't passing tests on my machine. There are two reasons why, the first I understand, but the other I am assuming was a typo.
1) Node and Domain.
My machine was originally set up as a Star (MessageLabs sister company) machine, but since then my network access has been fixed to use the correct domain. As such my profile, using Win32::NodeName in _find_homedirs(), doesn't get logged, causing all sorts of test failures. The attached patch additionally uses Win32::DomainName to record profiles.
2) & and &&
Following the call to _find_homedirs() in the import() function, the condition uses '&'. While this works in some cases, I get test failures in 01-dynamic.t and 01-warning.t. Changing to '&&' works fine.
3) test change
While checking out the above I changed two tests in 01-dynamic.t to help me see what was being affected, as such I think it would be better to use these (is() instead of ok() and eq).
Patch has all the above fixes. Use as according to taste :)
BTW Now that I've got my head around Sean's module and your module, and the fact you have said you no longer have a Windows box, if you want a new maintainer, let me know.
Barbie.
--- File-HomeDir-Win32-0.03/t/01-dynamic.t Thu Nov 3 16:42:03 2005
+++ File-HomeDir-Win32-0.03_01/t/01-dynamic.t Thu Nov 3 15:54:30 2005
@@ -25,12 +25,12 @@
}
ok( defined home(), "home defined");
-ok( home() eq home($ENV{USERNAME}), "home = home(username)");
+is( home(), home($ENV{USERNAME}), "home = home(username)");
ok( -d home(), "home exists");
{
- ok( $~{''} eq home(), "\$~{} = home(username)");
- ok( $~{$ENV{USERNAME}} eq home(), "\$~{} = home(username)");
+ is( $~{''}, home(), "\$~{} = home(username)");
+ is( $~{$ENV{USERNAME}}, home(), "\$~{} = home(username)");
}
--- File-HomeDir-Win32-0.03/lib/File/HomeDir/Win32.pm Thu Nov 3 16:42:02 2005
+++ File-HomeDir-Win32-0.03_01/lib/File/HomeDir/Win32.pm Thu Nov 3 16:53:51 2005
@@ -40,15 +40,15 @@
while (my $level = shift @names) {
$level .= "::",
- if (@names);
+ if (@names);
return,
- unless (defined $stash->{$level});
+ unless (defined $stash->{$level});
if (@names) {
- $stash = $stash->{$level};
+ $stash = $stash->{$level};
} else {
- no warnings 'redefine';
- $stash->{$level} = $value,
- if ((defined &{$stash->{$level}}) && ((ref $value) eq "CODE"));
+ no warnings 'redefine';
+ $stash->{$level} = $value,
+ if ((defined &{$stash->{$level}}) && ((ref $value) eq "CODE"));
}
}
}
@@ -56,7 +56,7 @@
# print STDERR "caller = $caller\n";
_find_homedirs(), unless (keys %HomeDirs);
- if ((keys %HomeDirs) & (defined &{$stash->{home}})) {
+ if ((keys %HomeDirs) && (defined &{$stash->{home}})) {
if (@_ > 1) {
carp "Exporter arguments ignored";
}
@@ -79,7 +79,9 @@
sub _find_homedirs {
%HomeDirs = ( );
- my $node = Win32::NodeName;
+ my $node_name = Win32::NodeName;
+ my $domain_name = Win32::DomainName;
+
my $profiles = $Registry{'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\'};
unless ($profiles) {
# Windows 98
@@ -96,13 +98,13 @@
my $uid = Win32::Security::SID::ConvertSidToName($sid);
my $domain = "";
if ($uid =~ /^(.+)\\(.+)$/) {
- $domain = $1;
- $uid = $2;
+ $domain = $1;
+ $uid = $2;
}
- if ($domain eq $node) {
- my $path = $profiles->{$p}->{ProfileImagePath};
- $path =~ s/\%(.+)\%/$ENV{$1}/eg;
- $HomeDirs{$uid} = $path;
+ if ($domain eq $node_name || $domain eq $domain_name) {
+ my $path = $profiles->{$p}->{ProfileImagePath};
+ $path =~ s/\%(.+)\%/$ENV{$1}/eg;
+ $HomeDirs{$uid} = $path;
}
}
}