From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3A22B1F461 for ; Wed, 13 Dec 2023 00:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1702428620; bh=xeF37NLnOmyQNyVhAF+h0fP8b+B7xA9vsVwZ1992TwY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PCLdI9vsHSqntFl8oWb9ULdEBwF+3hyXDhW+QIH4MGU6mOQiRUavSu9V2CTyOA4Go AAqHIgHwRTmPHojmcuF2M+H/CVsKOwy+e+C8pwRzMaKoBOhvBVOcXEJM4dbSGJRXmv uii75Z0hEr2WHamjsthItLP0l9rWJmz9s4AzJ4i4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/14] tests: account for missing git-http-backend Date: Wed, 13 Dec 2023 00:50:07 +0000 Message-ID: <20231213005019.26912-3-e@80x24.org> In-Reply-To: <20231213005019.26912-1-e@80x24.org> References: <20231213005019.26912-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Alpine Linux ships git-http-backend in the `git-daemon' package separately from `git', so we must test for its existence before attempting to test functionality which depends on it. --- lib/PublicInbox/TestCommon.pm | 19 ++++++++++++++++++- t/clone-coderepo.t | 1 + t/httpd.t | 1 + t/lei-mirror.t | 1 + t/www_listing.t | 1 + 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index d587bf10..27a758e4 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -25,7 +25,7 @@ BEGIN { run_script start_script key2sub xsys xsys_e xqx eml_load tick have_xapian_compact json_utf8 setup_public_inboxes create_inbox create_coderepo require_bsd kernel_version check_broken_tmpfs - quit_waiter_pipe wait_for_eof + quit_waiter_pipe wait_for_eof require_git_http_backend tcp_host_port test_lei lei lei_ok $lei_out $lei_err $lei_opt test_httpd xbail require_cmd is_xdeeply tail_f ignore_inline_c_missing no_pollerfd no_coredump cfg_new @@ -163,6 +163,23 @@ sub require_git ($;$) { skip("git $req+ required (have $cur_ver), skipping $nr tests") } +sub require_git_http_backend (;$) { + my ($nr) = @_; + state $ok = do { + require PublicInbox::Git; + my $git = PublicInbox::Git::check_git_exe() or plan + skip_all => 'nothing in public-inbox works w/o git'; + my $rdr = { 1 => \my $out, 2 => \my $err }; + xsys([$git, qw(http-backend)], undef, $rdr); + $out =~ /^Status:/ism; + }; + if (!$ok) { + my $msg = "`git http-backend' not available"; + defined($nr) ? skip $msg, $nr : plan skip_all => $msg; + } + $ok; +} + my %IPv6_VERSION = ( 'Net::NNTP' => 3.00, 'Mail::IMAPClient' => 3.40, diff --git a/t/clone-coderepo.t b/t/clone-coderepo.t index 0e6b4ac7..c0951941 100644 --- a/t/clone-coderepo.t +++ b/t/clone-coderepo.t @@ -8,6 +8,7 @@ use File::Temp; use File::Path qw(remove_tree); use PublicInbox::SHA qw(sha1_hex); require_mods(qw(json Plack::Builder HTTP::Date HTTP::Status)); +require_git_http_backend; require_git '1.8.5'; require_cmd 'curl'; require_ok 'PublicInbox::LeiMirror'; diff --git a/t/httpd.t b/t/httpd.t index 0421c7ea..c0fbaa22 100644 --- a/t/httpd.t +++ b/t/httpd.t @@ -7,6 +7,7 @@ use PublicInbox::TestCommon; use PublicInbox::Eml; use Socket qw(IPPROTO_TCP SOL_SOCKET); require_mods(qw(Plack::Util Plack::Builder HTTP::Date HTTP::Status)); +require_git_http_backend; # FIXME: too much setup my ($tmpdir, $for_destroy) = tmpdir(); diff --git a/t/lei-mirror.t b/t/lei-mirror.t index 37c9751b..76041b73 100644 --- a/t/lei-mirror.t +++ b/t/lei-mirror.t @@ -5,6 +5,7 @@ use v5.12; use PublicInbox::TestCommon; use PublicInbox::Inbox; require_mods(qw(-httpd lei DBD::SQLite)); require_cmd('curl'); +require_git_http_backend; use PublicInbox::Spawn qw(which); require PublicInbox::Msgmap; my $sock = tcp_server(); diff --git a/t/www_listing.t b/t/www_listing.t index 709dbd05..0a4c79e8 100644 --- a/t/www_listing.t +++ b/t/www_listing.t @@ -77,6 +77,7 @@ sub tiny_test { my $td; SKIP: { + require_git_http_backend 1; my $err = "$tmpdir/stderr.log"; my $out = "$tmpdir/stdout.log"; my $alt = "$tmpdir/alt.git";