]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/v2reindex.t
favor `do {}' over `eval {}' for localized slurp
[public-inbox.git] / t / v2reindex.t
index a14bf798d6f6c67a8e92532ba0d26460c63a7354..b6164ff810febd2936236e7ac2bd42f0d2e3bdc8 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use warnings;
@@ -8,11 +8,7 @@ use PublicInbox::ContentId qw(content_digest);
 use File::Path qw(remove_tree);
 use PublicInbox::TestCommon;
 require_git(2.6);
-
-foreach my $mod (qw(DBD::SQLite Search::Xapian)) {
-       eval "require $mod";
-       plan skip_all => "$mod missing for v2reindex.t" if $@;
-}
+require_mods(qw(DBD::SQLite Search::Xapian));
 use_ok 'PublicInbox::V2Writable';
 my ($inboxdir, $for_destroy) = tmpdir();
 my $ibx_config = {
@@ -22,12 +18,11 @@ my $ibx_config = {
        -primary_address => 'test@example.com',
        indexlevel => 'full',
 };
-my $agpl = eval {
+my $agpl = do {
        open my $fh, '<', 'COPYING' or die "can't open COPYING: $!";
        local $/;
        <$fh>;
 };
-$agpl or die "AGPL or die :P\n";
 my $phrase = q("defending all users' freedom");
 my $mime = PublicInbox::MIME->create(
        header => [
@@ -161,7 +156,7 @@ ok(!-d $xap, 'Xapian directories removed again');
        is($ibx->mm->num_highwater, 10, 'num_highwater as expected');
        my $mset = $ibx->search->query($phrase, {mset=>1});
        isnt($mset->size, 0, "phrase search succeeds on indexlevel=full");
-       for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
+       for (glob("$xap/*/*")) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
 
        my ($min, $max) = $ibx->mm->minmax;
        is_deeply($ibx->mm->msg_range(\$min, $max), $msgmap, 'msgmap unchanged');
@@ -197,7 +192,7 @@ ok(!-d $xap, 'Xapian directories removed again');
        $words =~ tr/"'//d;
        my $mset = $ibx->search->query($words, {mset=>1});
        isnt($mset->size, 0, "normal search works on indexlevel=medium");
-       for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
+       for (glob("$xap/*/*")) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
 
        ok($sizes{full} > $sizes{medium}, 'medium is smaller than full');
 
@@ -227,7 +222,7 @@ ok(!-d $xap, 'Xapian directories removed again');
 
        isnt($ibx->search, 'no search for basic');
 
-       for (<"$xap/*/*">) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
+       for (glob("$xap/*/*")) { $sizes{$ibx->{indexlevel}} += -s _ if -f $_ }
        ok($sizes{medium} > $sizes{basic}, 'basic is smaller than medium');
 
        my ($min, $max) = $ibx->mm->minmax;