diff options
author | Eric Wong <e@yhbt.net> | 2020-04-25 05:52:22 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-04-26 07:03:14 +0000 |
commit | e39585ee2bdcbeaab7b6bd33b3568021042d0879 (patch) | |
tree | b130b0ce73d8ce9624424c4de6999481ab96439d /lib | |
parent | 5d8dbb4aca5afcc6b98a4d951f03003fb7eaf356 (diff) | |
download | public-inbox-e39585ee2bdcbeaab7b6bd33b3568021042d0879.tar.gz |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/TestCommon.pm | 23 |
1 files changed, 3 insertions, 20 deletions
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 (;$) { |