From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 2ED621F55F for ; Tue, 3 Oct 2023 16:19:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696349945; bh=Upi+AjaEV4co+6jKsyppwux8dTnVOLS9S6lDTS3FniQ=; h=From:To:Subject:Date:From; b=K8kLD7fwzKX/Bp7mVbeJEJS14c5/uY3c9q6lTmfZOAKQGuPMnSZBJN2dFWCz6Quov mPoVwGrc1SHWOf2thWyz/PWSjqSgS7FylQYXlmX/EHVZC3bMVKAMOSKrkkxYPP5yxs 0l+y4hWZ155Hjs0gzOuGlrlLjUwzjWBtCE0+r/6o= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] t/lei-q-save: quiet `no email in From: ...' warnings Date: Tue, 3 Oct 2023 16:18:17 +0000 Message-ID: <20231003161817.2011-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: PublicInbox::Import will warn if it can't extract a valid address from an email. We need to ensure our tests capture them to $lei_err instead of spewing them to the terminal. While we're at it, use autodie and xsys_e to simplify some. --- t/lei-q-save.t | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/t/lei-q-save.t b/t/lei-q-save.t index 53311696..a9f9d4d6 100644 --- a/t/lei-q-save.t +++ b/t/lei-q-save.t @@ -1,7 +1,8 @@ #!perl -w # Copyright (C) all contributors # License: AGPL-3.0+ -use strict; use v5.10.1; use PublicInbox::TestCommon; +use v5.12; use PublicInbox::TestCommon; +use autodie qw(close open unlink); use PublicInbox::Smsg; use List::Util qw(sum); use File::Path qw(remove_tree); @@ -89,7 +90,7 @@ test_lei(sub { like($lei_out, qr!^\Q$home/mbcl2\E$!sm, 'complete got mbcl2 output'); like($lei_out, qr!^\Q$home/md\E$!sm, 'complete got maildir output'); - unlink("$home/mbcl2") or xbail "unlink $!"; + unlink("$home/mbcl2"); lei_ok qw(_complete lei up); like($lei_out, qr!^\Q$home/mbcl2\E$!sm, 'mbcl2 output shown despite unlink'); @@ -97,24 +98,24 @@ test_lei(sub { ok(-f "$home/mbcl2" && -s _ == 0, 'up recreates on missing output'); # no --augment - open my $mb, '>', "$home/mbrd" or xbail "open $!"; + open my $mb, '>', "$home/mbrd"; print $mb $pre_existing; - close $mb or xbail "close: $!"; + close $mb; lei_ok(qw(q -o mboxrd:mbrd m:qp@example.com -C), $home); - open $mb, '<', "$home/mbrd" or xbail "open $!"; + open $mb, '<', "$home/mbrd"; is_deeply([grep(/pre-existing/, <$mb>)], [], 'pre-existing messsage gone w/o augment'); - close $mb; + undef $mb; lei_ok(qw(q m:import-before@example.com)); is(json_utf8->decode($lei_out)->[0]->{'s'}, 'pre-existing', '--save imported before clobbering'); # --augment - open $mb, '>', "$home/mbrd-aug" or xbail "open $!"; + open $mb, '>', "$home/mbrd-aug"; print $mb $pre_existing; - close $mb or xbail "close: $!"; + close $mb; lei_ok(qw(q -a -o mboxrd:mbrd-aug m:qp@example.com -C), $home); - open $mb, '<', "$home/mbrd-aug" or xbail "open $!"; + open $mb, '<', "$home/mbrd-aug"; $mb = do { local $/; <$mb> }; like($mb, qr/pre-existing/, 'pre-existing message preserved w/ -a'); like($mb, qr//, 'new result written w/ -a'); @@ -228,16 +229,14 @@ test_lei(sub { my @lss = glob("$home/" . '.local/share/lei/saved-searches/*/lei.saved-search'); my $out = xqx([qw(git config -f), $lss[0], 'lei.q.output']); - xsys($^X, qw(-w -i -p -e), "s/\\[/\\0/", $lss[0]) - and xbail "-ipe $lss[0]: $?"; + xsys_e($^X, qw(-w -i -p -e), "s/\\[/\\0/", $lss[0]); lei_ok qw(ls-search); like($lei_err, qr/bad config line.*?\Q$lss[0]\E/, 'git config parse error shown w/ lei ls-search'); lei_ok qw(up --all), \'up works with bad config'; like($lei_err, qr/bad config line.*?\Q$lss[0]\E/, 'git config parse error shown w/ lei up'); - xsys($^X, qw(-w -i -p -e), "s/\\0/\\[/", $lss[0]) - and xbail "-ipe $lss[0]: $?"; + xsys_e($^X, qw(-w -i -p -e), "s/\\0/\\[/", $lss[0]); lei_ok qw(ls-search); is($lei_err, '', 'no errors w/ fixed config'); @@ -249,17 +248,17 @@ test_lei(sub { my $d = "$home/d"; lei_ok [qw(import -q -F eml)], undef, - {0 => \"Subject: do not call\n\n"}; + {%$lei_opt, 0 => \"Subject: do not call\n\n"}; lei_ok qw(q -o), $d, 's:do not call'; my @orig = glob("$d/*/*"); is(scalar(@orig), 1, 'got one message via argv'); lei_ok [qw(import -q -Feml)], undef, - {0 => \"Subject: do not ever call\n\n"}; + {%$lei_opt, 0 => \"Subject: do not ever call\n\n"}; lei_ok 'up', $d; is_deeply([glob("$d/*/*")], \@orig, 'nothing written'); lei_ok [qw(import -q -Feml)], undef, - {0 => \"Subject: do not call, ever\n\n"}; + {%$lei_opt, 0 => \"Subject: do not call, ever\n\n"}; lei_ok 'up', $d; @after = glob("$d/*/*"); is(scalar(@after), 2, '2 total, messages, now'); @@ -270,14 +269,15 @@ test_lei(sub { 'up retrieved correct message'); $d = "$home/d-stdin"; - lei_ok [ qw(q -q -o), $d ], undef, { 0 => \'s:"do not ever call"' }; + lei_ok [ qw(q -q -o), $d ], undef, + { %$lei_opt, 0 => \'s:"do not ever call"' }; @orig = glob("$d/*/*"); is(scalar(@orig), 1, 'got one message via stdin'); lei_ok [qw(import -q -Feml)], undef, - {0 => \"Subject: do not fall or ever call\n\n"}; + {%$lei_opt, 0 => \"Subject: do not fall or ever call\n\n"}; lei_ok [qw(import -q -Feml)], undef, - {0 => \"Subject: do not ever call, again\n\n"}; + {%$lei_opt, 0 => \"Subject: do not ever call, again\n\n"}; lei_ok 'up', $d; @new = glob("$d/new/*"); is(scalar(@new), 1, "new message written to `new'") or do { @@ -292,7 +292,7 @@ test_lei(sub { lei_ok(qw(q --no-external m:import-before@example.com -t -o), $d); @orig = glob("$d/{new,cur}/*"); is(scalar(@orig), 1, 'one result so far'); - lei_ok [ qw(import -Feml) ], undef, { 0 => \<<'EOM' }; + lei_ok [ qw(import -Feml) ], undef, { %$lei_opt, 0 => \<<'EOM' }; Date: Sun, 02 Oct 2023 00:00:00 +0000 From: In-Reply-To: