From db8d6aadf317d912839510afcd05b6d4bce08237 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Tue, 12 Nov 2019 20:48:50 -0700 Subject: [PATCH] do not die in test if there is no git executable --- t/app-codeowners-util.t | 8 ++++++-- t/app-codeowners.t | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) 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 } -- 2.44.0