com web/qa: QA Report : bug fixes and support for xfail view: reports/index.php reports/parserfunc.php reports/test-insert.php
| From: | Olivier Doucet | Date: | Sat, 31 Mar 2012 17:00:26 +0000 |
| Subject: | com web/qa: QA Report : bug fixes and support for xfail view: reports/index.php reports/parserfunc.php reports/test-insert.php | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66202@lists.php.net to get a copy of this message | ||
Commit: 487e7823fbfe185a67e2c6c71489be62d534e146
Author: Olivier Doucet <odoucet@php.net> Sat, 31 Mar 2012 19:00:26 +0200
Parents: eac40a57c9530ef9dd09e265098a3782c91bbe79
Branches: master
Link: http://git.php.net/?p=web/qa.git;a=commitdiff;h=487e7823fbfe185a67e2c6c71489be62d534e146
Log:
QA Report : bug fixes and support for xfail view
Changed paths:
M reports/index.php
M reports/parserfunc.php
M reports/test-insert.php
487e7823fbfe185a67e2c6c71489be62d534e146 diff --git a/reports/index.php b/reports/index.php index ba7492f..48e328e 100644 --- a/reports/index.php +++ b/reports/index.php @@ -49,6 +49,20 @@ if (isset($_GET['version'])) { die("Error opening DB file: ".$database->lastErrorMsg()); } $failedTestsArray = array(); + + // Do we add expected failed ? + if (!isset($_GET['noexpect']) || $_GET['noexpect'] == 0) { + $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; + $q = @$database->query($query); + if ($q) { + while ($tab = $q->fetchArray(SQLITE3_ASSOC)) { + $failedTestsArray[] = $tab; + } + } + } + $query = 'SELECT test_name,COUNT(failed.id) as cpt,COUNT(DISTINCT diff) as variations, datetime(date) as date FROM failed,reports WHERE failed.id_report = reports.id GROUP BY test_name ORDER BY cpt DESC LIMIT ' . $limit; @@ -125,7 +139,23 @@ foreach ($reportsPerVersion as $version => $line) { padding: 3px; } </style> -<table id="testList" class="sortable" style="width: 800px; border-collapse: collapse"> +<script type="text/javascript"> +<!-- +function changeExpect() +{ + var check = document.getElementById('noexpect').checked; + if (check == true) { + document.location.href = '?version=<?php echo $_GET['version']; ?>'; + } else { + document.location.href = '?version=<?php echo $_GET['version']; ?>&noexpect=1'; + } +} +// -> +</script> +<input type="checkbox" id="noexpect" onClick="javascript:changeExpect()" +<?php if (!isset($_GET['noexpect'])) echo ' checked'; ?> /><small>Show XFAIL</small><br /> + +<table id="testList" class="sortable" style="margin-top:10px; width: 800px; border-collapse: collapse"> <thead> <tr> <th>Test name</th> @@ -140,18 +170,23 @@ foreach ($reportsPerVersion as $version => $line) { $i = 0; $maxReportDate = 0; foreach ($failedTestsArray as $line) { - if ($maxReportDate < strtotime($line['date'])) $maxReportDate = strtotime($line['date']); - + if ($maxReportDate < strtotime($line['date'])) $maxReportDate = strtotime($line['date']); echo ' <tr '; if ($i % 2) echo 'style="background-color: #ffcc66" '; - echo '><td>'.$line['test_name'].'</td>'; + 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>'; - echo '<td><a href="viewreports.php?version='.$getVersion.'&test='.urlencode($line['test_name']).'"> - <img src="report.png" title="View reports" border="0" /></a></td>'; + echo format_readable_date(strtotime($line['date'])); + echo '</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++; } diff --git a/reports/parserfunc.php b/reports/parserfunc.php index 2fcbc6e..b0aa8e5 100644 --- a/reports/parserfunc.php +++ b/reports/parserfunc.php @@ -69,10 +69,7 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) 'expectedfail' => 'CREATE TABLE IF NOT EXISTS expectedfail ( `id` integer PRIMARY KEY AUTOINCREMENT, `id_report` bigint(20) NOT NULL, - `test_name` varchar(128) NOT NULL, - `output` STRING NOT NULL, - `diff` STRING NOT NULL, - `signature` binary(16) NOT NULL + `test_name` varchar(128) NOT NULL )', 'success' => 'CREATE TABLE IF NOT EXISTS success ( `id` integer PRIMARY KEY AUTOINCREMENT, @@ -112,10 +109,10 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) $dbi->exec($queriesCreate['success']); // patch add field success - @$dbi->exec('ALTER TABLE reports ADD COLUMN success unsigned int(10) NOT NULL'); + @$dbi->exec('ALTER TABLE reports ADD COLUMN success unsigned int(10) NOT NULL default 0'); - // handle tests with no success - if (!isset($array['succeededTest'])) $array['succeededTest'] = array(); + // handle tests with no success + if (!isset($array['succeededTest'])) $array['succeededTest'] = array(); $query = "INSERT INTO `reports` (`id`, `date`, `status`, `nb_failed`, `nb_expected_fail`, `success`, `build_env`, `phpinfo`, user_email) VALUES (null, @@ -123,7 +120,7 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) ".((int)$array['status']).", ".count($array['failedTest']).", ".count($array['expectedFailedTest']).", - ".count($array['succeededTest']).", + ".count($array['succeededTest']).", ('".$dbi->escapeString($array['buildEnvironment'])."'), ('".$dbi->escapeString($array['phpinfo'])."'), ".(!$array['userEmail'] ? "NULL" : "'".$dbi->escapeString($array['userEmail'])."'")." @@ -131,13 +128,15 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) $dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR: ".$dbi->error."\n"; + echo "ERROR: ".$dbi->lastErrorMsg()."\n"; exit; } $reportId = $dbi->lastInsertRowID(); foreach ($array['failedTest'] as $name) { + if (substr($name, 0, 1) != '/') $name = '/'.$name; + $test = $array['tests'][$name]; $query = "INSERT INTO `failed` (`id`, `id_report`, `test_name`, signature, `output`, `diff`) VALUES (null, @@ -147,35 +146,30 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting failed test : ".$dbi->error."\n"; + echo "ERROR when inserting failed test : ".$dbi->lastErrorMsg()."\n"; exit; } } foreach ($array['expectedFailedTest'] as $name) { - $test = $array['tests'][$name]; $query = "INSERT INTO `expectedfail` - (`id`, `id_report`, `test_name`, signature, `output`, `diff`) VALUES (null, - '".$reportId."', '".$name."', - X'".md5($name.'__'.$test['diff'])."', - ('".$dbi->escapeString($test['output'])."'), ('".$dbi->escapeString($test['diff'])."'))"; + (`id`, `id_report`, `test_name`) VALUES (null, '".$reportId."', '".$name."')"; @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting expected fail test : ".$dbi->error."\n"; + echo "ERROR when inserting expected fail test : ".$dbi->lastErrorMsg()."\n"; exit; } } - + foreach ($array['succeededTest'] as $name) { $test = $array['tests'][$name]; $query = "INSERT INTO `success` - (`id`, `id_report`, `test_name`) VALUES (null, - '".$reportId."', '".$name."')"; + (`id`, `id_report`, `test_name`) VALUES (null, '".$reportId."', '".$name."')"; @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting succeeded test : ".$dbi->error."\n"; + echo "ERROR when inserting succeeded test : ".$dbi->lastErrorMsg()."\n"; exit; } } @@ -188,12 +182,28 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) return true; } -function parse_phpmaketest($version, $status, $file) +/** + * Parse raw data from 'make test' and create array + * suitable to function insertToDb_phpmaketest() + * + * @param $version string PHP version (extracted from GET in buildtest-process.php \ + * or from mail subject in mailing qa-reports) + * @param $status enum (failed|success|unknown|null) extracted from GET. Will be \ + * completed based on the raw data if not specified + * @param $file string RAW data to parse (from POST in buildtest-process.php). + * Can also handle email content in mailing qa-reports + */ +function parse_phpmaketest($version, $status=null, $file) { $extract = array(); $extract['version'] = $version; - $extract['status'] = $status; + + if (in_array($status, array('failed', 'success', 'unknown'))) + $extract['status'] = $status; + else + $extract['status'] = null; + $extract['userEmail'] = null; $extract['date'] = time(); @@ -312,5 +322,13 @@ function parse_phpmaketest($version, $status, $file) $extract['buildEnvironment'] = trim(preg_replace('@^={1,}\s+@', '', $extract['buildEnvironment'])); $extract['buildEnvironment'] = preg_replace('@={1,}$@', '', trim($extract['buildEnvironment'])); + // define status if not set + if ($extract['status'] === null) { + if (isset($extract['failedTest']) && count($extract['failedTest']) > 0) + $extract['status'] = 'failed'; + else + $extract['status'] = 'success'; + } + return $extract; } diff --git a/reports/test-insert.php b/reports/test-insert.php index a045a56..83597a0 100644 --- a/reports/test-insert.php +++ b/reports/test-insert.php @@ -150,6 +150,20 @@ if (count($sqlFailed) == 33) { var_dump($sqlFailed); } +// expected fail +$query = 'SELECT count(*) FROM expectedfail WHERE id_report = '.$sqlReport['id']; +$q = $database->query($query); +list($nbExpected) = $q->fetchArray(); + +printf("%-30s", "Found 17 expectedFailedTests"); +if ($nbExpected == 17) { + echo " <font color='green'>OK</font> \n"; +} else { + echo " <font color='red'>KO (found: ".$nbExpected.")</font> \n"; +} + + + printf("%-30s", "specific test diff"); $strlen = strlen($sqlFailed['/tests/func/010.phpt']['diff']); if (isset($sqlFailed['/tests/func/010.phpt']['diff']) && $strlen >= 290 ) @@ -183,6 +197,7 @@ $database->close(); $database = new SQLite3($dbFile, SQLITE3_OPEN_READWRITE) or exit('cannot open DB to remove test'); $database->exec('DELETE FROM failed WHERE id_report = '.$sqlReport['id']); +$database->exec('DELETE FROM expectedfail WHERE id_report = '.$sqlReport['id']); $database->exec('DELETE FROM reports WHERE id = '.$sqlReport['id']); $database->close(); echo "<b>Cleanup done</b>";
487e7823fbfe185a67e2c6c71489be62d534e146 diff --git a/reports/index.php b/reports/index.php index ba7492f..48e328e 100644 --- a/reports/index.php +++ b/reports/index.php @@ -49,6 +49,20 @@ if (isset($_GET['version'])) { die("Error opening DB file: ".$database->lastErrorMsg()); } $failedTestsArray = array(); + + // Do we add expected failed ? + if (!isset($_GET['noexpect']) || $_GET['noexpect'] == 0) { + $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; + $q = @$database->query($query); + if ($q) { + while ($tab = $q->fetchArray(SQLITE3_ASSOC)) { + $failedTestsArray[] = $tab; + } + } + } + $query = 'SELECT test_name,COUNT(failed.id) as cpt,COUNT(DISTINCT diff) as variations, datetime(date) as date FROM failed,reports WHERE failed.id_report = reports.id GROUP BY test_name ORDER BY cpt DESC LIMIT ' . $limit; @@ -125,7 +139,23 @@ foreach ($reportsPerVersion as $version => $line) { padding: 3px; } </style> -<table id="testList" class="sortable" style="width: 800px; border-collapse: collapse"> +<script type="text/javascript"> +<!-- +function changeExpect() +{ + var check = document.getElementById('noexpect').checked; + if (check == true) { + document.location.href = '?version=<?php echo $_GET['version']; ?>'; + } else { + document.location.href = '?version=<?php echo $_GET['version']; ?>&noexpect=1'; + } +} +// -> +</script> +<input type="checkbox" id="noexpect" onClick="javascript:changeExpect()" +<?php if (!isset($_GET['noexpect'])) echo ' checked'; ?> /><small>Show XFAIL</small><br /> + +<table id="testList" class="sortable" style="margin-top:10px; width: 800px; border-collapse: collapse"> <thead> <tr> <th>Test name</th> @@ -140,18 +170,23 @@ foreach ($reportsPerVersion as $version => $line) { $i = 0; $maxReportDate = 0; foreach ($failedTestsArray as $line) { - if ($maxReportDate < strtotime($line['date'])) $maxReportDate = strtotime($line['date']); - + if ($maxReportDate < strtotime($line['date'])) $maxReportDate = strtotime($line['date']); echo ' <tr '; if ($i % 2) echo 'style="background-color: #ffcc66" '; - echo '><td>'.$line['test_name'].'</td>'; + 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>'; - echo '<td><a href="viewreports.php?version='.$getVersion.'&test='.urlencode($line['test_name']).'"> - <img src="report.png" title="View reports" border="0" /></a></td>'; + echo format_readable_date(strtotime($line['date'])); + echo '</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++; } diff --git a/reports/parserfunc.php b/reports/parserfunc.php index 2fcbc6e..b0aa8e5 100644 --- a/reports/parserfunc.php +++ b/reports/parserfunc.php @@ -69,10 +69,7 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) 'expectedfail' => 'CREATE TABLE IF NOT EXISTS expectedfail ( `id` integer PRIMARY KEY AUTOINCREMENT, `id_report` bigint(20) NOT NULL, - `test_name` varchar(128) NOT NULL, - `output` STRING NOT NULL, - `diff` STRING NOT NULL, - `signature` binary(16) NOT NULL + `test_name` varchar(128) NOT NULL )', 'success' => 'CREATE TABLE IF NOT EXISTS success ( `id` integer PRIMARY KEY AUTOINCREMENT, @@ -112,10 +109,10 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) $dbi->exec($queriesCreate['success']); // patch add field success - @$dbi->exec('ALTER TABLE reports ADD COLUMN success unsigned int(10) NOT NULL'); + @$dbi->exec('ALTER TABLE reports ADD COLUMN success unsigned int(10) NOT NULL default 0'); - // handle tests with no success - if (!isset($array['succeededTest'])) $array['succeededTest'] = array(); + // handle tests with no success + if (!isset($array['succeededTest'])) $array['succeededTest'] = array(); $query = "INSERT INTO `reports` (`id`, `date`, `status`, `nb_failed`, `nb_expected_fail`, `success`, `build_env`, `phpinfo`, user_email) VALUES (null, @@ -123,7 +120,7 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) ".((int)$array['status']).", ".count($array['failedTest']).", ".count($array['expectedFailedTest']).", - ".count($array['succeededTest']).", + ".count($array['succeededTest']).", ('".$dbi->escapeString($array['buildEnvironment'])."'), ('".$dbi->escapeString($array['phpinfo'])."'), ".(!$array['userEmail'] ? "NULL" : "'".$dbi->escapeString($array['userEmail'])."'")." @@ -131,13 +128,15 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) $dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR: ".$dbi->error."\n"; + echo "ERROR: ".$dbi->lastErrorMsg()."\n"; exit; } $reportId = $dbi->lastInsertRowID(); foreach ($array['failedTest'] as $name) { + if (substr($name, 0, 1) != '/') $name = '/'.$name; + $test = $array['tests'][$name]; $query = "INSERT INTO `failed` (`id`, `id_report`, `test_name`, signature, `output`, `diff`) VALUES (null, @@ -147,35 +146,30 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting failed test : ".$dbi->error."\n"; + echo "ERROR when inserting failed test : ".$dbi->lastErrorMsg()."\n"; exit; } } foreach ($array['expectedFailedTest'] as $name) { - $test = $array['tests'][$name]; $query = "INSERT INTO `expectedfail` - (`id`, `id_report`, `test_name`, signature, `output`, `diff`) VALUES (null, - '".$reportId."', '".$name."', - X'".md5($name.'__'.$test['diff'])."', - ('".$dbi->escapeString($test['output'])."'), ('".$dbi->escapeString($test['diff'])."'))"; + (`id`, `id_report`, `test_name`) VALUES (null, '".$reportId."', '".$name."')"; @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting expected fail test : ".$dbi->error."\n"; + echo "ERROR when inserting expected fail test : ".$dbi->lastErrorMsg()."\n"; exit; } } - + foreach ($array['succeededTest'] as $name) { $test = $array['tests'][$name]; $query = "INSERT INTO `success` - (`id`, `id_report`, `test_name`) VALUES (null, - '".$reportId."', '".$name."')"; + (`id`, `id_report`, `test_name`) VALUES (null, '".$reportId."', '".$name."')"; @$dbi->query($query); if ($dbi->lastErrorCode() != '') { - echo "ERROR when inserting succeeded test : ".$dbi->error."\n"; + echo "ERROR when inserting succeeded test : ".$dbi->lastErrorMsg()."\n"; exit; } } @@ -188,12 +182,28 @@ function insertToDb_phpmaketest($array, $QA_RELEASES = array()) return true; } -function parse_phpmaketest($version, $status, $file) +/** + * Parse raw data from 'make test' and create array + * suitable to function insertToDb_phpmaketest() + * + * @param $version string PHP version (extracted from GET in buildtest-process.php \ + * or from mail subject in mailing qa-reports) + * @param $status enum (failed|success|unknown|null) extracted from GET. Will be \ + * completed based on the raw data if not specified + * @param $file string RAW data to parse (from POST in buildtest-process.php). + * Can also handle email content in mailing qa-reports + */ +function parse_phpmaketest($version, $status=null, $file) { $extract = array(); $extract['version'] = $version; - $extract['status'] = $status; + + if (in_array($status, array('failed', 'success', 'unknown'))) + $extract['status'] = $status; + else + $extract['status'] = null; + $extract['userEmail'] = null; $extract['date'] = time(); @@ -312,5 +322,13 @@ function parse_phpmaketest($version, $status, $file) $extract['buildEnvironment'] = trim(preg_replace('@^={1,}\s+@', '', $extract['buildEnvironment'])); $extract['buildEnvironment'] = preg_replace('@={1,}$@', '', trim($extract['buildEnvironment'])); + // define status if not set + if ($extract['status'] === null) { + if (isset($extract['failedTest']) && count($extract['failedTest']) > 0) + $extract['status'] = 'failed'; + else + $extract['status'] = 'success'; + } + return $extract; } diff --git a/reports/test-insert.php b/reports/test-insert.php index a045a56..83597a0 100644 --- a/reports/test-insert.php +++ b/reports/test-insert.php @@ -150,6 +150,20 @@ if (count($sqlFailed) == 33) { var_dump($sqlFailed); } +// expected fail +$query = 'SELECT count(*) FROM expectedfail WHERE id_report = '.$sqlReport['id']; +$q = $database->query($query); +list($nbExpected) = $q->fetchArray(); + +printf("%-30s", "Found 17 expectedFailedTests"); +if ($nbExpected == 17) { + echo " <font color='green'>OK</font> \n"; +} else { + echo " <font color='red'>KO (found: ".$nbExpected.")</font> \n"; +} + + + printf("%-30s", "specific test diff"); $strlen = strlen($sqlFailed['/tests/func/010.phpt']['diff']); if (isset($sqlFailed['/tests/func/010.phpt']['diff']) && $strlen >= 290 ) @@ -183,6 +197,7 @@ $database->close(); $database = new SQLite3($dbFile, SQLITE3_OPEN_READWRITE) or exit('cannot open DB to remove test'); $database->exec('DELETE FROM failed WHERE id_report = '.$sqlReport['id']); +$database->exec('DELETE FROM expectedfail WHERE id_report = '.$sqlReport['id']); $database->exec('DELETE FROM reports WHERE id = '.$sqlReport['id']); $database->close(); echo "<b>Cleanup done</b>";