Made Survey Test Suite feature was dependent on TAP::Parser and TAP::Parser::Aggregator
This commit is contained in:
parent
d37da79bbd
commit
1a4b673843
2 changed files with 39 additions and 5 deletions
|
|
@ -22,6 +22,11 @@ use WebGUI::Asset::Wobject::Survey::ResponseJSON;
|
|||
use Params::Validate qw(:all);
|
||||
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
|
||||
|
||||
my $TAP_PARSER_MISSING = <<END_WARN;
|
||||
The Survey Test Suite feature requires TAP::Parser and TAP::Parser::Aggregator CPAN modules.
|
||||
These will be installed as a dependency if you upgrade to Test::Harness 3.x
|
||||
END_WARN
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, [definition] )
|
||||
|
|
@ -2629,6 +2634,15 @@ sub www_runTest {
|
|||
return $self->session->privilege->insufficient()
|
||||
unless $self->session->user->isInGroup( $self->get('groupToEditSurvey') );
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Survey');
|
||||
my $ac = $self->getAdminConsole;
|
||||
|
||||
eval 'use TAP::Parser';
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
|
||||
my $testId = $session->form->get("testId");
|
||||
|
||||
my $test = WebGUI::Asset::Wobject::Survey::Test->new($session, $testId)
|
||||
|
|
@ -2640,8 +2654,6 @@ sub www_runTest {
|
|||
|
||||
my $parsed = $self->parseTap($tap) or return $self->www_editTestSuite('Unable to parse test output');
|
||||
|
||||
my $ac = $self->getAdminConsole;
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Survey');
|
||||
$ac->addSubmenuItem($self->session->url->page("func=editTest;testId=$testId"), $i18n->get('edit test'));
|
||||
$ac->addSubmenuItem($self->session->url->page("func=runTest;testId=$testId"), $i18n->get('run test'));
|
||||
return $ac->render($parsed->{templateText}, 'Test Results');
|
||||
|
|
@ -2657,7 +2669,11 @@ all interesting TAP::Parser and TAP::Parser::Result properties) and the template
|
|||
sub parseTap {
|
||||
my ($self, $tap) = @_;
|
||||
|
||||
use TAP::Parser;
|
||||
eval 'use TAP::Parser';
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return;
|
||||
}
|
||||
my $parser = TAP::Parser->new( { tap => $tap } );
|
||||
|
||||
# Expose TAP::Parser and TAP::Parser::Result info as template variables
|
||||
|
|
@ -2725,6 +2741,7 @@ sub www_runTests {
|
|||
|
||||
my $session = $self->session;
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_Survey");
|
||||
my $ac = $self->getAdminConsole;
|
||||
return $self->session->privilege->insufficient()
|
||||
unless $self->session->user->isInGroup( $self->get('groupToEditSurvey') );
|
||||
|
||||
|
|
@ -2746,9 +2763,19 @@ sub www_runTests {
|
|||
};
|
||||
my $format = $self->session->form->param('format');
|
||||
local $| = 1 if $format eq 'tap';
|
||||
|
||||
|
||||
my @parsers;
|
||||
use TAP::Parser::Aggregator;
|
||||
eval 'use TAP::Parser';
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
eval 'use TAP::Parser::Aggregator';
|
||||
if ($@) {
|
||||
$self->session->log->warn($TAP_PARSER_MISSING);
|
||||
return $ac->render($TAP_PARSER_MISSING, $i18n->get('test results'));
|
||||
}
|
||||
my $aggregate = TAP::Parser::Aggregator->new;
|
||||
$aggregate->start;
|
||||
|
||||
|
|
@ -2792,7 +2819,7 @@ sub www_runTests {
|
|||
}
|
||||
my $out = $self->processTemplate($var, $self->get('testResultsTemplateId') || 'S3zpVitAmhy58CAioH359Q');
|
||||
|
||||
my $ac = $self->getAdminConsole;
|
||||
|
||||
if ($format eq 'tap') {
|
||||
my $summary = <<'END_SUMMARY';
|
||||
SUMMARY
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ plan tests => 85;
|
|||
|
||||
my ( $s, $t1 );
|
||||
|
||||
eval 'use TAP::Parser; use TAP::Parser::Aggregator';
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load TAP::Parser and TAP::Parser::Aggregator", 1 if $@;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
use_ok('WebGUI::Asset::Wobject::Survey::Test');
|
||||
|
|
@ -683,6 +689,7 @@ sub try_it {
|
|||
}
|
||||
ok( !$parser->has_problems == !$opts->{fail}, ( $opts->{fail} ? "Fails" : "Passes" ) . ' as expected' );
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue