App-TestOnTap
view release on metacpan or search on metacpan
lib/App/TestOnTap/WorkDirManager.pm view on Meta::CPAN
}
sub beginTestRun
{
my $self = shift;
$self->{begin} = time();
$self->__save("$self->{save_testontap}/env", { %ENV });
}
sub endTestRun
{
my $self = shift;
my $args = shift;
my $aggregator = shift;
$self->{end} = time();
$self->{runid} = $args->getId();
my $summary =
{
all_passed => $aggregator->all_passed() ? 1 : 0,
status => $aggregator->get_status(),
failed => [ $aggregator->failed() ],
parse_errors => [ $aggregator->parse_errors() ],
passed => [ $aggregator->passed() ],
planned => [ $aggregator->planned() ],
skipped => [ $aggregator->skipped() ],
todo => [ $aggregator->todo() ],
todo_passed => [ $aggregator->todo_passed() ],
};
$self->__save("$self->{save_testontap}/summary", $summary);
my $testinfo =
{
config => $self->{args}->getConfig()->getRawCfg(),
dispensedorder => $self->{dispensedorder},
found => $self->{foundtests},
commandlines => $self->{commandlines},
fullgraph => $self->{fullgraph},
prunedgraph => $self->{prunedgraph},
};
$self->__save("$self->{save_testontap}/testinfo", $testinfo);
my $elapsed = $aggregator->elapsed();
my $meta =
{
format => { major => 1, minor => 0 }, # Change when format of result tree is changed in any way.
runid => $args->getId(),
suiteid => $args->getConfig()->getId(),
suitename => basename($args->getSuiteRoot()),
begin => stringifyTime($self->{begin}),
end => stringifyTime($self->{end}),
elapsed =>
{
str => $aggregator->elapsed_timestr(),
real => $elapsed->real(),
cpu => $elapsed->cpu_a(),
},
user => $IS_WINDOWS ? getlogin() : scalar(getpwuid($<)),
host => hostfqdn(),
jobs => $args->getJobs(),
dollar0 => slashify(File::Spec->rel2abs($0)),
argv => $args->getFullArgv(),
defines => $args->getDefines(),
platform => $^O,
uname => [ uname() ],
order => $self->{orderstrategy} ? $self->{orderstrategy}->getStrategyName() : undef,
};
$self->__save("$self->{save_testontap}/meta", $meta);
$self->__saveText("$self->{save_testontap}/preprocess", $self->{preprocess}) if $self->{preprocess};
}
# retain the tap handles we issue so we can 'manually' close them
# this can be necessary during a bailout on windows, where the
# spool handle closing is not called, and the automatic cleanup
# of temp stuff spouts errors to delete a file due to it having an
# open handle to it.
#
# note that putting the handle as a key stringifies it, so we
# must use the actual value when closing, not the string...
#
my %tapHandles;
END
{
close($tapHandles{$_}) foreach (keys(%tapHandles));
}
sub openTAPHandle
{
my $self = shift;
my $testPath = slashify(shift, '/');
my $sr = slashify($self->{suiteroot}, '/');
$testPath =~ s#^\Q$sr\E/(.*)#$1#;
my $tapPath = slashify("$self->{tap}/$testPath.tap");
mkpath(dirname($tapPath));
open(my $h, '>', $tapPath) or die("Failed to open '$tapPath': $!");
# save the handle in the list, forcibly stringify it as key and
# save the actual value
#
$tapHandles{"$h"} = $h;
return $h;
}
sub closeTAPHandle
{
my $self = shift;
my $parser = shift;
my $spool_handle = $parser->delete_spool;
if ($spool_handle)
{
close($spool_handle);
# don't forget to remove the key/value in the list
# using the stringified version of the handle!
( run in 1.392 second using v1.01-cache-2.11-cpan-39bf76dae61 )