PITA::XML::Test - The result of an single executed test script


PITA-XML documentation Contained in the PITA-XML distribution.

Index


Code Index:

NAME

Top

PITA::XML::Test - The result of an single executed test script

DESCRIPTION

Top

The PITA::XML::Test class provides data objects that represent the output from a single test script.

METHODS

Top

new

The new constructor is used to create a new test result.

TO BE COMPLETED

Returns a PITA::XML::Text object, or dies on error.

name

The name accessor returns the name of the test, if it has one.

Returns a not-null string, or undef if the test is unnamed.

language

The language accessor returns the mime-type of the test output.

On creation, this defaults to "text/x-tap" unless otherwise specified.

stdout

The stdout accessor returns the output of the test as a SCALAR reference.

stderr

The stderr accessor returns the error output of the command as a SCALAR reference, or undef if the test was run via a communications mechanism that does not support error output.

exitcode

The exitcode accessor returns the process exit code of the test, if run across a communications mechanism that supports the concept of an exit code.

Returns a not-null string (generally an integer), or undef if the test did not return an exit code.

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PITA-XML

For other issues, contact the author.

AUTHOR

Top

Adam Kennedy <adamk@cpan.org>, http://ali.as/

SEE ALSO

Top

PITA::XML

The Perl Image-based Testing Architecture (http://ali.as/pita/)

COPYRIGHT

Top


PITA-XML documentation Contained in the PITA-XML distribution.
package PITA::XML::Test;

use strict;
use Carp         ();
use Params::Util qw{ _STRING _SCALAR0 };

use vars qw{$VERSION};
BEGIN {
	$VERSION = '0.51';
}





#####################################################################
# Constructor and Accessors

sub new {
	my $class = shift;
	my $self  = bless { @_ }, $class;

	# Check the object
	$self->_init;

	$self;
}

sub _init {
	my $self = shift;

	# Check the test name
	if ( $self->name ) {
		unless ( _STRING($self->name) ) {
			Carp::croak('Invalid or missing cmd');
		}
	} else {
		$self->{name} = undef;
	}

	# Check the mime-type
	$self->{language} ||= 'text/x-tap';
	unless ( _STRING($self->language) ) {
		Carp::croak('Invalid or missing language mime-type');
	}

	# Check the STDOUT
	unless ( PITA::XML->_OUTPUT($self, 'stdout') ) {
		Carp::croak('Invalid or missing STDOUT output');
	}

	# Check the STDERR (optional)
	if ( defined $self->stderr or exists $self->{stderr} ) {
		unless ( PITA::XML->_OUTPUT($self, 'stderr') ) {
			Carp::croak('Invalid or missing STDERR output');
		}
	} else {
		$self->{stderr} = undef;
	}

	# Check the optional exit code
	if ( defined $self->exitcode ) {
		unless ( defined _STRING($self->exitcode) ) {
			Carp::croak('Invalid exit code');
		}
	} else {
		$self->{exitcode} = undef;
	}

	$self;
}

sub name {
	$_[0]->{name};
}

sub language {
	$_[0]->{language};
}

sub stdout {
	$_[0]->{stdout};
}

sub stderr {
	$_[0]->{stderr};
}

sub exitcode {
	$_[0]->{exitcode};
}

1;