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 AC2381F751 for ; Tue, 21 Apr 2020 21:16:15 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] t/mda.t: avoid needless use of Email::Simple Date: Tue, 21 Apr 2020 21:16:14 +0000 Message-Id: <20200421211614.5076-5-e@yhbt.net> In-Reply-To: <20200421211614.5076-1-e@yhbt.net> References: <20200421211614.5076-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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(< To: You 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(< To: You 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(< To: You 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(< To: You 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(< 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),