+sub require_mods {
+ my @mods = @_;
+ my $maybe = pop @mods if $mods[-1] =~ /\A[0-9]+\z/;
+ my @need;
+ for my $mod (@mods) {
+ if ($mod eq 'Search::Xapian') {
+ if (eval { require PublicInbox::Search } &&
+ PublicInbox::Search::load_xapian()) {
+ next;
+ }
+ } elsif ($mod eq 'Search::Xapian::WritableDatabase') {
+ if (eval { require PublicInbox::SearchIdx } &&
+ PublicInbox::SearchIdx::load_xapian_writable()){
+ next;
+ }
+ } else {
+ eval "require $mod";
+ }
+ push @need, $mod if $@;
+ }
+ return unless @need;
+ my $m = join(', ', @need)." missing for $0";
+ Test::More::skip($m, $maybe) if $maybe;
+ Test::More::plan(skip_all => $m)
+}
+