Further win32 related hacks.
Dan Brook [Sat, 6 Mar 2010 21:35:51 +0000 (21:35 +0000)]
lib/Gitalist/Git/Repository.pm
t/02git_CollectionOfRepositories_FromDirectory.t
t/02git_Repository.t
t/02git_util.t

index 986180a..03239c8 100644 (file)
@@ -147,6 +147,7 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
         if ($search) {
             $search->{type} = 'grep'
                 if $search->{type} eq 'commit';
+           no warnings; # where's this warning coming from?
             @search_opts = (
                 # This seems a little fragile ...
                 qq[--$search->{type}=$search->{text}],
index 41f7699..ac590ef 100644 (file)
@@ -12,7 +12,7 @@ my $repo_dir = "$Bin/lib/repositories";
 my $repo = Gitalist::Git::CollectionOfRepositories::FromDirectory->new( repo_dir => $repo_dir );
 isa_ok($repo, 'Gitalist::Git::CollectionOfRepositories::FromDirectory');
 
-is($repo->repo_dir, $repo_dir, "repo->repo_dir is correct" );
+is($repo->repo_dir, Path::Class::Dir->new($repo_dir), "repo->repo_dir is correct" );
 
 # 'bare.git' is a bare git repository in the repository dir
 use Path::Class;
index e8ee762..176651d 100644 (file)
@@ -8,16 +8,19 @@ use Encode qw/decode_utf8/;
 use Data::Dumper;
 
 BEGIN {
-    # Mocking to allow testing regardless of the user's locale
-    require I18N::Langinfo;
-    no warnings 'redefine';
-    *I18N::Langinfo::langinfo = sub($) {
+    # Don't die on win32.
+    eval {
+      # Mocking to allow testing regardless of the user's locale
+      require I18N::Langinfo;
+      no warnings 'redefine';
+      *I18N::Langinfo::langinfo = sub($) {
         return "UTF-8" if $_[0] == I18N::Langinfo::CODESET();
-    };
-    *CORE::GLOBAL::getpwuid = sub {
+      };
+      *CORE::GLOBAL::getpwuid = sub {
         wantarray
-            ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
-            : "test";
+         ? ("test", "x", "1000", "1000", "", "", "T\x{c3}\x{a9}st", "/home/test", "/bin/bash")
+          : "test";
+      };
     };
 }
 
@@ -75,7 +78,10 @@ like($proj->head_hash('HEAD'), qr/^([0-9a-fA-F]{40})$/, 'head_hash');
     isa_ok($tree[0], 'Gitalist::Git::Object', 'tree element 0');
 }
 
-my $owner = $proj->owner;
-is_flagged_utf8($owner, "Owner name is flagged as utf8");
-is_sane_utf8($owner, "Owner name is not double-encoded");
-is($owner, decode_utf8("T\x{c3}\x{a9}st"),  "Owner name is correct");
+# Be win32 friendly. Poor poor win32.
+if($^O ne 'MSWin32') {
+  my $owner = $proj->owner;
+  is_flagged_utf8($owner, "Owner name is flagged as utf8");
+  is_sane_utf8($owner, "Owner name is not double-encoded");
+  is($owner, decode_utf8("T\x{c3}\x{a9}st"),  "Owner name is correct");
+}
index 94f82f7..7cb99c5 100644 (file)
@@ -19,7 +19,7 @@ my $util = Gitalist::Git::Util->new(
 );
 isa_ok($util, 'Gitalist::Git::Util');
 
-like( $util->_git, qr#/git$#, 'git binary found');
+like( $util->_git, qr#\bgit(?:.CMD)$#, 'git binary found');
 isa_ok($util->gpp, 'Git::PurePerl', 'gpp instance created');
 
 done_testing;