CPAN-Reporter-Smoker
view release on metacpan or search on metacpan
lib/CPAN/Reporter/Smoker.pm view on Meta::CPAN
my @list = map { chomp; $_ } grep { /\S/ } <$list_fh>;
$dists = \@list;
}
}
else {
# Or get list from CPAN
my $package = _get_module_index( 'modules/02packages.details.txt.gz' );
my $find_ls = _get_module_index( 'indices/find-ls.gz' );
CPAN::Index->reload;
$CPAN::Frontend->mywarn( "Smoker: scanning and sorting index\n");
$dists = _parse_module_index( $package, $find_ls, $args{skip_dev_versions}, $args{_start_from_timestamp} );
$CPAN::Frontend->mywarn( "Smoker: found " . scalar @$dists . " distributions on CPAN\n");
}
# Maybe reverse the list
if ( $args{'reverse'} ) {
$dists = [ reverse @$dists ];
}
# Maybe shuffle the list
if ( $args{'random'} ) {
$dists = [ shuffle @$dists ];
}
# Check if we need to manually reset test history during each dist loop
my $reset_string = q{};
if ( $CPAN::Config->{build_dir_reuse}
&& $CPAN::META->can('reset_tested') )
{
$reset_string = 'CPAN::Index->reload; $CPAN::META->reset_tested; '
}
# Force trust_test_report_history if requested
my $trust_string = q{};
if ( $args{force_trust} ) {
$trust_string = '$CPAN::Config->{trust_test_report_history} = 1; '
}
# Clean cache on start and count dists tested to trigger cache cleanup
_clean_cache();
my $dists_tested = 0;
# Start smoking
DIST:
for my $d ( 0 .. $#{$dists} ) {
my $dist = CPAN::Shell->expandany($dists->[$d]);
my $base = $dist->base_id;
my $count = sprintf('%d/%d', $d+1, scalar @$dists);
if ( $seen{$base}++ ) {
$CPAN::Frontend->mywarn(
"Smoker: already tested $base [$count]\n");
next DIST;
}
elsif ( $args{filter} and $args{filter}->($dist) ) {
$CPAN::Frontend->mywarn(
"Smoker: dist skipped $base [$count]\n");
next DIST;
}
elsif ( CPAN::Distribution->new(%{$dist})->prefs->{disabled} ) {
$CPAN::Frontend->mywarn(
"Smoker: dist disabled $base [$count]\n");
next DIST;
}
else {
# record distribution being smoked
my $time = scalar localtime();
my $msg = "$base [$count] at $time";
if ( $args{set_term_title} ) {
Term::Title::set_titlebar( "Smoking $msg" );
}
$CPAN::Frontend->mywarn( "\nSmoker: testing $msg\n\n" );
local $ENV{PERL_CR_SMOKER_CURRENT} = $base;
open my $status_fh, ">", $args{status_file};
if ( $status_fh ) {
flock $status_fh, LOCK_EX;
print {$status_fh} $msg;
flock $status_fh, LOCK_UN;
close $status_fh;
}
# invoke CPAN.pm to test distribution
system($perl, "-MCPAN", "-e",
"\$CPAN::Config->{test_report} = 1; " . $trust_string
. $reset_string . ($args{'install'} ? 'install' : 'test')
. "( '$dists->[$d]' )"
);
my $interrupted = 0;
if ( $? & 127 ) {
$interrupted = 1;
_prompt_quit( $? & 127 ) ;
}
if ($args{_hook_after_test}) {
$args{_hook_after_test}->($dist, $interrupted);
}
# cleanup and record keeping
unlink $args{status_file} if -f $args{status_file};
$dists_tested++;
}
if ( $dists_tested >= $args{clean_cache_after} ) {
_clean_cache();
$dists_tested = 0;
}
if (time - $history_loaded_at > $args{reload_history_period}) { #_reload_history
%seen = map { $_->{dist} => 1 } CPAN::Reporter::History::have_tested();
$history_loaded_at = time;
$CPAN::Frontend->mywarn( "List of distros smoked updated\n");
}
next SCAN_LOOP if time - $loop_start_time > $args{restart_delay};
}
last SCAN_LOOP if $ENV{PERL_CR_SMOKER_RUNONCE};
last SCAN_LOOP if $args{list};
# if here, we are out of distributions to test, so sleep
my $delay = int( $args{restart_delay} - ( time - $loop_start_time ));
if ( $delay > 0 ) {
$CPAN::Frontend->mywarn(
"\nSmoker: Finished all available dists. Sleeping for $delay seconds.\n\n"
);
lib/CPAN/Reporter/Smoker.pm view on Meta::CPAN
}
1;
# ABSTRACT: Turnkey CPAN Testers smoking
__END__
=pod
=encoding UTF-8
=head1 NAME
CPAN::Reporter::Smoker - Turnkey CPAN Testers smoking
=head1 VERSION
version 0.30
=head1 SYNOPSIS
$ perl -MCPAN::Reporter::Smoker -e start
=head1 DESCRIPTION
Rudimentary smoke tester for CPAN Testers, built upon L<CPAN::Reporter>. Use
at your own risk. It requires a recent version of CPAN::Reporter to run.
Currently, CPAN::Reporter::Smoker requires zero independent configuration;
instead it uses configuration settings from CPAN.pm and CPAN::Reporter.
Once started, it retrieves a list of distributions from the configured CPAN
mirror and begins testing them in reverse order of upload. It will skip any
distribution which has already had a report sent by CPAN::Reporter.
Features (or bugs, depending on your point of view):
=over
=item *
No configuration needed
=item *
Tests each distribution as a separate CPAN process -- each distribution
has prerequisites like build_requires satisfied from scratch
=item *
Automatically checks for new distributions every twelve hours or as
otherwise specified
=item *
Continues until interrupted with CTRL-C
=item *
Checks CPAN.pm "distroprefs" to see if distributions should be skipped
(before handing off to CPAN)
=back
Current limitations:
=over
=item *
Does not attempt to retest distributions that had reports discarded because
of prerequisites that could not be satisfied
=item *
Does not test trial version if there is no non-trial version
=back
=head2 WARNING -- smoke testing is risky
Smoke testing will download and run programs that other people have uploaded to
CPAN. These programs could do B<anything> to your system, including deleting
everything on it. Do not run CPAN::Reporter::Smoker unless you are prepared to
take these risks.
=head1 USAGE
=head2 C<<< start() >>>
Starts smoke testing using defaults already in CPAN::Config and
CPAN::Reporter's .cpanreporter directory. Runs until all distributions are
tested or the process is halted with CTRL-C or otherwise killed.
C<<< start() >>> supports several optional arguments:
=over
=item *
C<<< clean_cache_after >>> -- number of distributions that will be tested
before checking to see if the CPAN build cache needs to be cleaned up
(not including any prerequisites tested). Must be a positive integer.
Defaults to 100
=item *
C<<< list >>> -- if provided, this list of distributions will be tested instead
of all of CPAN. May be a reference to an array of distribution names or may
be a filename containing one distribution name per line. Distribution names
must be of the form 'AUTHORE<sol>Dist-Name-0.00.tar.gz'
=item *
C<<< restart_delay >>> -- number of seconds that must elapse before restarting
smoke testing. This will reload indices to search for new distributions
and restart testing from the most recent distribution. Must be a positive
integer; Defaults to 43200 seconds (12 hours)
=item *
lib/CPAN/Reporter/Smoker.pm view on Meta::CPAN
C<<< random >>> -- toggle whether to randomize distribution test order. When set to 1,
the list of releases is shuffled. Valid values are 0 or 1. Defaults to 0
=item *
C<<< force_trust >>> -- toggle whether to override CPAN's
C<<< trust_test_report_history >>> option. When set to 1, C<<< trust_test_report_history >>>
is set to 1. When set to 0, C<<< trust_test_report_history >>> is left alone and
whatever the user has configured for their CPAN client is used.
Valid values are 0 or 1. Defaults to 0
=item *
C<<< reload_history_period >>> -- after this period in seconds, history of modules
smoked will be reloaded when possible.
Default value 1800 seconds (30 minutes).
=back
=head1 HINTS
=head2 Selection of distributions to test
Only the most recently uploaded developer and normal releases will be
tested, and only if the developer release is newer than the regular release
indexed by PAUSE.
For example, if Foo-Bar-0.01, Foo-Bar-0.02, Foo-Bar-0.03_01 and Foo-Bar-0.03_02
are on CPAN, only Foo-Bar-0.02 and Foo-Bar-0.03_02 will be tested, and in
reverse order of when they were uploaded. Once Foo-Bar-0.04 is released and
indexed, Foo-Bar-0.03_02 will not longer be tested.
To avoid testing script or other tarballs, developer distributions included
must have a base distribution name that resembles a distribution tarball
already indexed by PAUSE. If the first upload of distribution to PAUSE is a
developer release -- Baz-Bam-0.00_01.tar.gz -- it will not be tested as there
is no indexed Baz-Bam appearing in CPAN's 02packages.details.txt file.
Unauthorized tarballs are treated like developer releases and will be tested
if they resemble an indexed distribution and are newer than the indexed
tarball.
Perl, parrot, kurila, Pugs and similar distributions will not be tested. The
skip list is based on CPAN::Mini and matches as follows:
qr{(?:
/(?:emb|syb|bio)?perl-\d
| /(?:parrot|ponie|kurila|Perl6-Pugs)-\d
| /perl-?5\.004
| /perl_mlb\.zip
)}xi,
Bundles and mod_perl distributions will also not be tested, though mod_perl is
likely to be requested as a dependency by many modules. See the next section
for how to tell CPAN.pm not to test certain dependencies.
=head2 Skipping additional distributions
If certain distributions hang, crash or otherwise cause trouble, you can use
CPAN's "distroprefs" system to disable them. If a distribution is disabled, it
won't be built or tested. If a distribution's dependency is disabled, a
failing test is just discarded.
The first step is configuring a directory for distroprefs files:
$ cpan
cpan> o conf init prefs_dir
cpan> o conf commit
Next, ensure that either the L<YAML> or L<YAML::Syck> module is installed.
(YAML::Syck is faster). Then create a file in the C<<< prefs_dir >>> directory
to hold the list of distributions to disable, e.g. call it C<<< disabled.yml >>>
In that file, you can add blocks of YAML code to disable distributions. The
match criteria "distribution" is a regex that matches against the canonical
name of a distribution, e.g. C<<< AUTHOR/Foo-Bar-3.14.tar.gz >>>.
Here is a sample file to show you some syntax (don't actually use these,
though):
---
comment: "Tests take too long"
match:
distribution: "^DAGOLDEN/CPAN-Reporter-\d"
disabled: 1
---
comment: "Skip Win32 distributions"
match:
distribution: "/Win32"
disabled: 1
---
comment: "Skip distributions by Andy Lester"
match:
distribution: "^PETDANCE"
disabled: 1
Please note that disabling distributions like this will also disable them
for normal, non-smoke usage of CPAN.pm.
One distribution that I would recommend either installing up front or else
disabling with distroprefs is mod_perl, as it is a common requirement for many
Apache:: modules but does not (easily) build and test under automation.
---
comment: "Don't build mod_perl if required by some other module"
match:
distribution: "/mod_perl-\d"
disabled: 1
Distroprefs are more powerful than this -- they can be used to automate
responses to prompts in distributions, set environment variables, specify
additional dependencies and so on. Read the docs for CPAN.pm for more and
look in the "distroprefs" directory in the CPAN distribution tarball for
examples.
=head2 Using a local CPAN::Mini mirror
Because distributions must be retrieved from a CPAN mirror, the smoker may
cause heavy network load and will repetitively download common build
prerequisites.
An alternative is to use L<CPAN::Mini> to create a local CPAN mirror and to
point CPAN's C<<< urllist >>> to the local mirror.
$ cpan
cpan> o conf urllist unshift file:///path/to/minicpan
cpan> o conf commit
However, CPAN::Reporter::Smoker needs the C<<< find-ls.gz >>> file, which
CPAN::Mini does not mirror by default. Add it to a .minicpanrc file in your
home directory to include it in your local CPAN mirror.
also_mirror: indices/find-ls.gz
Note that CPAN::Mini does not mirror developer versions. Therefore, a
live, network CPAN Mirror will be needed in the urllist to retrieve these.
Note that CPAN requires the LWP module to be installed to use a local CPAN
mirror.
Alternatively, you might experiment with the alpha-quality release of
L<CPAN::Mini::Devel>, which subclasses CPAN::Mini to retrieve developer
distributions (and find-ls.gz) using the same logic as
CPAN::Reporter::Smoker.
=head2 Timing out hanging tests
CPAN::Reporter (since 1.08) supports a 'command_timeout' configuration option.
Set this option in the CPAN::Reporter configuration file to time out tests that
hang up or get stuck at a prompt. Set it to a high-value to avoid timing out a
lengthy tests that are still running -- 1000 or more seconds is probably
enough.
Warning -- on Win32, terminating processes via the command_timeout is equivalent to
SIGKILL and could cause system instability or later deadlocks
This option is still considered experimental.
=head2 Avoiding repetitive prerequisite testing
Because CPAN::Reporter::Smoker satisfies all requirements from scratch, common
dependencies (e.g. Class::Accessor) will be unpacked, built and tested
repeatedly.
As of version 1.92_56, CPAN supports the C<<< trust_test_report_history >>> config
option. When set, CPAN will check the last test report for a distribution.
If one is found, the results of that test are used instead of running tests
again.
$ cpan
cpan> o conf init trust_test_report_history
cpan> o conf commit
( run in 1.725 second using v1.01-cache-2.11-cpan-98e64b0badf )