Commit: 526ac548ee842570da043bc95a848b865cebf5b8
Author: Sara Golemon <[email protected]> Fri, 24 Aug 2018 22:53:38
-0400
Parents: 31bd35c92c5719829d02239232d3798ced7a218f
Branches: master
Link:
http://git.php.net/?p=web/qa.git;a=commitdiff;h=526ac548ee842570da043bc95a848b865cebf5b8
Log:
Refactor reports/run_tests.php
Changed paths:
M reports/run_tests.php
diff --git a/reports/run_tests.php b/reports/run_tests.php
index d611063..f4d6fa8 100644
--- a/reports/run_tests.php
+++ b/reports/run_tests.php
@@ -18,40 +18,101 @@
$startTime = microtime(true);
-include "../include/functions.php";
-include "../include/release-qa.php";
+include __DIR__ . '/../include/release-qa.php';
+include __DIR__ . '/../include/functions.php';
+require __DIR__ . '/reportsfunctions.php';
-require 'reportsfunctions.php';
+common_header();
+echo "<script src=\"sorttable.js\"></script>\n";
+echo "<div style=\"margin:10px\">\n";
-$getVersion = null;
+$version = $_GET['version'] ?? '';
+if (is_valid_php_version($version, $QA_RELEASES)) {
+ $tmSiteUpdate = outputTestReportsForVersion($version);
+} else {
+ $tmSiteUpdate = outputTestReportsSummary();
+}
-if (isset($_GET['version'])) {
- //sanity check
- if (!is_valid_php_version($_GET['version'], $QA_RELEASES)) {
- exit('invalid version');
- }
- $getVersion = $_GET['version'];
- $TITLE = 'PHP Test Reports For PHP Version '.$_GET['version'];
+echo "</div>\n";
+// Last update = date of last report in this very page
+$SITE_UPDATE = date('D M d H:i:s Y T', $tmSiteUpdate)."<br />".
+ "Generated in ".round((microtime(true)-$startTime)*1000)." ms";
+common_footer();
+
+/////////////////////////////////////////////////////////////////////////////
+
+function outputReportTitle(string $TITLE) {
+ echo '<h1><a href="run_tests.php">',
+ '<img title="Go back home" src="home.png" border="0"
style="vertical-align:middle;" /></a>',
+ htmlentities($TITLE), "</h1>\n";
+}
- $limit = 50;
- if (!empty($_GET['limit'])) {
- if (is_numeric($_GET['limit'])) {
- $limit = (int) $_GET['limit'];
+function outputTestReportsSummary() {
+ outputReportTitle('PHP Test Reports Summary');
+ echo <<<HTML
+<table class="sortable" style="border: 1px solid black;padding:5px;
width:800px">
+<thead>
+ <tr>
+ <th>PHP Version</th>
+ <th>Reports</th>
+ <th>Unique failed tests</th>
+ <th>Total failed tests</th>
+ <th>Last report date</th>
+ </tr>
+</thead>
+<tbody>
+HTML;
+
+ $filter = $_GET['summary_filter'] ?? QA_REPORT_FILTER_ALL;
+ $reportsPerVersion = get_summary_data($filter);
+ uksort($reportsPerVersion, 'version_compare');
+ $maxReportDate = 0;
+ foreach ($reportsPerVersion as $version => $line) {
+ if (version_compare($version, '5.3.8', '<')) {
+ continue;
}
+ $tmLastReport = strtotime($line['lastReport']);
+ if ($maxReportDate < $tmLastRport) $maxReportDate = $tmLastReport;
+ echo '<tr>';
+ echo '<td><a href="run_tests.php?version=', urlencode($version),
'">',
+ htmlentities($version).'</a></td>';
+ echo '<td align="right">', intval($line['nbReports']), '</td>';
+ echo '<td align="right">', intval($line['nbFailingTests']), '</td>';
+ echo '<td align="right">', intval($line['nbFailures']), '</td>';
+ echo "<td nowrap align=\"right\"
sorttable_customkey=\"$tmLastReport\">",
+ format_readable_date($tmLastReport),
+ '</td>';
+ echo "</tr>\n";
}
+ echo <<<HTML
+</tbody>
+</table>
+<p>(<a href="run_tests.php?summary_filter=0">Show all versions</a> |
+ <a href="run_tests.php">Show stable and current dev only</a>)</p>
+HTML;
+
+ return $maxReportDate;
+}
- $dbFile = dirname(__FILE__).'/db/'.$getVersion.'.sqlite';
- if (!file_exists($dbFile)) {
- die('no data for this version');
+function outputTestReportsForVersion(string $getVersion) {
+ outputReportTitle("PHP Test Reports For PHP Version $getVersion");
+ $isDevVersion = substr($getVersion, -4) === '-dev';
+
+ $limit = intval($_GET['limit'] ?? 0);
+ if ($limit <= 0) {
+ $limit = 50;
}
+
+ $dbFile = __DIR__ . "/db/{$getVersion}.sqlite";
+ file_exists($dbFile) or die('no data for this version');
+
$database = new SQLite3($dbFile, SQLITE3_OPEN_READONLY);
- if (!($database instanceof SQLite3)) {
- die("Error opening DB file: ".$database->lastErrorMsg());
- }
- $failedTestsArray = array();
+ ($database instanceof SQLite3) or die("Error opening DB file:
".$database->lastErrorMsg());
+
+ $failedTestsArray = [];
// Do we add expected failed ?
- if (isset($_GET['expect']) && $_GET['expect'] == 1) {
+ if (($_GET['expect'] ?? 0) == 1) {
$query = 'SELECT \'xfail\' as xfail, test_name,COUNT(expectedfail.id)
as cpt,\'-\' as variations,
datetime(date) as date FROM expectedfail,reports WHERE
expectedfail.id_report = reports.id
GROUP BY test_name ORDER BY cpt DESC LIMIT :limit';
@@ -75,73 +136,17 @@ if (isset($_GET['version'])) {
$stmt = $database->prepare($query);
$stmt->bindValue(':limit', $limit, SQLITE3_INTEGER);
$q = @$stmt->execute();
- if (!$q) die("Error querying DB (error ".$database->lastErrorCode()."):
".$database->lastErrorMsg());
+ $q or die("Error querying DB (error ".$database->lastErrorCode()."):
".$database->lastErrorMsg());
while ($tab = $q->fetchArray(SQLITE3_ASSOC)) {
$failedTestsArray[] = $tab;
}
$database->close();
-} else {
- if (!isset($_GET['summary_filter'])) {
- $filter = QA_REPORT_FILTER_ALL;
- } else {
- $filter = $_GET['summary_filter'];
- }
- $reportsPerVersion = get_summary_data($filter);
- $TITLE = "PHP Test Reports Summary";
-
-}
-
-common_header();
-?>
-<script src="sorttable.js"></script>
-<div style="margin:10px">
-
-<h1><a href="run_tests.php">
-<img title="Go back home" src="home.png" border="0"
style="vertical-align:middle;" /></a>
-<?php echo $TITLE; ?></h1>
-
-<?php
-if (!$getVersion) {
-?>
-<table class="sortable" style="border: 1px solid black;padding:5px;
width:800px">
-<thead>
- <tr>
- <th>PHP Version</th>
- <th>Reports</th>
- <th>Unique failed tests</th>
- <th>Total failed tests</th>
- <th>Last report date</th>
- </tr>
-</thead>
-<tbody>
-<?php
-uksort($reportsPerVersion, 'version_compare');
-$maxReportDate = 0;
-foreach ($reportsPerVersion as $version => $line) {
-
- if (version_compare($version, '5.3.8', '<')) {
- continue;
- }
- if ($maxReportDate < strtotime($line['lastReport'])) $maxReportDate =
strtotime($line['lastReport']);
- echo '<tr>';
- echo '<td><a
href="run_tests.php?version='.$version.'">'.$version.'</a></td>';
- echo '<td align="right">'.$line['nbReports'].'</td>';
- echo '<td align="right">'.$line['nbFailingTests'].'</td>';
- echo '<td align="right">'.$line['nbFailures'].'</td>';
- echo '<td nowrap align="right"
sorttable_customkey="'.strtotime($line['lastReport']).'">';
- echo format_readable_date(strtotime($line['lastReport']));
- echo '</td>';
- echo '</tr>'."\n";
-}
-?>
-</tbody>
-</table>
-<p>(<a href="run_tests.php?summary_filter=0">Show all versions</a> |
- <a href="run_tests.php?summary_filter=<?php echo QA_REPORT_FILTER_ALL;
?>">Show stable and current dev only</a>)</p>
-<?php
-} else { /* $getVersion */
-?>
+ // Variables interpolated in the following heredoc.
+ $getVersionURL = urlencode($getVersion);
+ $expectCHECKED = (($_GET['expect'] ?? 0) == 1) ? ' CHECKED' : '';
+ $CIQAcolumn = $isDevVersion ? '<th>CIQA status</th>' : '';
+ echo <<<HTML
<style>
#testList td {
padding: 3px;
@@ -153,15 +158,15 @@ function changeExpect()
{
var check = document.getElementById('expect').checked;
if (check == true) {
- document.location.href = 'run_tests.php?version=<?php echo
$getVersion; ?>&expect=1';
+ document.location.href =
'run_tests.php?version=$getVersionURL&expect=1';
} else {
- document.location.href = 'run_tests.php?version=<?php echo
$getVersion; ?>';
+ document.location.href = 'run_tests.php?version=$getVersionURL';
}
}
// ->
</script>
-<input type="checkbox" id="expect" onClick="javascript:changeExpect()"
-<?php if (isset($_GET['expect']) && $_GET['expect'] == '1') echo ' checked';
?> /><small>Show XFAIL</small><br />
+<input type="checkbox" id="expect" onClick="javascript:changeExpect()"
$expectCHECKED />
+<small>Show XFAIL</small><br />
<table id="testList" class="sortable" style="margin-top:10px; width: 800px;
border-collapse: collapse">
<thead>
@@ -170,65 +175,56 @@ function changeExpect()
<th>Count</th>
<th>Variations</th>
<th>Last report date</th>
- <?php
- if (substr($getVersion, -4) == '-dev') {
- echo '<th>CIQA status</th>';
- }
- ?>
+ $CIQAcolumn
<th> </th>
</tr>
</thead>
<tbody>
- <?php
- $i = 0;
- $maxReportDate = 0;
- foreach ($failedTestsArray as $line) {
- if ($maxReportDate < strtotime($line['date'])) $maxReportDate =
strtotime($line['date']);
- echo ' <tr ';
- if ($i % 2) echo 'style="background-color: #ffcc66" ';
- echo '><td>';
- if (isset($line['xfail'])) echo '[XFAIL] ';
- echo $line['test_name'].'</td>';
- echo '<td align="right">'.$line['cpt'].'</td>';
- echo '<td align="right">'.$line['variations'].'</td>';
- echo '<td align="right"
sorttable_customkey="'.strtotime($line['date']).'">';
- echo format_readable_date(strtotime($line['date']));
- echo '</td>';
- if (substr($getVersion, -4) == '-dev') {
- echo '<td style="';
- $textCI = '';
- if (!array_key_exists('success', $line)) {
- // probably xfail
- echo 'background-color: grey';
- } elseif ($line['success'] === null) {
- // no success. Check fail ?
- if (isset($line['failedci'])) {
- echo 'background-color: #c00000';
- $textCI = 'FAIL';
- } else {
- echo 'background-color: grey';
- }
- } else {
- // success
- echo "background-color: #00c000";
- $textCI = 'PASS';
+HTML;
+
+ $maxReportDate = 0;
+ foreach ($failedTestsArray as $i => $line) {
+ $tmDate = strtotime($line['date']);
+ if ($maxReportDate < $tmDate) $maxReportDate = $tmDate;
+
+ $style = ($i % 2) ? ' style="background-color: #ffcc66"' : '';
+ echo " <tr{$style}><td>";
+ if (isset($line['xfail'])) { echo '[XFAIL] '; }
+ echo htmlentities($line['test_name']), '</td>';
+ echo '<td align="right">', htmlentities($line['cpt']), '</td>';
+ echo '<td align="right">', htmlentities($line['variations']), '</td>';
+ echo "<td align=\"right\" sorttable_customkey=\"$tmDate\">",
+ format_readable_date($tmDate),
+ '</td>';
+ if ($isDevVersion) {
+ $style = 'background-color: grey';
+ $textCI = ' ';
+ if (!array_key_exists('success', $line)) {
+ // probably xfail
+ } elseif ($line['success'] === null) {
+ // no success. Check fail ?
+ if (isset($line['failedci'])) {
+ $style = 'background-color: #c00000';
+ $textCI = 'FAIL';
+ }
+ } else {
+ // success
+ $style = "background-color: #00c000";
+ $textCI = 'PASS';
+ }
+
+ echo "<td style=\"$style\" align=\"center\">$textCI</td>";
}
-
- echo '" align="center">'.$textCI.'</td>';
- }
- echo '<td>';
- if (!isset($line['xfail'])) {
- echo '<a
href="viewreports.php?version='.$getVersion.'&test='.urlencode($line['test_name']).'">
- <img src="report.png" title="View reports" border="0" /></a>';
- }
- echo '</td>';
- echo '</tr>'."\n";
- $i++;
- }
-
- ?>
-</tbody></table>
-<?php
+ echo '<td>';
+ if (!isset($line['xfail'])) {
+ echo '<a
href="viewreports.php?version='.$getVersion.'&test='.urlencode($line['test_name']).'">
+ <img src="report.png" title="View reports" border="0" /></a>';
+ }
+ echo '</td>';
+ echo '</tr>'."\n";
+ }
+ echo "</tbody></table>\n";
+
if (count($failedTestsArray) >= $limit) {
echo '<i>There are more failing tests ';
echo '(<a href="run_tests.php?version=' . $getVersion .
'&limit=1000">view all)</i>';
@@ -236,13 +232,6 @@ function changeExpect()
echo '<i>View only the most common failed tests ';
echo '(<a href="run_tests.php?version=' . $getVersion .
'&limit=50">view 50)</i>';
}
-}
-?>
-
-</div>
-<?php
-// Last update = date of last report in this very page
-$SITE_UPDATE = date('D M d H:i:s Y T', $maxReportDate)."<br />".
- "Generated in ".round((microtime(true)-$startTime)*1000)." ms";
-common_footer();
+ return $maxReportDate;
+}