App-Du-Analyze

 view release on metacpan or  search on metacpan

t/app.t  view on Meta::CPAN

#!/usr/bin/perl

use strict;
use warnings;

use autodie;

use File::Spec;

use Test::More tests => 12;

use Test::Differences qw( eq_or_diff );

use Test::Trap
    qw( trap $trap :flow:stderr(systemsafe):stdout(systemsafe):warn );

use App::Du::Analyze;
my $input_filename = File::Spec->catfile( File::Spec->curdir, 't', 'data',
    'fc-solve-git-du-output.txt' );

# TEST:$test_filter_on_fc_solve__proto=1;
sub test_filter_on_fc_solve__proto
{
    my ( $args, $expected_output, $blurb ) = @_;

    local $Test::Builder::Level = $Test::Builder::Level + 1;

    trap
    {
        App::Du::Analyze->new( { argv => [@$args] } )->run();
    };

    my $got_output = $trap->stdout;

    return eq_or_diff( $got_output, $expected_output, $blurb, );
}

# TEST:$test_filter_on_fc_solve=0;
sub test_filter_on_fc_solve
{
    local $Test::Builder::Level = $Test::Builder::Level + 1;
    my ( $args, $expected_output, $blurb ) = @_;

    {
        local $ENV{ANALYZE_DU_INPUT_FN} = $input_filename;

        # TEST:$test_filter_on_fc_solve+=$test_filter_on_fc_solve__proto;
        test_filter_on_fc_solve__proto( $args, $expected_output,
            "$blurb - ENV", );
    }

    {
        # TEST:$test_filter_on_fc_solve+=$test_filter_on_fc_solve__proto;
        test_filter_on_fc_solve__proto( [ @$args, $input_filename ],
            $expected_output, "$blurb - arg", );
    }
}

{

    # TEST*$test_filter_on_fc_solve
    test_filter_on_fc_solve(
        [ '-p', '', '-d', 0, ],
        <<"EOF", "depth 0 and no prefix",
119224\t
EOF
    );

    # TEST*$test_filter_on_fc_solve
    test_filter_on_fc_solve(
        [ '-p', 'fc-solve', '-d', 0, ],
        <<"EOF", "depth 0 and specified prefix",



( run in 0.849 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )