X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=t%2Fapp-codeowners-util.t;h=477d848292ee0e9169033c85c64ee2411dc714b8;hb=8019ec2b1e1938711e4cccf4af19e61512ee8dcd;hp=af153e9566a95e1ede32c57782e2729cb9358421;hpb=26eed33eb4aa577d9347e5ebaf577b3e3a2c0396;p=chaz%2Fgit-codeowners diff --git a/t/app-codeowners-util.t b/t/app-codeowners-util.t index af153e9..477d848 100644 --- a/t/app-codeowners-util.t +++ b/t/app-codeowners-util.t @@ -42,16 +42,19 @@ subtest 'git_ls_files' => sub { subtest 'git_toplevel' => sub { plan skip_all => 'Cannot run git' if !$can_git; my $repodir =_setup_git_repo(); + my $repodir_fixed = _fix_win32_path($repodir); my $r = App::Codeowners::Util::git_toplevel($repodir); - is($r, $repodir, 'found toplevel directory from toplevel'); + is($r->canonpath, $repodir_fixed->canonpath, 'found toplevel directory from toplevel'); $r = App::Codeowners::Util::git_toplevel($repodir->child('a/b')); - is($r, $repodir, 'found toplevel directory'); + is($r->canonpath, $repodir_fixed->canonpath, 'found toplevel directory'); }; subtest 'find_nearest_codeowners' => sub { + plan skip_all => 'Cannot run git' if !$can_git; my $repodir =_setup_git_repo(); + $repodir->child('docs')->mkpath; my $filepath = _spew_codeowners($repodir->child('docs/CODEOWNERS')); @@ -60,9 +63,10 @@ subtest 'find_nearest_codeowners' => sub { }; subtest 'find_codeowners_in_directory' => sub { + plan skip_all => 'Cannot run git' if !$can_git; my $repodir =_setup_git_repo(); - $repodir->child('docs')->mkpath; + $repodir->child('docs')->mkpath; my $filepath = _spew_codeowners($repodir->child('docs/CODEOWNERS')); my $r = App::Codeowners::Util::find_codeowners_in_directory($repodir); @@ -77,7 +81,8 @@ done_testing; exit; sub _can_git { - my (undef, $version) = run_git('--version'); + my (undef, $version) = eval { run_git('--version') }; + note $@ if $@; note "Found: $version" if $version; return $version && $version ge 'git version 1.8.5'; # for -C flag } @@ -86,6 +91,8 @@ sub _setup_git_repo { my $repodir = tempdir; run_git('-C', $repodir, 'init')->wait; + run_git('-C', $repodir, qw{config --local user.email app-codeowners@example.com})->wait; + run_git('-C', $repodir, qw{config --local user.name App-Codeowners})->wait; $repodir->child('foo.txt')->touchpath; $repodir->child('a/b/c/bar.txt')->touchpath; @@ -93,6 +100,15 @@ sub _setup_git_repo { return $repodir; } +sub _fix_win32_path { + my $path = shift; + # Git for Windows shows full paths + if (eval { require Win32 }) { + $path = path(Win32::GetLongPathName($path)); + } + return $path; +} + sub _spew_codeowners { my $path = path(shift); $path->spew_utf8(\"foo.txt \@twix\n");