Changeset 232994 in webkit


Ignore:
Timestamp:
Jun 19, 2018 4:58:54 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[test262-runner] Print results report to HTML
https://bugs.webkit.org/show_bug.cgi?id=186790

Patch by Leo Balter <Leo Balter> on 2018-06-19
Reviewed by Michael Saboff.

After runing the tests, 2 html files are created with a list to failing tests and summaries.

  • Scripts/test262/Runner.pm:

(main):
(summarizeResults):
(printHTML):

Location:
trunk/Tools
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r232987 r232994  
     12018-06-19  Leo Balter  <leonardo.balter@gmail.com>
     2
     3        [test262-runner] Print results report to HTML
     4        https://bugs.webkit.org/show_bug.cgi?id=186790
     5
     6        Reviewed by Michael Saboff.
     7
     8        After runing the tests, 2 html files are created with a list to failing tests and summaries.
     9        * Scripts/test262/Runner.pm:
     10        (main):
     11        (summarizeResults):
     12        (printHTML):
     13
    1142018-06-19  Keith Rollin  <krollin@apple.com>
    215
  • trunk/Tools/Scripts/test262/Runner.pm

    r232972 r232994  
    187187    }
    188188
    189 
    190189    if ($JSC) {
    191190        $JSC = abs_path($JSC);
     
    293292    print $deffh getHarness(\@defaultHarnessFiles);
    294293
    295     # If not commandline test path supplied, use the root directory of all tests.
    296     push(@cliTestDirs, 'test') if not @cliTestDirs;
     294    if (!@cliTestDirs) {
     295        # If not commandline test path supplied, use the root directory of all tests.
     296        push(@cliTestDirs, 'test') if not @cliTestDirs;
     297        $runningAllTests = 1;
     298    }
    297299
    298300    if ($latestImport) {
     
    302304        findAllFailing();
    303305    } else {
    304         $runningAllTests = 1;
    305306        # Otherwise, get all files from directory
    306307        foreach my $testsDir (@cliTestDirs) {
     
    502503    }
    503504
    504     print("\n");
     505    my $totalRun = scalar @results - $skipfilecount;
     506    print "\n$totalRun tests run\n";
     507    print "$skipfilecount test files skipped\n";
     508
     509    if (!$expect) {
     510        print "$failcount tests failed\n";
     511        print "$newpasscount tests newly pass\n" if $skippedOnly;
     512    } else {
     513        print "$failcount tests failed in total\n";
     514        print "$newfailcount tests newly fail\n";
     515        print "$newpasscount tests newly pass\n";
     516    }
    505517
    506518    if ($saveExpectations) {
     
    508520        print "Saved expectation file in: $expectationsFile\n";
    509521    }
    510     if ($runningAllTests) {
    511         if (! -e $resultsDir) {
    512             mkpath($resultsDir);
    513         }
    514         $resultsFile = abs_path("$resultsDir/results.yaml");
    515 
    516         DumpFile($resultsFile, \@results);
    517         print "Saved all the results in $resultsFile\n";
    518         summarizeResults();
    519     }
    520 
    521     my $total = scalar @results - $skipfilecount;
    522     print "\n" . $total . " tests ran\n";
    523 
    524     if ( !$expect ) {
    525         print $failcount . " tests failed\n";
    526         print $newpasscount . " tests newly pass\n" if $skippedOnly;
    527     } else {
    528         print $failcount . " tests failed in total\n";
    529         print $newfailcount . " tests newly fail\n";
    530         print $newpasscount . " tests newly pass\n";
    531     }
    532 
    533     print $skipfilecount . " test files skipped\n";
     522    if (! -e $resultsDir) {
     523        mkpath($resultsDir);
     524    }
     525
     526    $resultsFile = abs_path("$resultsDir/results.yaml");
     527
     528    DumpFile($resultsFile, \@results);
     529    print "Saved all the results in $resultsFile\n";
     530
     531    my $styleCss = abs_path("$Bin/report.css");
     532    qx/cp $styleCss $resultsDir/;
     533    summarizeResults();
     534    printHTMLResults(\%failed, $totalRun, $failcount, $newfailcount, $skipfilecount);
     535
     536    print "See the summaries and results in the $resultsDir.\n\n";
    534537
    535538    printf("Done in %.2f seconds!\n", time() - $startTime);
     
    917920    $summaryTxtFile = abs_path("$resultsDir/summary.txt");
    918921    $summaryFile = abs_path("$resultsDir/summary.yaml");
     922    my $summaryHTMLFile = abs_path("$resultsDir/summary.html");
    919923
    920924    my %byfeature;
     
    973977
    974978    open(my $sfh, '>', $summaryTxtFile) or die $!;
    975 
    976     print $sfh sprintf("%-6s %-6s %-6s %-6s %-6s %-6s %-7s %-6s %s\n", 'TOTAL', 'RAN', 'PASS-%', 'PASS', 'FAIL', 'SKIP', 'TIME', 'AVG', 'FOLDER');
     979    open(my $htmlfh, '>', $summaryHTMLFile) or die $!;
     980
     981    print $htmlfh qq{<html><head>
     982        <title>Test262 Summaries</title>
     983        <link rel="stylesheet" href="report.css">
     984        </head>
     985        <body>
     986        <h1>Test262 Summaries</h1>
     987        <div class="visit">Visit <a href="index.html">the index</a> for a report of failures.</div>
     988        <h2>By Features</h2>
     989        <table class="summary-table">
     990            <thead>
     991                <th>Feature</th>
     992                <th>%</th>
     993                <th>Total</th>
     994                <th>Run</th>
     995                <th>Passed</th>
     996                <th>Failed</th>
     997                <th>Skipped</th>
     998                <th>Exec. time</th>
     999                <th>Avg. time</th>
     1000            </thead>
     1001            <tbody>};
     1002
     1003    print $sfh sprintf("%-6s %-6s %-6s %-6s %-6s %-6s %-7s %-6s %s\n", 'TOTAL', 'RUN', 'PASS-%', 'PASS', 'FAIL', 'SKIP', 'TIME', 'AVG', 'FEATURE');
     1004
     1005    foreach my $key (sort keys %byfeature) {
     1006        my $totalFilesRun = $byfeature{$key}->[0] + $byfeature{$key}->[1];
     1007        my $totalFiles = $totalFilesRun + $byfeature{$key}->[2];
     1008
     1009        my $iper = ($byfeature{$key}->[0] / $totalFiles) * 100;
     1010        my $per = sprintf("%.0f", $iper) . "%";
     1011
     1012        my $time = sprintf("%.1f", $byfeature{$key}->[3]) . "s";
     1013        my $avgTime;
     1014
     1015        if ($totalFilesRun) {
     1016            $avgTime = sprintf("%.2f", $byfeature{$key}->[3] / $totalFilesRun) . "s";
     1017        } else {
     1018            $avgTime = "0s";
     1019        }
     1020
     1021        print $sfh sprintf("%-6s %-6s %-6s %-6d %-6d %-6d %-7s %-6s %s\n",
     1022                           $totalFiles,
     1023                           $totalFilesRun,
     1024                           $per,
     1025                           $byfeature{$key}->[0],
     1026                           $byfeature{$key}->[1],
     1027                           $byfeature{$key}->[2],
     1028                           $time,
     1029                           $avgTime,
     1030                           $key);
     1031
     1032        print $htmlfh qq{
     1033            <tr class="per-$iper">
     1034                <td>$key</td>
     1035                <td>$per</td>
     1036                <td>$totalFiles</td>
     1037                <td>$totalFilesRun</td>
     1038                <td>$byfeature{$key}->[0]</td>
     1039                <td>$byfeature{$key}->[1]</td>
     1040                <td>$byfeature{$key}->[2]</td>
     1041                <td>$time</td>
     1042                <td>$avgTime</td>
     1043            </tr>};
     1044    }
     1045
     1046    print $htmlfh qq{</tbody></table>
     1047        <h2>By Path</h2>
     1048        <table class="summary-table">
     1049            <thead>
     1050                <th>Folder</th>
     1051                <th>%</th>
     1052                <th>Total</th>
     1053                <th>Run</th>
     1054                <th>Passed</th>
     1055                <th>Failed</th>
     1056                <th>Skipped</th>
     1057                <th>Exec. time</th>
     1058                <th>Avg. time</th>
     1059            </thead>
     1060            <tbody>};
     1061
     1062    print $sfh sprintf("\n\n%-6s %-6s %-6s %-6s %-6s %-6s %-7s %-6s %s\n", 'TOTAL', 'RUN', 'PASS-%', 'PASS', 'FAIL', 'SKIP', 'TIME', 'AVG', 'FOLDER');
    9771063    foreach my $key (sort keys %bypath) {
    978         my $totalFilesRan = $bypath{$key}->[0] + $bypath{$key}->[1];
    979         my $totalFiles = $totalFilesRan + $bypath{$key}->[2];
    980 
    981         my $per = sprintf("%.0f", ($bypath{$key}->[0] / $totalFiles) * 100) . "%";
     1064        my $totalFilesRun = $bypath{$key}->[0] + $bypath{$key}->[1];
     1065        my $totalFiles = $totalFilesRun + $bypath{$key}->[2];
     1066
     1067        my $iper = ($bypath{$key}->[0] / $totalFiles) * 100;
     1068        my $per = sprintf("%.0f", $iper) . "%";
    9821069
    9831070        my $time = sprintf("%.1f", $bypath{$key}->[3]) . "s";
    9841071        my $avgTime;
    9851072
    986         if ($totalFilesRan) {
    987             $avgTime = sprintf("%.2f", $bypath{$key}->[3] / $totalFilesRan) . "s";
     1073        if ($totalFilesRun) {
     1074            $avgTime = sprintf("%.2f", $bypath{$key}->[3] / $totalFilesRun) . "s";
    9881075        } else {
    9891076            $avgTime = "0s";
     
    9921079        print $sfh sprintf("%-6s %-6s %-6s %-6d %-6d %-6d %-7s %-6s %s\n",
    9931080                           $totalFiles,
    994                            $totalFilesRan,
     1081                           $totalFilesRun,
    9951082                           $per,
    9961083                           $bypath{$key}->[0],
     
    10001087                           $avgTime,
    10011088                           $key);
    1002     }
    1003 
    1004     print $sfh "\n\n";
    1005     print $sfh sprintf("%-6s %-6s %-6s %-6s %-6s %-6s %-7s %-6s %s\n", 'TOTAL', 'RAN', 'PASS-%', 'PASS', 'FAIL', 'SKIP', 'TIME', 'AVG', 'FEATURE');
    1006 
    1007     foreach my $key (sort keys %byfeature) {
    1008         my $totalFilesRan = $byfeature{$key}->[0] + $byfeature{$key}->[1];
    1009         my $totalFiles = $totalFilesRan + $byfeature{$key}->[2];
    1010 
    1011         my $per = sprintf("%.0f", ($byfeature{$key}->[0] / $totalFiles) * 100) . "%";
    1012 
    1013         my $time = sprintf("%.1f", $byfeature{$key}->[3]) . "s";
    1014         my $avgTime;
    1015 
    1016         if ($totalFilesRan) {
    1017             $avgTime = sprintf("%.2f", $byfeature{$key}->[3] / $totalFilesRan) . "s";
    1018         } else {
    1019             $avgTime = "0s";
    1020         }
    1021 
    1022         print $sfh sprintf("%-6s %-6s %-6s %-6d %-6d %-6d %-7s %-6s %s\n",
    1023                            $totalFiles,
    1024                            $totalFilesRan,
    1025                            $per,
    1026                            $byfeature{$key}->[0],
    1027                            $byfeature{$key}->[1],
    1028                            $byfeature{$key}->[2],
    1029                            $time,
    1030                            $avgTime,
    1031                            $key);
    1032     }
     1089
     1090        print $htmlfh qq{
     1091            <tr class="per-$iper">
     1092                <td>$key</td>
     1093                <td>$per</td>
     1094                <td>$totalFiles</td>
     1095                <td>$totalFilesRun</td>
     1096                <td>$bypath{$key}->[0]</td>
     1097                <td>$bypath{$key}->[1]</td>
     1098                <td>$bypath{$key}->[2]</td>
     1099                <td>$time</td>
     1100                <td>$avgTime</td>
     1101            </tr>};
     1102    }
     1103
     1104    print $htmlfh qq{</tbody></table>
     1105        <div class="visit">Visit <a href="index.html">the index</a> for a report of failures.</div>
     1106        </body></html>};
    10331107
    10341108    close($sfh);
     1109    close($htmlfh);
    10351110
    10361111    my %resultsyaml = (
     
    10401115
    10411116    DumpFile($summaryFile, \%resultsyaml);
    1042 
    1043     print "See summarized results in $summaryTxtFile\n";
    10441117}
    10451118
     
    10581131}
    10591132
     1133sub printHTMLResults {
     1134    my %failed = %{shift()};
     1135    my ($total, $failcount, $newfailcount, $skipcount) = @_;
     1136
     1137    # Create test262-results folder if it does not exits
     1138    if (! -e $resultsDir) {
     1139        mkpath($resultsDir);
     1140    }
     1141
     1142    my $indexHTML = abs_path("$resultsDir/index.html");
     1143    open(my $htmlfh, '>', $indexHTML) or die $!;
     1144
     1145    print $htmlfh qq{<html><head>
     1146        <title>Test262 Results</title>
     1147        <link rel="stylesheet" href="report.css">
     1148        </head>
     1149        <body>
     1150        <h1>Test262 Results</h1>
     1151        <div class="visit">Visit <a href="summary.html">the summary</a> for statistics.</div>};
     1152
     1153    print $htmlfh qq{<h2>Stats</h2><ul>};
     1154
     1155    {
     1156        my $failedFiles = scalar (keys %failed);
     1157        my $totalPlus = $total + $skipcount;
     1158        print $htmlfh qq{
     1159            <li>$total test files run from $totalPlus files, $skipcount skipped test files</li>
     1160            <li>$failcount failures from $failedFiles distinct files, $newfailcount new failures</li>
     1161        };
     1162    }
     1163
     1164    print $htmlfh qq{</ul><h2>Failures</h2><ul>};
     1165
     1166    while (my ($path, $scenarios) = each %failed) {
     1167        print $htmlfh qq{<li class="list-item">
     1168            <label for="$path" class="expander-control">$path</label>
     1169            <input type="checkbox" id="$path" class="expander">
     1170            <ul class="expand">};
     1171        while (my ($scenario, $value) = each %{$scenarios}) {
     1172            print $htmlfh qq{<li>$scenario: $value</li>};
     1173        }
     1174        print $htmlfh qq{</ul></li>}
     1175    }
     1176
     1177    print $htmlfh qq{</ul>
     1178    <div class="visit">Visit <a href="summary.html">the summary</a> for statistics.</div>
     1179    </body></html>};
     1180
     1181    close $htmlfh;
     1182}
     1183
    10601184__END__
    10611185
Note: See TracChangeset for help on using the changeset viewer.