user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/3] tests: replace mime_from_path with mime_load
  2020-04-25  5:52  7% [PATCH 0/3] remove Email::MIME->create use Eric Wong
@ 2020-04-25  5:52  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-04-25  5:52 UTC (permalink / raw)
  To: meta

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;
 };
 

^ permalink raw reply related	[relevance 6%]

* [PATCH 0/3] remove Email::MIME->create use
@ 2020-04-25  5:52  7% Eric Wong
  2020-04-25  5:52  6% ` [PATCH 3/3] tests: replace mime_from_path with mime_load Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-04-25  5:52 UTC (permalink / raw)
  To: meta

Instead, I used Email::MIME->create for a final time with [1/3]
to generate the data for [2/3].  Reducing dependencies on
Email::MIME will make it easier for us to switch it out with
a potentially better alternative.

Eric Wong (3):
  testcommon: introduce mime_load sub
  tests: remove Email::MIME->create use entirely
  tests: replace mime_from_path with mime_load

 MANIFEST                      | 12 ++++++++
 lib/PublicInbox/TestCommon.pm |  8 +++++-
 t/filter_base-junk.eml        | 19 +++++++++++++
 t/filter_base-xhtml.eml       | 19 +++++++++++++
 t/filter_base.t               | 53 ++---------------------------------
 t/filter_mirror.t             | 30 ++------------------
 t/mda-mime.eml                | 21 ++++++++++++++
 t/mda.t                       | 37 ++----------------------
 t/msg_iter-nested.eml         | 26 +++++++++++++++++
 t/msg_iter-order.eml          | 16 +++++++++++
 t/msg_iter.t                  | 24 ++++------------
 t/nntpd-tls.t                 |  4 +--
 t/plack-2-txt-bodies.eml      | 17 +++++++++++
 t/plack-attached-patch.eml    | 20 +++++++++++++
 t/plack-qp.eml                |  8 ++++++
 t/plack.t                     | 53 ++---------------------------------
 t/psgi_attach.eml             | 38 +++++++++++++++++++++++++
 t/psgi_attach.t               | 44 ++---------------------------
 t/psgi_v2-new.eml             | 17 +++++++++++
 t/psgi_v2-old.eml             | 17 +++++++++++
 t/psgi_v2.t                   | 22 ++-------------
 t/search-amsg.eml             | 23 +++++++++++++++
 t/search.t                    | 36 ++----------------------
 t/solver_git.t                |  4 +--
 24 files changed, 286 insertions(+), 282 deletions(-)
 create mode 100644 t/filter_base-junk.eml
 create mode 100644 t/filter_base-xhtml.eml
 create mode 100644 t/mda-mime.eml
 create mode 100644 t/msg_iter-nested.eml
 create mode 100644 t/msg_iter-order.eml
 create mode 100644 t/plack-2-txt-bodies.eml
 create mode 100644 t/plack-attached-patch.eml
 create mode 100644 t/plack-qp.eml
 create mode 100644 t/psgi_attach.eml
 create mode 100644 t/psgi_v2-new.eml
 create mode 100644 t/psgi_v2-old.eml
 create mode 100644 t/search-amsg.eml


^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-04-25  5:52  7% [PATCH 0/3] remove Email::MIME->create use Eric Wong
2020-04-25  5:52  6% ` [PATCH 3/3] tests: replace mime_from_path with mime_load Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).