Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

Test::Smoke and perlivp [was: Utility for building multiple...]

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


ben at morrow

Nov 10, 2009, 10:57 AM

Post #1 of 2 (245 views)
Permalink
Test::Smoke and perlivp [was: Utility for building multiple...]

Quoth Tim.Bunce [at] pobox (Tim Bunce):
> On Tue, Nov 10, 2009 at 05:50:36PM +0100, H.Merijn Brand wrote:
> >
> > $ cpan Test::Smoke
> >
> > should work on all supported OS's
> > That's what brings us the smoke reports, and it does almost exactly what
> > you ask
>
> Umm. Doesn't seem to be a good fit for my needs, but the docs are quite
> sparse so it's hard to be sure. I'd still have to run 'make install'
> myself, and still have to work out the combinations of configure options.

Is there anything to be gained from modifying Test::Smoke so that it
installs the new perl (to a temporary location), runs perlivp, and
cleans up? It seems we've had a few bugs related to installation in the
recent past, and if the smokes were actually running perlivp it might
provide some incentive to start making it test the installation more
thoroughly.

Ben


Tim.Bunce at pobox

Nov 10, 2009, 2:31 PM

Post #2 of 2 (223 views)
Permalink
Re: Test::Smoke and perlivp [was: Utility for building multiple...] [In reply to]

On Tue, Nov 10, 2009 at 06:57:12PM +0000, Ben Morrow wrote:
> Quoth Tim.Bunce [at] pobox (Tim Bunce):
> > On Tue, Nov 10, 2009 at 05:50:36PM +0100, H.Merijn Brand wrote:
> > >
> > > $ cpan Test::Smoke
> > >
> > > should work on all supported OS's
> > > That's what brings us the smoke reports, and it does almost exactly what
> > > you ask
> >
> > Umm. Doesn't seem to be a good fit for my needs, but the docs are quite
> > sparse so it's hard to be sure. I'd still have to run 'make install'
> > myself, and still have to work out the combinations of configure options.
>
> Is there anything to be gained from modifying Test::Smoke so that it
> installs the new perl (to a temporary location), runs perlivp, and
> cleans up? It seems we've had a few bugs related to installation in the
> recent past, and if the smokes were actually running perlivp it might
> provide some incentive to start making it test the installation more
> thoroughly.

Certainly that seems like a useful addition to Test::Smoke.

Adding a way to build, test, install and install-test, multiple variants
would bring it much closer to what I'm after.

I've appended my current quick hack. There might be things you can use.
Any suggestions welcome.

Tim.


#!/usr/bin/env perl
use strict;
use warnings;

=head1 NAME

build-perl-variants - build, optionally test, and install multiple variants of perl

=head1 SYNOPSIS

build-perl-variants [options] root_dir

For example:

$ cd perl-5.11.1
$ build-perl-variants ~/myperls
... a long time passes ...
$ ls ~/myperls
perl-5.11.1-debug-longdouble-noshrplib-nothreads perl-5.11.1-nodebug-longdouble-noshrplib-nothreads
perl-5.11.1-debug-longdouble-noshrplib-threads perl-5.11.1-nodebug-longdouble-noshrplib-threads
perl-5.11.1-debug-longdouble-shrplib-nothreads perl-5.11.1-nodebug-longdouble-shrplib-threads
perl-5.11.1-debug-nolongdouble-noshrplib-nothreads perl-5.11.1-nodebug-nolongdouble-noshrplib-nothreads
perl-5.11.1-debug-nolongdouble-shrplib-nothreads perl-5.11.1-nodebug-nolongdouble-noshrplib-threads
perl-5.11.1-debug-nolongdouble-shrplib-threads perl-5.11.1-nodebug-nolongdouble-shrplib-nothreads

=head1 DESCRIPTION

This utility is designed to make it easy to build multiple variant
configurations of a single perl version for testing.

It (currently) has only a small built-in set of configuation variants:

usethreads
useshrplib
use64bitall
uselongdouble
DEBUGGING

By default all variants are included in the set from which all the combinations
are calculated.

Since the goal is testing it errs on the side of caution: to be immune from
defaults it uses C<-Ufoo> to disable the options that aren't being enabled, and
it installs the perls into unambiguously named directories.

=head1 TODO

Provide a way to specify variants to include or exclude.

=head2 Ideas

Do an initial trial Configure run and parse the generated config.sh to
determine what variants can't be built on this platform and eliminate them from
the trial set.

=cut

use Getopt::Long qw(:config require_order);
use Cwd;
use Data::Dumper;

my %all_variants = (
usethreads => {},
useshrplib => {},
use64bitall => {},
uselongdouble => {},
DEBUGGING => { tag => 'debug' },
);

GetOptions(
'name=s' => \my $opt_name, # eg myperl-x.y.z
'test!' => \(my $opt_test = 1), # run make test, --notest to disable
'jobs=i' => \(my $opt_jobs = 3), # for $ENV{TEST_JOBS}
'n!' => \my $opt_n, # just list, don't act
) or exit 1;

my $root = shift
or die "No installation root directory specified\n";
-w $root
or mkdir($root, 0711)
or die "Can't create installation root directory '$root': $!\n";

$opt_name ||= do {
open my $fh, '<', 'patchlevel.h'
or die "Can't open patchlevel.h: $!";
my %patchlevel;
while (<$fh>) {
$patchlevel{$1} = $2 if m/define \s+ (\w+) \s+ (\d+)/x;
}
"perl-" . join ".", @patchlevel{qw(PERL_REVISION PERL_VERSION PERL_SUBVERSION)};
};

my %variants = %all_variants; # XXX add filter


my %status;
foreach my $set (@{ powerset(keys %variants) }) {
my %enabled = map { $_=>1 } @$set;
my %option_state = map { $_ => ($enabled{$_}) ? 1 : 0 } keys %variants;

my @options;
my $tag = '';
while ( my ($option, $enabled) = each %option_state ) {
my $opt = $all_variants{$option}{tag}
|| do { $option =~ m/^use(.*)/ ? $1 : $option };
if ($enabled) {
push @options, "-D$option";
$tag .= "-$opt";
}
else {
push @options, "-U$option";
$tag .= "-no$opt";
}
}

eval {
warn "\n*** Building $opt_name$tag\n";
build_a_perl_variant($tag, \@options)
unless $opt_n;
};
$status{"$opt_name$tag"} = $@;

}
warn Dumper(\%status);

foreach my $tag (sort keys %status) {
printf "%s: %s\n", $tag, $status{$tag} || 'ok';
}


exit 0;


sub build_a_perl_variant {
my ($tag, $options) = @_;

my $name = "$opt_name$tag";
my $prefix = "$root/$name";
my $logit = "> build$tag.log 2>&1";

run("make distclean || true > /dev/null") if -f "Makefile";
run("./Configure -des @$options -Dusedevel -Dprefix=$prefix $logit");
run("make $logit");
if ($opt_test) {
local $ENV{TEST_JOBS} = $opt_jobs if $opt_jobs;
run("make test $logit") if $opt_test;
}
# just install perl, not the docs
run("make install.perl $logit");
}


sub run {
my ($cmd) = @_;
warn "\t$cmd\n";
system($cmd) == 0 or die "ERROR status returned from $cmd\n";
}


# mjd's powerset implementation. See http://perl.plover.com/LOD/199803.html
# And http://search.cpan.org/perldoc?List::PowerSet
sub powerset {
return [[]] if @_ == 0;
my $first = shift;
my $pow = &powerset;
[ map { [$first, @$_ ], [ @$_] } @$pow ];
}

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.