App-Dest

 view release on metacpan or  search on metacpan

t/00-compile.t  view on Meta::CPAN

use File::Spec;
use IPC::Open3;
use IO::Handle;

open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";

my @warnings;
for my $lib (@module_files)
{
    # see L<perlfaq8/How can I capture STDERR from an external command?>
    my $stderr = IO::Handle->new;

    diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
            $^X, @switches, '-e', "require q[$lib]"))
        if $ENV{PERL_COMPILE_TEST_DEBUG};

    my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]");
    binmode $stderr, ':crlf' if $^O eq 'MSWin32';
    my @_warnings = <$stderr>;
    waitpid($pid, 0);
    is($?, 0, "$lib loaded ok");

    shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
        and not eval { +require blib; blib->VERSION('1.01') };

    if (@_warnings)
    {
        warn @_warnings;
        push @warnings, @_warnings;

t/00-compile.t  view on Meta::CPAN

{ SKIP: {
    open my $fh, '<', $file or warn("Unable to open $file: $!"), next;
    my $line = <$fh>;

    close $fh and skip("$file isn't perl", 1) unless $line =~ /^#!\s*(?:\S*perl\S*)((?:\s+-\w*)*)(?:\s*#.*)?$/;
    @switches = (@switches, split(' ', $1)) if $1;

    close $fh and skip("$file uses -T; not testable with PERL5LIB", 1)
        if grep { $_ eq '-T' } @switches and $ENV{PERL5LIB};

    my $stderr = IO::Handle->new;

    diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} }
            $^X, @switches, '-c', $file))
        if $ENV{PERL_COMPILE_TEST_DEBUG};

    my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-c', $file);
    binmode $stderr, ':crlf' if $^O eq 'MSWin32';
    my @_warnings = <$stderr>;
    waitpid($pid, 0);
    is($?, 0, "$file compiled ok");

    shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/
        and not eval { +require blib; blib->VERSION('1.01') };

    # in older perls, -c output is simply the file portion of the path being tested
    if (@_warnings = grep { !/\bsyntax OK$/ }
        grep { chomp; $_ ne (File::Spec->splitpath($file))[2] } @_warnings)
    {

t/deploy.t  view on Meta::CPAN

set_state;

my $log;
sub read_log {
    open( my $log, '<', 'log' );
    return join( '', <$log> );
}

dircopy( 'source', 'actions' );

stderr_is(
    sub { App::Dest->init },
    "Created new watch list based on dest.watch file:\n" .
        "  actions\n",
    'init succeeds',
);

move(    'actions/005', '.dest/actions/005' );
dircopy( 'actions/001', '.dest/actions/001' );
dircopy( 'actions/002', '.dest/actions/002' );

t/deploy.t  view on Meta::CPAN

        "ok - deploy: actions/004\n" .
        "ok - verify: actions/004\n",
    'deploy',
);
$log .= "actions/004/deploy\n" .
    "004 deploy\n" .
    "actions/004/verify\n" .
    "004 verify\n";
is( &read_log, $log, 'log correct after deploy' );

stderr_is( sub {
    try {
        App::Dest->deploy('actions/004');
    }
    catch ($e) {
        warn $e;
    }
}, "Action already deployed\n", 'deploy again fails' );

stdout_is(
    sub { App::Dest->redeploy('actions/004') },

t/init.t  view on Meta::CPAN


sub set_state {
    chdir( dirname($0) . '/init' );
    rmtree('.dest');
    open( my $out, '>', 'dest.watch' );
    print $out "actions\n";
    close $out;
}
set_state;

stderr_is(
    sub { App::Dest->init },
    "Created new watch list based on dest.watch file:\n  actions\n",
    'init succeeds',
);

ok( -d '.dest', '.dest created' );
ok( -f '.dest/watch', '.dest/watch created' );

stderr_is( sub {
    try {
        App::Dest->init;
    }
    catch ($e) {
        warn $e;
    }
}, "Project already initialized\n", 'init again fails' );

stderr_is( sub {
    try {
        App::Dest->add('actions');
    }
    catch ($e) {
        warn $e;
    }
}, "Directory actions already added\n", 'no re-add actions' );

ok( lives { App::Dest->rm('actions') }, 'rm actions' ) or note $@;
stdout_is( sub { App::Dest->watches }, '', 'watches (no results)' );
ok( lives { App::Dest->add('actions') }, 'add actions' ) or note $@;

stderr_is( sub {
    try {
        App::Dest->add('not_exists');
    }
    catch ($e) {
        warn $e;
    }
}, "Directory specified does not exist\n", 'no add not exists' );

stdout_is( sub { App::Dest->watches }, "actions\n", 'watches (results)' );
ok( lives { App::Dest->putwatch('dest.watch2') }, 'putwatch' ) or note $@;

t/make.t  view on Meta::CPAN

use Test::Output;

use App::Dest;

sub set_state {
    chdir( dirname($0) . '/make' );
    rmtree($_) for ( '.dest', 'actions/003' );
}
set_state;

stderr_is(
    sub { App::Dest->init },
    "Created new watch list based on dest.watch file:\n  actions\n",
    'init succeeds',
);

stdout_is(
    sub { App::Dest->list },
    "actions actions:\n  actions/001\n  actions/002\n",
    'list',
);

t/revert.t  view on Meta::CPAN

set_state;

my $log;
sub read_log {
    open( my $log, '<', 'log' );
    return join( '', <$log> );
}

dircopy( 'source', 'actions' );

stderr_is(
    sub { App::Dest->init },
    "Created new watch list based on dest.watch file:\n" .
        "  actions\n",
    'init succeeds',
);

stdout_is(
    sub { App::Dest->update('-d') },
    "actions/dest.wrap actions/005/deploy\n" .
        "actions/dest.wrap actions/005/verify\n" .

t/revert.t  view on Meta::CPAN

        "ok - verify: actions/001\n" .
        "begin - deploy: actions/002\n" .
        "ok - deploy: actions/002\n" .
        "ok - verify: actions/002\n" .
        "begin - deploy: actions/003\n" .
        "ok - deploy: actions/003\n" .
        "ok - verify: actions/003\n",
    'update',
);

my ( $stdout, $stderr, $exit );
ok(
    lives { ( $stdout, $stderr, $exit ) = capture { App::Dest->revert( 'actions/005', '-d' ) } },
    'dry run revert specific action',
) or note $@;

like(
    $stdout,
    qr|(?:actions/dest.wrap .dest/actions/00[1-5]/revert\n){5}|,
    'good revert output construction',
);

my $position;



( run in 0.248 second using v1.01-cache-2.11-cpan-26ccb49234f )