App-bk
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/bk.pm view on Meta::CPAN
=head2 backup_files
Main function to process ARGV and backup files as necessary
=cut
sub backup_files {
# make sure we don't clobber any callers variables
local @ARGV = @ARGV;
GetOptions( \%options, keys(%opts) ) || pod2usage( -verbose => 1 );
die("Version: $VERSION\n") if ( $options{version} );
pod2usage( -verbose => 1 ) if ( $options{'?'} || $options{help} );
pod2usage( -verbose => 2 ) if ( $options{HELP} || $options{man} );
$options{debug} ||= 0;
$options{debug} = 8 if ( $options{debug} > 8 );
if ( !@ARGV ) {
t/find_sum_binary.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use Test::Trap;
use File::Which qw(which);
my $result;
use_ok("App::bk");
local @ARGV = ();
$result = trap { App::bk::find_sum_binary(); };
is( $trap->stderr, '', 'no stderr output' );
is( $trap->stdout, '', 'no stdout output' );
is( $trap->exit, undef, 'correct exit' );
is( $trap->leaveby, 'return', 'returned correctly' );
is( $trap->die, undef, 'no death output' );
is( $result, which('md5sum') || which('sum'),
'got correct path: ' . $result );
t/multi_files.t view on Meta::CPAN
use FindBin qw($Bin);
my $result;
use_ok("App::bk");
chdir($Bin) || BAIL_OUT( 'Failed to cd into '. $Bin );
unlink <file*.txt.*>;
local @ARGV = ('no_such_file.txt');
$result = trap { App::bk::backup_files(); };
like(
$trap->stderr,
qr/WARNING: File no_such_file.txt not found/,
'correct stderr output'
);
is( $trap->stdout, '', 'no stdout output' );
is( $trap->exit, undef, 'correct exit' );
is( $trap->leaveby, 'return', 'returned correctly' );
is( $trap->die, undef, 'no death output' );
is( $result, 1, 'got correct return value' );
local @ARGV = ( 'file1.txt', 'file2.txt' );
$result = trap { App::bk::backup_files(); };
is( $trap->stderr, '', 'no stderr output' );
like(
$trap->stdout,
qr!Backed up file1.txt to ./file1.txt.([\w-]+\.)?\d{8}
Backed up file2.txt to ./file2.txt.([\w-]+\.)?\d{8}
$!,
'got correct backup filename'
t/no_files.t view on Meta::CPAN
#!perl
use strict;
use warnings;
use Test::More tests => 2;
use Test::Trap;
use_ok("App::bk");
local @ARGV = ();
my $r = trap { App::bk::backup_files(); };
like( $trap->stderr, qr/No filenames provided./, 'No files error ok' );
t/one_file.t view on Meta::CPAN
use FindBin qw($Bin);
my $result;
use_ok("App::bk");
chdir($Bin) || BAIL_OUT( 'Failed to cd into '. $Bin );
unlink <file1.txt.*>;
local @ARGV = ('no_such_file.txt');
$result = trap { App::bk::backup_files(); };
like(
$trap->stderr,
qr/WARNING: File no_such_file.txt not found/,
'correct stderr output'
);
is( $trap->stdout, '', 'no stdout output' );
is( $trap->exit, undef, 'correct exit' );
is( $trap->leaveby, 'return', 'returned correctly' );
is( $trap->die, undef, 'no death output' );
is( $result, 1, 'got correct return value' );
local @ARGV = ('file1.txt');
$result = trap { App::bk::backup_files(); };
is( $trap->stderr, '', 'no stderr output' );
like(
$trap->stdout,
qr!Backed up file1.txt to ./file1.txt.([\w-]+\.)?\d{8}\s$!,
'got correct backup filename'
);
is( $trap->exit, undef, 'correct exit' );
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.108 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )