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-ASN: 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 0F0B11F934 for ; Mon, 4 Oct 2021 00:07:18 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] t/thread-cycle: make Email::Simple optional Date: Sun, 3 Oct 2021 19:07:16 -0500 Message-Id: <20211004000717.18965-2-e@80x24.org> In-Reply-To: <20211004000717.18965-1-e@80x24.org> References: <20211004000717.18965-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We only use it if Mail::Thread is available, and often it's not. --- t/thread-cycle.t | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/t/thread-cycle.t b/t/thread-cycle.t index 613c142e65cd..4b47c01c37c1 100644 --- a/t/thread-cycle.t +++ b/t/thread-cycle.t @@ -1,19 +1,16 @@ # Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ -use strict; -use warnings; -use Test::More; -use PublicInbox::TestCommon; -require_mods 'Email::Simple'; +use strict; use v5.10.1; use PublicInbox::TestCommon; use_ok('PublicInbox::SearchThread'); my $mt = eval { require Mail::Thread; no warnings 'once'; $Mail::Thread::nosubject = 1; $Mail::Thread::noprune = 1; + require Email::Simple; # required by Mail::Thread (via Email::Abstract) }; -sub make_objs { +my $make_objs = sub { my @simples; my $n = 0; my @msgs = map { @@ -21,17 +18,19 @@ sub make_objs { $msg->{ds} ||= ++$n; $msg->{references} =~ s/\s+/ /sg if $msg->{references}; $msg->{blob} = '0'x40; # any dummy value will do, here - my $simple = Email::Simple->create(header => [ - 'Message-ID' => "<$msg->{mid}>", - 'References' => $msg->{references}, - ]); - push @simples, $simple; + if ($mt) { + my $simple = Email::Simple->create(header => [ + 'Message-ID' => "<$msg->{mid}>", + 'References' => $msg->{references}, + ]); + push @simples, $simple; + } bless $msg, 'PublicInbox::Smsg' } @_; (\@simples, \@msgs); -} +}; -my ($simples, $smsgs) = make_objs( +my ($simples, $smsgs) = $make_objs->( # data from t/testbox-6 in Mail::Thread 2.55: { mid => '20021124145312.GA1759@nlin.net' }, { mid => 'slrnau448m.7l4.markj+0111@cloaked.freeserve.co.uk', @@ -79,13 +78,13 @@ my @backwards = ( { mid => 8, references => '' } ); -($simples, $smsgs) = make_objs(@backwards); +($simples, $smsgs) = $make_objs->(@backwards); my $backward = thread_to_s($smsgs); SKIP: { skip 'Mail::Thread missing', 1 unless $mt; check_mt($backward, $simples, 'matches Mail::Thread backwards'); } -($simples, $smsgs) = make_objs(reverse @backwards); +($simples, $smsgs) = $make_objs->(reverse @backwards); my $forward = thread_to_s($smsgs); unless ('Mail::Thread sorts by Date') { SKIP: {