Well I'm not sure what snippet would work. This is running a set of scripts (total of about 8 to run this example) that are using objects to set up the environment depending on platform and OS. I already have some warnings placed in the code, as well as print statements for debugging.
The basic function is this:
sub getBinDir
{
my $self = shift;
if ( not exists $self->{'binDir'} )
{
warn "Object member binDir not set";
return "";
}
$self->{'binDir'} = shift if @_;
print "Returning binDir.\n";
return $self->{'binDir'};
}
It's located in the TestHarness.pm file, but called from UnixTestHarness.pm
sub copyCtestBinaries
{
my $self = shift;
my $binDir = $self->getBinDir();
if ( $binDir eq '' )
{
warn "Could not set up C test binary area: $!\n";
print "Received " . $self->getBinDir() . " for binDir.\n";
return;
}
$binDir = $binDir . "\/*";
print "BinDir = $binDir.\n";
my $appBin = $self->app1() . "/bin";
print "AppDir = $appBin.\n";
`cp $binDir $appBin`;
}
With the values set up in SolarisTestHarness.pm
sub new
{
my $class = shift;
# Pass the command line to the base class.
my $self = $class->SUPER::new(@_);
# Set OS specific defaults.
$self->{'binDir'} = 'bin/solaris';
bless ($self, $class);
return $self;
}
One thing I did try, was to move the function to the SolarisTestHarness.pm file and set it there if its not set already. Which generated the following:
Can't locate object method "getBinDir" via package "SolarisTestHarness" at /opt/testharness/UnixTestHarness.pm line 90. |