App-CPAN-Mini-Visit

 view release on metacpan or  search on metacpan

t/01-App-CPAN-Mini-Visit.t  view on Meta::CPAN

    my $label = "path";
    for my $opt (qw/ --append -a /) {
        try eval {
            capture sub {
                App::CPAN::Mini::Visit->run( "$opt=path", "--", $^X, '-e',
                    'print shift(@ARGV) . "\n"' );
              } => \$stdout,
              \$stderr;
        };
        catch my $err;
        my @found = split /\n/, $stdout;
        my @expect = @files;
        ok( length $stdout, "[$label] ($opt) got stdout" ) or diag $err;
        is_deeply( \@found, \@expect, "[$label] ($opt) listing correct" )
          or diag "STDOUT:\n$stdout\nSTDERR:\n$stderr\n";
    }
}

#--------------------------------------------------------------------------#
# --append dist
#--------------------------------------------------------------------------#

{
    my $label = "dist";
    for my $opt (qw/ --append -a /) {
        try eval {
            capture sub {
                App::CPAN::Mini::Visit->run( "$opt=dist", "--", $^X, '-e',
                    'print shift(@ARGV) . "\n"' );
              } => \$stdout,
              \$stderr;
        };
        catch my $err;
        my @found = split /\n/, $stdout;
        my $prefix = dir( $minicpan, qw/ authors id / )->absolute;
        my @expect = map {
            ( my $file = $_ ) =~ s{$prefix[/\\].[/\\]..[/\\]}{};
            $file;
        } @files;
        ok( length $stdout, "[$label] ($opt) got stdout" ) or diag $err;
        is_deeply( \@found, \@expect, "[$label] ($opt) listing correct" )
          or diag "STDOUT:\n$stdout\nSTDERR:\n$stderr\n";
    }
}

#--------------------------------------------------------------------------#
# --output file
#--------------------------------------------------------------------------#

{
    my $label    = "output";
    my $tempfile = tmpnam();
    try eval {
        capture sub {
            App::CPAN::Mini::Visit->run("--output=$tempfile");
          } => \$stdout,
          \$stderr;
    };
    catch my $err;
    ok( -f $tempfile, "[$label] output file created" );
    my @found = map { chomp; $_ } do { local @ARGV = ($tempfile); <> };
    is( $stdout, '', "[$label] saw no output on terminal" );
    is_deeply( \@found, \@files, "[$label] listing correct" );
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.652 second using v1.00-cache-2.02-grep-82fe00e-cpan-48ebf85a1963 )