Eric Wong <e...@80x24.org> wrote:
> +++ b/t/lei-import.t
> @@ -126,6 +126,18 @@ $res = json_utf8->decode($lei_out);
>  is_deeply($res->[0]->{kw}, [qw(answered seen)], 'keyword added');
>  is_deeply($res->[0]->{L}, [qw(boombox inbox)], 'labels preserved');
>  
> +# +kw:seen is not a location
> +ok(!lei(qw(import -F eml +kw:seen)), 'import fails w/ only kw arg');
> +like($lei_err, qr/\bLOCATION\.\.\. or --stdin must be set/, 'error message');

That's unreliable because stdin could be pointed to a
regular file or pipe while running tests, so we shouldn't
inherit.

So I think I'll squash the following in and use autodie a bit
more while I'm at it, too.
---
 t/lei-import.t | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/t/lei-import.t b/t/lei-import.t
index 30d8b531..8b09d3aa 100644
--- a/t/lei-import.t
+++ b/t/lei-import.t
@@ -1,14 +1,15 @@
 #!perl -w
 # Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use strict; use v5.10.1; use PublicInbox::TestCommon;
+use v5.12; use PublicInbox::TestCommon;
+use autodie qw(open close);
 test_lei(sub {
 ok(!lei(qw(import -F bogus), 't/plack-qp.eml'), 'fails with bogus format');
 like($lei_err, qr/\bis `eml', not --in-format/, 'gave error message');
 
 lei_ok(qw(q s:boolean), \'search miss before import');
 unlike($lei_out, qr/boolean/i, 'no results, yet');
-open my $fh, '<', 't/data/0001.patch' or BAIL_OUT $!;
+open my $fh, '<', 't/data/0001.patch';
 lei_ok([qw(import -F eml -)], undef, { %$lei_opt, 0 => $fh },
        \'import single file from stdin') or diag $lei_err;
 close $fh;
@@ -18,7 +19,7 @@ lei_ok(qw(q s:boolean -f mboxrd), \'blob accessible after 
import');
        my $expect = [ eml_load('t/data/0001.patch') ];
        require PublicInbox::MboxReader;
        my @cmp;
-       open my $fh, '<', \$lei_out or BAIL_OUT "open :scalar: $!";
+       open my $fh, '<', \$lei_out;
        PublicInbox::MboxReader->mboxrd($fh, sub {
                my ($eml) = @_;
                $eml->header_set('Status');
@@ -127,8 +128,10 @@ is_deeply($res->[0]->{kw}, [qw(answered seen)], 'keyword 
added');
 is_deeply($res->[0]->{L}, [qw(boombox inbox)], 'labels preserved');
 
 # +kw:seen is not a location
-ok(!lei(qw(import -F eml +kw:seen)), 'import fails w/ only kw arg');
-like($lei_err, qr/\bLOCATION\.\.\. or --stdin must be set/, 'error message');
+open my $null, '<', '/dev/null';
+ok(!lei([qw(import -F eml +kw:seen)], undef, { %$lei_opt, 0 => $null }),
+       'import fails w/ only kw arg');
+like($lei_err, qr/\bLOCATION\.\.\. or --stdin must be set/s, 'error message');
 
 lei_ok([qw(import -F eml +kw:flagged)], # no lone dash (`-')
        undef, { %$lei_opt, 0 => \$eml_str },

Reply via email to