From e39585ee2bdcbeaab7b6bd33b3568021042d0879 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 25 Apr 2020 05:52:22 +0000 Subject: tests: remove Email::MIME->create use entirely Replace them with .eml files generated with the help of Email::MIME, but without some extraneous and unnecessary headers, and strip mime_load down to just loading files. This will give us more freedom to experiment with other mail libraries which may be more correct, better maintained, use less memory and/or be faster than Email::MIME. --- lib/PublicInbox/TestCommon.pm | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index ac14d27b..27390ab2 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -11,27 +11,10 @@ use IO::Socket::INET; our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods run_script start_script key2sub xsys xqx mime_load); -sub mime_load ($;&) { +sub mime_load ($) { my ($path, $cb) = @_; - if (open(my $fh, '<', $path)) { - PublicInbox::MIME->new(\(do { local $/; <$fh> })); - } elsif ($cb) { - require File::Temp; - - my $mime = $cb->(); - my ($dir) = ($path =~ m!(.+)/(?:[^/]+)\z!); - -d $dir or die "BUG: dir=$dir is not the dir of $path"; - my $fh = File::Temp->new(DIR => $dir); - $fh->autoflush(1); - print $fh $mime->as_string or die "print: $!"; - my $fn = $fh->filename; - rename($fn, $path) or die "link $fn => $path: $!"; - $fh->unlink_on_destroy(0); - pop @_; # retry via tail recursion - goto &mime_load; - } else { - die "open $path: $!"; - } + open(my $fh, '<', $path) or die "open $path: $!"; + PublicInbox::MIME->new(\(do { local $/; <$fh> })); } sub tmpdir (;$) { -- cgit v1.2.3-24-ge0c7