App-MechaCPAN

 view release on metacpan or  search on metacpan

lib/App/MechaCPAN.pm  view on Meta::CPAN


our @args = (
  'diag-run!',
  'verbose|v!',
  'quiet|q!',
  'no-log!',
  'directory|d=s',
  'build-reusable-perl!',
);

# Timeout when there's no output in seconds
our $TIMEOUT = $ENV{MECHACPAN_TIMEOUT} // 60;
our $VERBOSE;    # Print output from sub commands to STDERR
our $QUIET;      # Do not print any progress to STDERR
our $LOGFH;      # File handle to send the logs to
our $LOG_ON = 1; # Default if to log or not
our $PROJ_DIR;   # The directory given with -d or pwd if not provided

sub main
{
  my @argv = @_;

t/03_run.t  view on Meta::CPAN

is( eval { run $^X, '-e', 'exit 0'; 1 }, 1, 'Can successfully run' );

# Failed run
is( eval { run $^X, '-e', 'exit 1'; 1 }, undef, 'Can successfully fail' );

# Output
my @lines = qw/line1 line2 line3/;
my @output = eval { run $^X, '-e', "print join(qq[\\n], qw[@lines]);" };
is_deeply( \@output, \@lines, 'Result from run is STDOUT' );

# Timeout run
is( eval { run $^X, '-e', 'sleep 10'; 1 }, undef, 'Will timeout without output' );
is( eval { run $^X, '-e', 'sleep 2; print STDERR "\n"; sleep 2;'; 1 }, 1, 'Output resets timeout' );

# Test for output gathering and logging
{
  my $output           = '';
  my $capture          = '';
  my $stderr           = '';
  my $capture_expected = join( qq[\\n], @lines );

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

( run in 0.534 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )