Chart-EPS_graph

 view release on metacpan or  search on metacpan

lib/Chart/EPS_graph/Test.pm  view on Meta::CPAN

	unless ($tainted) {
		$self->mk_png_file($eps);
		$self->test_png_file($eps);
		$eps->display();
	}

	if ($self->{dir} =~ m/Chart\/EPS_graph/m) {
		$self->{results} .= "Ahem! Deleting test graphs from '$self->{dir}'. \n";
		$self->clean_up_dir();
		$self->{results} .= "Note: Next time, specify '/some/dir/' for the test. \n";
	} else {
		my $foo_path = "$self->{dir}/foo.eps*";
		$foo_path =~ s/\//\\/gm if $Config::Config{'osname'} =~ m/Win/im;
		$self->{results} .= "Done: Lacking any oopses, you may look at '$foo_path'. \n";
	}
	return $self->pass_judgement(); # RE the string for "Oops!" as failure.
}

1;

__END__

=head1 NAME

Chart::EPS_graph::Test.pm

=head1 VERSION

Version 0.01

=head1 SYNOPSIS

From the CLI, call as below where C<'/some/dir/'> is any directory you have
permission to write to.

C<perl -e "use Chart::EPS_graph::Test; \ >

C<print Chart::EPS_graph::Test-E<gt>full_test('/some/dir');">

From anywhere else call...

C<use Chart::EPS_graph::Test;>

C<print Chart::EPS_graph::Test-E<gt>full_test(/some/dir);>

With the parent module (C<Chart::EPS_graph.pm>) loaded, call as below. The
C<$foo> may be either class or instance (of module C<Chart::EPS_graph>) as it
will be ignored. The test module auto-instanciates its own object without need
of a C<new()> method. It is just a test, after all.

C<$foo-E<gt>full_test('/some/dir');>

Then look for both C<foo.eps> and C<foo.eps.png> to be created in C</some/dir/>.

=head1 SUBROUTINES/METHODS

There is but a single method of interest as detailed in the synopsis above.

A special default is in effect if called without C<'/some/dir'> as an argument.
Then output will default to the C</home/your_id> directory on UNIX or the
desktop in Win32 with only the C<foo.eps> (and not the C<foo.eps.png>) being
written there. This default behavior exists to allow for the module to be called
as a test when first building the module freshly downloaded from CPAN.

In the ordinary, user-diven, case (when C</some/dir> is supplied as an argument)
then this module will allow itself a free hand to search for wherever it is that
I<Ghostscript> and/or I<The GIMP> have been installed. It calls the special Perl
module C<File::Find> to do this. It must because those programs may be installed
in various paths depending upon their version number.

But while being built as a brand new module freshly downloaded from CPAN, taint
mode will be in effect. This is a security precaution that disallows many an
unsafe condition. Taint mode will disallow that C<File::Find> be free to look
about where it likes. Thus, since at time of build we cannot know where
I<Ghostscript> and I<The GIMP> might be, and also cannot look for them, then
the test must do without them such that only C<foo.eps> and not C<foo.eps.png>
may be created during the test.


=head1 DESCRIPTION

For use only with the C<Chart::EPS_graph> module...as a full, user-like test
thereof.

How this test works is that two files, C<foo.eps> and C<foo.eps.png> will be
(over-)written into C</some/dir/>. The test itself will inspect each of these
files for date, size and content. Based upon what it finds it will return a
string as its pronouncement on the health of C<Chart::EPS_graph> as a module.
That string will contain several lines, all of which should start with "Okay:"
and none of which should start with "Oops!".

=head1 USAGE

Here is the output from calling this test module on the command line on
NetBSD UNIX OS. If, as below, you specify a file path between the parens
the output will be written there. Elsewise it will default to the user's home
directory on UNIX or their desktop on Win32.

C<baal: {666} perl -e "use Chart::EPS_graph::Test; \>

C<print Chart::EPS_graph::Test-E<gt>full_test('/ram');">

C<Testing Chart::EPS_graph.pm in path '/ram' >

C<Okay: File 'foo.eps' has expected first two lines. >

C<Okay: File 'foo.eps' looks fresh: 0 seconds old. >

C<Okay: File 'foo.eps' looks big enough, 28319 bytes. >

C<Okay: Ghostscript created 'foo.eps.png'. >

C<Okay: File 'foo.eps.png' looks fresh: 1 seconds old.>

C<Okay: File 'foo.eps.png' looks big enough, 105828 bytes. >

C<Glad Tidings! All tests okay for Chart::EPS_graph. >

C<baal: {667} >

Had there been a problem of any kind, one or more of the above lines would have
begun as C<Oops! ...> followed by a few terse details. You can also inspect the
example files personally via I<The GIMP> or I<ImageMagick> as you choose.

=head1 DIAGNOSTICS

A few of my design-phase, run-time diagnostics remain but are commented out
for the formal CPAN release so as not to impinge on general usage.

=head1 CONFIGURATION AND ENVIRONMENT

This module requires no configuration. It auto-searches for its dependencies
by calling to C<File::Find>.

My goal, as always, is OS-independence, but only have recources to design and
test on these two platforms only:

=over 4

=item NetBSD 2.0.2 running Perl 5.8.7

=item WinXP SP2 running ActiveState Perl 5.8.0.

=back

=head1 DEPENDENCIES

Refer to POD of parent module C<Chart::EPS_graph>.

=head1 INCOMPATIBILITIES

None known as yet.

=head1 BUGS AND LIMITATIONS

None known as yet.



( run in 0.722 second using v1.01-cache-2.11-cpan-df04353d9ac )