]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
tests: add `+SCM_RIGHTS' as a require_mods target
authorEric Wong <e@80x24.org>
Mon, 4 Sep 2023 10:36:06 +0000 (10:36 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Sep 2023 03:01:42 +0000 (03:01 +0000)
We'll also ensure the existing `lei' target expands to depend on
`+SCM_RIGHTS', and use require_mods in t/lei-import-nntp.t and
t/lei.t so they can be skipped when Inline::C and Socket::MsgHdr
are missing on OpenBSD.

lib/PublicInbox/TestCommon.pm
t/lei-import-nntp.t
t/lei.t
t/xap_helper.t

index 6da993af8ac166365b3aab44bc52f262054bb3ed..a90e89d1f21fae70cd982b16628397b30e754ef4 100644 (file)
@@ -134,7 +134,7 @@ sub require_mods {
        while (my $mod = shift(@mods)) {
                if ($mod eq 'lei') {
                        require_git(2.6, $maybe ? $maybe : ());
-                       push @mods, qw(DBD::SQLite Search::Xapian);
+                       push @mods, qw(DBD::SQLite Search::Xapian +SCM_RIGHTS);
                        $mod = 'json'; # fall-through
                }
                if ($mod eq 'json') {
@@ -155,6 +155,11 @@ sub require_mods {
                                PublicInbox::Search::load_xapian()) {
                                next;
                        }
+               } elsif ($mod eq '+SCM_RIGHTS') {
+                       if (my $msg = need_scm_rights()) {
+                               push @need, $msg;
+                               next;
+                       }
                } elsif (index($mod, '||') >= 0) { # "Foo||Bar"
                        my $ok;
                        for my $m (split(/\Q||\E/, $mod)) {
@@ -567,13 +572,13 @@ sub ignore_inline_c_missing {
                grep(!/\bInline\b/, split(/^/m, $_[0])))));
 }
 
-sub no_scm_rights () {
+sub need_scm_rights () {
        state $ok = PublicInbox::Spawn->can('send_cmd4') || do {
                        require PublicInbox::Syscall;
-                       PublicInbox::Syscall->can('send_cmd4');
+                       PublicInbox::Syscall->can('send_cmd4'); # Linux only
                } || eval { require Socket::MsgHdr; 1 };
        return if $ok;
-       'Inline::C unconfigured/missing '.
+       'need SCM_RIGHTS support: Inline::C unconfigured/missing '.
        '(mkdir -p ~/.cache/public-inbox/inline-c) OR Socket::MsgHdr missing';
 }
 
@@ -601,8 +606,6 @@ SKIP: {
        $ENV{LANG} = $ENV{LC_ALL} = 'C';
        my (undef, $fn, $lineno) = caller(0);
        my $t = "$fn:$lineno";
-       state $msg = no_scm_rights();
-       skip $msg, 1 if $msg;
        $lei_opt = { 1 => \$lei_out, 2 => \$lei_err };
        my ($daemon_pid, $for_destroy, $daemon_xrd);
        my $tmpdir = $test_opt->{tmpdir};
index 2c48d9735c715d8c1c4e78812127afa71c50323b..c3ee06a24c1387bbdeec7d5649d612e2e68d6056 100644 (file)
@@ -1,9 +1,9 @@
 #!perl -w
-# Copyright (C) 2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
 require_git 2.6;
-require_mods(qw(json DBD::SQLite Search::Xapian Net::NNTP));
+require_mods(qw(lei json DBD::SQLite Search::Xapian Net::NNTP));
 my ($ro_home, $cfg_path) = setup_public_inboxes;
 my ($tmpdir, $for_destroy) = tmpdir;
 my $sock = tcp_server;
diff --git a/t/lei.t b/t/lei.t
index 5d0fa622000bc8a1dab054d2d2e1e652686f8b27..d83bde69fd44207a98e1b35564082f9941de47b8 100644 (file)
--- a/t/lei.t
+++ b/t/lei.t
@@ -1,7 +1,8 @@
 #!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict; use v5.10.1; use PublicInbox::TestCommon;
+require_mods 'lei';
 use File::Path qw(rmtree);
 
 # this only tests the basic help/config/init/completion bits of lei;
index f4b3581f3143d4769877aca7c4765b07a4c50fd4..0a21132900b3ea3b77cdf06308fab2dd39237615 100644 (file)
@@ -3,9 +3,7 @@
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use v5.12;
 use PublicInbox::TestCommon;
-require_mods(qw(DBD::SQLite Search::Xapian));
-my $msg = no_scm_rights;
-plan(skip_all => $msg) if $msg; # TODO: FIFO support?
+require_mods(qw(DBD::SQLite Search::Xapian +SCM_RIGHTS)); # TODO: FIFO support?
 use PublicInbox::Spawn qw(spawn);
 use Socket qw(AF_UNIX SOCK_SEQPACKET SOCK_STREAM);
 require PublicInbox::AutoReap;