package UserScenarioDesc; use strict; use Cwd qw( abs_path ); my ($cwd, $above, $below, $tinc); BEGIN { $cwd = abs_path "."; ($above, $below) = $cwd =~ m~^(.+)/pp2dev/src(/.+|)$~ or die "Not in a pp2dev source tree\n"; my $tinc = "$above/pp2dev/src/testsuite/user/tinc"; my $Common="$above/pp2dev/src/testsuite/user"; unshift @INC, $tinc; unshift @INC, $Common; } use DHPL::System; use nightly::common; use Logs::LogReader; #Defining function BEGIN { use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( &get_user_scenario_desc ); } sub get_user_scenario_desc{ my($web_link, $us_name) = @_; # constructing web link to open the remote log file if($web_link =~ m/nightly_results(.*?)(.html)/) { $web_link= "/nightly_results".$1.".html"; } #remote copy command `rcp lcla238.ping.com:$web_link /tmp/nightly_db_scenarios.html`; my $file = "/tmp/nightly_db_scenarios.html"; #Generating SUiteLog object my $sul = SuiteLog->new( { FILE => $file } ); # $logfile is the log file of test run #parsing all the log. $sul->parse_suite( ); # get_scheduled will return the list of all the test_suites present in the respective test_run foreach my $sname ( @{$sul->get_scheduled( )} ) { #creating scenario_log variable using SuiteLog object my $scl = $sul->get_log( $sname ); #invoking method to list all the scenarios names for the given web link. my $name = $scl->name( ); ##invoking method to extract the description (if any) for the given scenario name of the provided test_web_link. my $description=$scl->get_decription(); if($name eq $us_name){ return $description; } } } 1;