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 4/4] t/mda.t: avoid needless use of Email::Simple
  2020-04-21 21:16  6% [PATCH 0/4] some test cleanups Eric Wong
@ 2020-04-21 21:16  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-04-21 21:16 UTC (permalink / raw)
  To: meta

Totally pointless to create an object only to convert
it back to a raw string for -mda input.
---
 t/mda.t | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/t/mda.t b/t/mda.t
index dc691616..fb505146 100644
--- a/t/mda.t
+++ b/t/mda.t
@@ -87,7 +87,7 @@ die $@ if $@;
 	local $ENV{PI_EMERGENCY} = $faildir;
 	local $ENV{HOME} = $home;
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: Me <me\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -96,8 +96,6 @@ Subject: hihi
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	# ensure successful message delivery
 	{
 		local $ENV{PATH} = $main_path;
@@ -177,7 +175,7 @@ Date: deadbeef
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
 	local $ENV{PATH} = $main_path;
 	my $mid = 'spam-train@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: Spammer <spammer\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -186,8 +184,6 @@ Subject: this message will be trained as spam
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	{
 		# deliver the spam message, first
 		ok(run_script(['-mda'], undef, { 0 => \$in }));
@@ -214,7 +210,7 @@ EOF
 	local $ENV{ORIGINAL_RECIPIENT} = $addr;
 	local $ENV{PATH} = $main_path;
 	my $mid = 'ham-train@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: False-positive <hammer\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -223,8 +219,6 @@ Subject: this message will be trained as spam
 Date: Thu, 01 Jan 1970 00:00:00 +0000
 
 EOF
-	my $in = $simple->as_string;
-
 	# now train it
 	# these should be overridden
 	local $ENV{GIT_AUTHOR_EMAIL} = 'trainer@example.com';
@@ -288,7 +282,7 @@ EOF
 	local $ENV{PATH} = $main_path;
 	my $list_id = 'foo.example.com';
 	my $mid = 'list-id-delivery@example.com';
-	my $simple = Email::Simple->new(<<EOF);
+	my $in = <<EOF;
 From: user <user\@example.com>
 To: You <you\@example.com>
 Cc: $addr
@@ -300,7 +294,6 @@ Date: Thu, 01 Jan 1970 00:00:00 +0000
 EOF
 	xsys(qw(git config --file), $pi_config, "$cfgpfx.listid", $list_id);
 	$? == 0 or die "failed to set listid $?";
-	my $in = $simple->as_string;
 	ok(run_script(['-mda'], undef, { 0 => \$in }),
 		'mda OK with List-Id match');
 	my $path = mid2path($mid);
@@ -308,13 +301,12 @@ EOF
 	like($$msg, qr/\Q$list_id\E/, 'delivered message w/ List-ID matches');
 
 	# try a message w/o precheck
-	$simple = Email::Simple->new(<<EOF);
+	$in = <<EOF;
 To: You <you\@example.com>
 List-Id: <$list_id>
 
 this message would not be accepted without --no-precheck
 EOF
-	$in = $simple->as_string;
 	my ($out, $err) = ('', '');
 	my $rdr = { 0 => \$in, 1 => \$out, 2 => \$err };
 	ok(run_script(['-mda', '--no-precheck'], undef, $rdr),

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/4] some test cleanups
@ 2020-04-21 21:16  6% Eric Wong
  2020-04-21 21:16  7% ` [PATCH 4/4] t/mda.t: avoid needless use of Email::Simple Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-04-21 21:16 UTC (permalink / raw)
  To: meta

Email::MIME and Email::Simple may not be a hard dependencies
down the line(*), so slowly start moving our tests away from them.

(*) they're slow, and Email::MIME eats ginormous amounts of RAM

There's also a lot of redundancy in our tests I intend to
address, such as not using PSGI tests for WWW components
and redundancy of v1 + v2 test paths.

Eric Wong (4):
  t/feed: remove useless $ENV{GIT_DIR} assignment
  t/*.t: use Email::MIME->create over PublicInbox::MIME->create
  t/*.t: reduce dependency on Email::MIME APIs
  t/mda.t: avoid needless use of Email::Simple

 t/altid.t              |  19 ++--
 t/altid_v2.t           |  19 ++--
 t/cgi.t                |   8 +-
 t/content_id.t         |  24 +++--
 t/convert-compact.t    |  20 ++--
 t/feed.t               |   8 +-
 t/filter_rubylang.t    |   8 +-
 t/filter_subjecttag.t  |   4 +-
 t/filter_vger.t        |   6 +-
 t/html_index.t         |   4 +-
 t/httpd.t              |   4 +-
 t/import.t             |  21 ++---
 t/indexlevels-mirror.t |  17 ++--
 t/mda.t                |  18 +---
 t/mid.t                |   5 +-
 t/msgtime.t            |  50 +++++-----
 t/nntp.t               |   4 +-
 t/nntpd.t              |   4 +-
 t/nulsubject.t         |  18 ++--
 t/plack.t              |   4 +-
 t/psgi_attach.t        |   2 +-
 t/psgi_mount.t         |   4 +-
 t/psgi_multipart_not.t |   2 +-
 t/psgi_scan_all.t      |   2 +-
 t/psgi_search.t        |   2 +-
 t/psgi_text.t          |   2 +-
 t/psgi_v2.t            |   8 +-
 t/reply.t              |   4 +-
 t/search-thr-index.t   |   6 +-
 t/search.t             | 205 ++++++++++++++++++++---------------------
 t/time.t               |  23 +++--
 t/v1-add-remove-add.t  |  21 ++---
 t/v1reindex.t          |  19 ++--
 t/v2-add-remove-add.t  |  19 ++--
 t/v2mda.t              |  22 ++---
 t/v2reindex.t          |  16 ++--
 t/v2writable.t         |  18 ++--
 t/watch_maildir.t      |   2 +-
 t/xcpdb-reshard.t      |  15 ++-
 39 files changed, 307 insertions(+), 350 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-04-21 21:16  6% [PATCH 0/4] some test cleanups Eric Wong
2020-04-21 21:16  7% ` [PATCH 4/4] t/mda.t: avoid needless use of Email::Simple 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).