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 64CC91FA04 for ; Sat, 25 Apr 2020 05:52:24 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/3] tests: replace mime_from_path with mime_load Date: Sat, 25 Apr 2020 05:52:23 +0000 Message-Id: <20200425055223.21879-4-e@yhbt.net> In-Reply-To: <20200425055223.21879-1-e@yhbt.net> References: <20200425055223.21879-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: mime_from_path is designed to fail gracefully in busy Maildirs whereas mime_load was made for loading files from a work tree. --- t/mda.t | 4 +--- t/msg_iter.t | 9 ++------- t/nntpd-tls.t | 4 +--- t/search.t | 4 +--- t/solver_git.t | 4 +--- 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/t/mda.t b/t/mda.t index 863eaf8f..03cc4bc3 100644 --- a/t/mda.t +++ b/t/mda.t @@ -62,9 +62,7 @@ local $ENV{GIT_COMMITTER_NAME} = eval { use PublicInbox::MDA; use PublicInbox::Address; use Encode qw/encode/; - my $eml = 't/utf8.eml'; - my $msg = PublicInbox::InboxWritable::mime_from_path($eml) or - die "failed to open $eml: $!"; + my $msg = mime_load 't/utf8.eml'; my $from = $msg->header('From'); my ($author) = PublicInbox::Address::names($from); my ($email) = PublicInbox::Address::emails($from); diff --git a/t/msg_iter.t b/t/msg_iter.t index 6adbf165..5c57e043 100644 --- a/t/msg_iter.t +++ b/t/msg_iter.t @@ -5,7 +5,6 @@ use warnings; use Test::More; use PublicInbox::TestCommon; use PublicInbox::Hval qw(ascii_html); -use PublicInbox::InboxWritable; use_ok('PublicInbox::MsgIter'); { @@ -34,9 +33,7 @@ use_ok('PublicInbox::MsgIter'); } { - my $f = 't/iso-2202-jp.eml'; - my $mime = PublicInbox::InboxWritable::mime_from_path($f) or - die "open $f: $!"; + my $mime = mime_load 't/iso-2202-jp.eml'; my $raw = ''; msg_iter($mime, sub { my ($part, $level, @ex) = @{$_[0]}; @@ -49,9 +46,7 @@ use_ok('PublicInbox::MsgIter'); } { - my $f = 't/x-unknown-alpine.eml'; - my $mime = PublicInbox::InboxWritable::mime_from_path($f) or - die "open $f: $!"; + my $mime = mime_load 't/x-unknown-alpine.eml'; my $raw = ''; msg_iter($mime, sub { my ($part, $level, @ex) = @{$_[0]}; diff --git a/t/nntpd-tls.t b/t/nntpd-tls.t index a0522e1f..0ad29be0 100644 --- a/t/nntpd-tls.t +++ b/t/nntpd-tls.t @@ -63,9 +63,7 @@ EOF { my $im = $ibx->importer(0); - my $eml = 't/data/0001.patch'; - my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or - die "open $eml: $!"; + my $mime = mime_load 't/data/0001.patch'; ok($im->add($mime), 'message added'); $im->done; if ($version == 1) { diff --git a/t/search.t b/t/search.t index 40264345..83986837 100644 --- a/t/search.t +++ b/t/search.t @@ -286,9 +286,7 @@ EOF }); $ibx->with_umask(sub { - my $eml = 't/utf8.eml'; - my $mime = PublicInbox::InboxWritable::mime_from_path($eml) or - die "open $eml: $!"; + my $mime = mime_load 't/utf8.eml'; my $doc_id = $rw->add_message($mime); ok($doc_id > 0, 'message indexed doc_id with UTF-8'); my $msg = $rw->query('m:testmessage@example.com', {limit => 1})->[0]; diff --git a/t/solver_git.t b/t/solver_git.t index 7f79ff4c..c483aba1 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -29,9 +29,7 @@ my $im = PublicInbox::V2Writable->new($ibx, 1); $im->{parallel} = 0; my $deliver_patch = sub ($) { - my $mime = PublicInbox::InboxWritable::mime_from_path($_[0]) or - die "open $_[0]: $!"; - $im->add($mime); + $im->add(mime_load($_[0])); $im->done; };