#!/usr/bin/perl -w # -*- Mode: perl; indent-tabs-mode: nil -*- # ################################################################### # Report Summary Generator for ARMS v2.0 by Vladimir Ermakov ################################################################### # This file parses through a results file and generates a # test summary giving the following info: # # of tcs passed # # of tcs failed # # of tcs died # % of pass and fail # List of testcases that failed. # Separates the results into suites with a convinient quick link # at the top of the page ################################################################### # Questions Coments go to vladimire@netscape.com ################################################################### sub PrintUsage { die < ["express"] END_USAGE } if ($#ARGV < 0) { PrintUsage(); } my $DATAFILE = $ARGV[0]; my $MODE; if($#ARGV > 0) { $MODE = $ARGV[1]; } else { $MODE = ""; } my $express = 0; if($MODE eq "express") { $express = 1; } my $ngdir = "http://geckoqa.mcom.com/ngdriver/"; #$input->url(-base=>1) . "/ngdriver/"; my $ngsuites = $ngdir . "suites/"; my $conffile = "ngdriver.conf"; my $HTMLreport = ""; unless ($express) { print "Content-type: text/html\n\n"; } &generateResults; $File{'SuiteList'} = \@suiteArray; &generateHTML; $File{'Project'} = "Buffy"; print $HTMLreport; sub generateResults { if (!open(INFILE,$DATAFILE)) { print "DATAFILE = $DATAFILE\n"; print "

Cannot open $?, $!

\n"; return -1; } $File{'tcsPass'} = 0; $File{'tcsFail'} = 0; $File{'tcsDied'} = 0; $File{'tcsTotal'} = 0; $line = ; while ($line) { my %Suite = (); my @diedArray = (); $Suite{'DiedList'} = \@diedArray; my @testArray = (); $Suite{'FailedList'} = \@testArray; # Skip to first anchor. while (!($line =~ //i) && $line) { $line = ; # Go to next line. } # First anchor. $line =~ /

(.*?)<\/H1>/i; my $name = $1; my $title =$2; $Suite{'Name'} = $name; $Suite{'Title'} = $title; $Suite{'tcsPass'} = 0; $Suite{'tcsFail'} = 0; $Suite{'tcsDied'} = 0; $Suite{'tcsTotal'} = 0; do { while ($line && !($line =~ //i) && !($line =~ //i)) { $line = ; } if ($line && ($line =~ //i) && ($1 eq $Suite{'Name'})) { $line = ; } # TC = test case. if ($line && ($line =~ //i)) { while ($line && !($line =~ //i)) { $line1 = ; if ($line1 =~ //i) { print "

SOMETHING WRONG!


"; next; next; } $line .= $line1; } my ($tfName, $tcStat); my @lines = split /<->/, $line; $tfName = $lines[1]; $tcStat = $lines[3]; # D=died, P=pass, F=failure if ($tcStat eq 'D') { $Suite{'tcsDied'} += 1; push(@diedArray,$line); } if ($tcStat eq 'P') { $Suite{'tcsPass'} += 1; $Suite{'tcsTotal'} += 1; } if ($tcStat eq 'F') { push(@testArray,$line); $Suite{'tcsFail'} += 1; $Suite{'tcsTotal'} += 1; } $line = ; } } while ($line && !($line =~ /
/i) && $line); $File{'tcsPass'} += $Suite{'tcsPass'}; $File{'tcsFail'} += $Suite{'tcsFail'}; $File{'tcsTotal'} += $Suite{'tcsTotal'}; $File{'tcsDied'} += $Suite{'tcsDied'}; push(@suiteArray,\%Suite); } close INFILE; 1; } sub generateHTML { my $prjExtension; my %extList; my $os = `uname -s`; # Cheap OS id for now my %Matrices; # Hard-coded from ngdriver.conf, I didn't want extra files in tree. $extList{"mb"} = "http://cemicrobrowser.web.aol.com/bugReportDetail.php?RID=%"; $extList{"bs"} = "http://bugscape.nscp.aoltw.net/show_bug.cgi?id=%"; $extList{"bz"} = "http://bugzilla.mozilla.org/show_bug.cgi?id=%"; $extList{"bzx"} = "http://bugzilla.mozilla.org/show_bug.cgi?id=%"; $prjExtension = "bz"; # Buffy hard-coded here. $Matricies{"dom-core"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; $Matricies{"dom-html"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; $Matricies{"domevents"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; $Matricies{"javascript"} = "http://geckoqa.mcom.com/browser/standards/javascript/tcmatrix/index.html"; $Matricies{"forms"} = "http://geckoqa.mcom.com/browser/standards/form_submission/tcmatrix/index.html"; $Matricies{"formsec"} = "http://geckoqa.mcom.com/browser/standards/form_submission/tcmatrix/index.html"; unless ($express) { $HTMLreport .= < Test Result Summary on $File{'Platform'}

AUTOMATED TEST RESULTS


OS: $os

The Following Test Suites Were Run:

    END_PRINT for (my $var = 0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { if (my $href = $Matrices{$File{'SuiteList'}->[$var]->{'Name'}}) { $HTMLreport .= "
  • $File{'SuiteList'}->[$var]->{'Title'}
  • \n"; } else { $HTMLreport .= "
  • [$var]->{'Name'}\">$File{'SuiteList'}->[$var]->{'Title'}
  • \n"; } } $HTMLreport .= <

    Test Result Summary:

    END_PRINT } # !express $HTMLreport .= <   Passed Failed Total Died % Passed % Failed END_PRINT for (my $var = 0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { $curSuite = $File{'SuiteList'}->[$var]; $HTMLreport .= "\n"; if($express) { $HTMLreport .= "$curSuite->{'Title'}\n"; } else { $HTMLreport .= "{'Name'}\">$curSuite->{'Title'}\n"; } $HTMLreport .= "$File{'SuiteList'}->[$var]->{'tcsPass'}\n"; $HTMLreport .= "$File{'SuiteList'}->[$var]->{'tcsFail'}\n"; $HTMLreport .= "$File{'SuiteList'}->[$var]->{'tcsTotal'}\n"; $HTMLreport .= "${@{$File{'SuiteList'}}[$var]}{'tcsDied'}\n"; my $pctPass = $File{'SuiteList'}->[$var]->{'tcsPass'} / $File{'SuiteList'}->[$var]->{'tcsTotal'}; $pctPass = int($pctPass*10000)/100; $HTMLreport .= "$pctPass\n"; my $pctFail = $File{'SuiteList'}->[$var]->{'tcsFail'} / $File{'SuiteList'}->[$var]->{'tcsTotal'}; $pctFail = int($pctFail*10000)/100; $HTMLreport .= "$pctFail\n"; $HTMLreport .= "\n"; } $HTMLreport .= < Total: $File{'tcsPass'} $File{'tcsFail'} $File{'tcsTotal'} $File{'tcsDied'} END_PRINT my $pctPass = $File{'tcsPass'} / $File{'tcsTotal'}; $pctPass = int($pctPass*10000)/100; my $pctFail = $File{'tcsFail'} / $File{'tcsTotal'}; $pctFail = int($pctFail*10000)/100; $HTMLreport .= <$pctPass $pctFail END_PRINT unless ($express) { $HTMLreport .= <Failed Testcases:

END_PRINT my $curSuite; for (my $var=0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { $curSuite = $File{'SuiteList'}->[$var]; $HTMLreport .= <

$curSuite->{'Title'}

Died: END_PRINT for (my $dcnt = 0;$curFile = $File{'SuiteList'}->[$var]->{'DiedList'}->[$dcnt];$dcnt++) { ($none,$fName) = split(/<->/,$curFile); $HTMLreport .= "\n"; } $HTMLreport .= "
$fName

\n"; $HTMLreport .= "Failures:
"; $HTMLreport .= "\n"; for ($fcnt = 0;$curFile = $File{'SuiteList'}->[$var]->{'FailedList'}->[$fcnt];$fcnt++) { ($none,$fName,$fDesc,$fStat,$fBug,$fExpected,$fActual) = split(/<->/,$curFile); $HTMLreport.= "\n"; # $fBug =~ s/(\d+)($prjExtension)/makelink($1,$extList{$2})/ige; # $HTMLreport.= "$fBug\n"; } $HTMLreport .= "
{'Name'}/$fName\" target=\"_new\">$fName"; # Quiet perl warnings about unused variables. my $tmp; $tmp = $fStat; $tmp = $fActual; $tmp = $fExpected; # # TEMPRORAY DISABLED. # my @bugList = split(/[\s+]|,/,$fBug); my $bug = ""; my $index = 0; while ($bugList[$index]) { if ($bugList[$index] =~ /(\d+)$prjExtension/i) { $bugList[$index] =~ s/(\d+)($prjExtension)/makelink($1,$extList{$2})/ige; $bug .= $bugList[$index]; } $index++; } $HTMLreport.= "$bug$fDesc
$fDesc
\n"; } $HTMLreport .= < END_PRINT } # !express 1; } sub makelink { $bugNum = $_[0]; $bugLnk = $_[1]; $bugLnk =~ s/%/$bugNum/ig; $bugLnk = "$bugNum"; return $bugLnk; } 1;