From aa454143b1f26ffdf5f32f17c2032473d70eceae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 Apr 2020 05:52:23 +0000 Subject: [PATCH] tests: replace mime_from_path with mime_load 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; }; -- 2.44.0