From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7F2EE1F9FF for ; Mon, 15 Mar 2021 11:58:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 02/35] t/lei_xsearch: use create_inbox Date: Mon, 15 Mar 2021 12:57:53 +0100 Message-Id: <20210315115826.17591-3-e@80x24.org> In-Reply-To: <20210315115826.17591-1-e@80x24.org> References: <20210315115826.17591-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Less code and noticeably faster when TMPDIR is on an SSD --- t/lei_xsearch.t | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/t/lei_xsearch.t b/t/lei_xsearch.t index 5bfbcfe6..a1ab3ec8 100644 --- a/t/lei_xsearch.t +++ b/t/lei_xsearch.t @@ -3,7 +3,6 @@ # License: AGPL-3.0+ use strict; use v5.10.1; -use Test::More; use List::Util qw(shuffle max); use PublicInbox::TestCommon; use PublicInbox::Eml; @@ -16,17 +15,11 @@ my ($home, $for_destroy) = tmpdir(); my @ibx; for my $V (1..2) { for my $i (3..6) { - my $ibx = PublicInbox::InboxWritable->new({ - inboxdir => "$home/v$V-$i", - name => "test-v$V-$i", - version => $V, - indexlevel => 'medium', - -primary_address => "v$V-$i\@example.com", - }, { nproc => int(rand(8)) + 1 }); - push @ibx, $ibx; - my $im = $ibx->importer(0); - for my $j (0..9) { - my $eml = PublicInbox::Eml->new(< 'full', + version => $V, sub { + my ($im, $ibx) = @_; + for my $j (0..9) { + my $eml = PublicInbox::Eml->new(<{-primary_address} Date: Fri, 02 Oct 1993 0$V:0$i:0$j +0000 @@ -34,14 +27,14 @@ Subject: v${V}i${i}j$j Message-ID: ${V}er ${i}on j$j -EOF - $im->add($eml); - } - $im->done; +EOM + $im->add($eml) or BAIL_OUT '->add'; + } + }); # create_inbox } } -my $first = shift @ibx; is($first->{name}, 'test-v1-3', 'first plucked'); -my $last = pop @ibx; is($last->{name}, 'test-v2-6', 'last plucked'); +my $first = shift @ibx; is($first->{name}, 'v1-3', 'first plucked'); +my $last = pop @ibx; is($last->{name}, 'v2-6', 'last plucked'); my $eidx = PublicInbox::ExtSearchIdx->new("$home/eidx"); $eidx->attach_inbox($first); $eidx->attach_inbox($last);