From: Charles McGarvey Date: Wed, 13 Nov 2019 03:48:50 +0000 (-0700) Subject: do not die in test if there is no git executable X-Git-Tag: v0.42~4 X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=db8d6aadf317d912839510afcd05b6d4bce08237;p=chaz%2Fgit-codeowners do not die in test if there is no git executable --- diff --git a/t/app-codeowners-util.t b/t/app-codeowners-util.t index af153e9..2edbcc7 100644 --- a/t/app-codeowners-util.t +++ b/t/app-codeowners-util.t @@ -51,7 +51,9 @@ subtest 'git_toplevel' => sub { }; 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 +62,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 +80,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 } diff --git a/t/app-codeowners.t b/t/app-codeowners.t index e3a1e2e..6441539 100644 --- a/t/app-codeowners.t +++ b/t/app-codeowners.t @@ -76,7 +76,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 }