# -*- perl -*- # # Test::AutoBuild::Stage # # Daniel Berrange # Dennis Gregorovic # # Copyright (C) 2004 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: Stage.pm,v 1.10 2006/02/02 10:30:48 danpb Exp $ =pod =head1 NAME Test::AutoBuild::Stage - The base class for an AutoBuild stage =head1 SYNOPSIS use Test::AutoBuild::Stage my $stage = Test::AutoBuild::Stage->new(name => $token, label => $string, [critical => $boolean,] [enabled => $boolean]); # Execute the stage $stage->run($runtime); if ($stage->aborted()) { # Very badly wrong die $stage->log(); } elsif ($stage->failed()) { # Expected failure if ($stage->is_critical()) { # Non-recoverable .. do failure case ... } else { .. do recovery case ... } } elsif ($stage->success() || # Everything's ok $stage->skipped()) { .. do normal case ... } =head1 DESCRIPTION This module is an abstract base class for all AutoBuild stages. If defines a handful of common methods and the abstract method C to be implemented by sub-classes to provide whatever custom processing is required. =head2 STATUS The status of a stage starts off as 'pending', and when the C method is invoked, the status will changed to one of the following: =over 4 =item success If the stage completed its processing without encountering any problems. Stages will automatically have their status set to this value if their C method completes without the C method having been called. =item failed If the stage completed its processing, but encountered and handled one or more problems. Such problems may include failure of a module build, failure of a test suite. Upon encountering such an problem, the stage should call the C method providing a description of the problem, and then return from the C method. =item aborted If the stage died as a result of an error during processing. Stages should simply call the C method to abort processing. NB, the C method should not be used to abort since, autobuilder will automatically hook C into the perl SIG{__DIE__} handler. =item skipped If the stage was not executed due to the C flag being set to false. =back =head1 CONFIGURATION All stage modules have a number of standard configuration options that are used. Sub-classes are not permitted to define additional configuration parameters, rather, they should use the C parameter for their custom configuration needs. =over 4 =item name A short alpha-numeric token representing the stage, typically based on the last component of the name of the stage module =item label An arbitrary string describing the purpose of the stage, suitable for presenting to users through email alerts, or HTML status pages. =item enabled A boolean flag indicating whether the stage is to be executed, or skipped. =item critical A boolean flag indicating whether failure of a stage should be considered fatal to the build process. NB, if a stage aborts, it is always considered fatal, regardless of this flag. =item options A hash containing options specific to the particular stage sub-class. =back =head1 METHODS =over 4 =cut package Test::AutoBuild::Stage; use strict; use Carp qw(confess); use Class::MethodMaker new_with_init => 'new', get_set => [qw( name label start_time end_time status log is_critical is_enabled )]; use Data::Dumper; use Log::Log4perl; use Test::AutoBuild::Result; =item my $stage = Test::AutoBuild::Stage->new(name => $name, label => $label, [critical => $boolean,] [enabled => $boolean,] [options => \%options]); Creates a new stage, with a name specified by the C parameter and label by the C