about summary refs log tree commit homepage
path: root/lib/PublicInbox/TestCommon.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-04 10:36:06 +0000
committerEric Wong <e@80x24.org>2023-09-05 03:01:42 +0000
commit2232ff9a7d99b567618f27380603ca52dd296144 (patch)
tree253e89dd290e140eff0e6f1dabc5a2fda2cf67b0 /lib/PublicInbox/TestCommon.pm
parent38ed82d426aceb1a185071b5339f21e65e01490a (diff)
downloadpublic-inbox-2232ff9a7d99b567618f27380603ca52dd296144.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/TestCommon.pm')
-rw-r--r--lib/PublicInbox/TestCommon.pm15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 6da993af..a90e89d1 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -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};