function print_component_row($component, $rev, $old_rev) { global $DB; $uc_name = ucfirst($component); $log_title = $uc_name; $log_file = "{$component}.log"; print "<tr>"; print "<td>" . maybe_link($rev, $old_rev, $log_file, $log_title) . "</td>"; $data = $DB->query("\n\t\t\t\tSELECT\ttime_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\trevision == {$rev}\n\t\t\t\tAND\t\tcomponent == '{$component}'\n\t\t\t\t")->fetchAll(PDO::FETCH_ASSOC); if (isset($data[0])) { foreach ($data[0] as $key => $value) { if ($key == "test_date") { $value = date_from_timestamp($value); } else { if ($key == "time_taken") { $value = minutes_from_seconds($value); } } print "<td>{$value}</td>"; } } print "\n</tr>"; }
function run_main() { global $DB; $order = array("revision", "branch", "author", "pass", "fail", "skip", "timeout", "benchmark", "time_taken", "test_date", "revision_used", "failed", "redo"); foreach ($order as $header) { $headers[$header] = ucfirst(str_replace("_", " ", $header)); } $headers["revision"] = "Rev"; $headers["revision_used"] = "Test rev"; $headers["time_taken"] = "Time"; $headers["benchmark"] = "Bench"; $headers["timeout"] = "T/O"; print "<table class=info>\n"; print "<tr>\n"; foreach (array_values($headers) as $header) { print "<th>{$header}</th>\n"; } // Completed tests $query = $DB->query("\n\t\t\t\tSELECT\trevision, branch, author\n\t\t\t\tFROM\t\tcomplete\n\t\t\t\t"); $completes = $query->fetchAll(PDO::FETCH_ASSOC); // Test results $query = $DB->query("\n\t\t\t\tSELECT\trevision, pass, fail, skip, timeout\n\t\t\t\tFROM\t\ttests\n\t\t\t\tWHERE\t\ttestname == 'Total'\n\t\t\t\t"); $tests = $query->fetchAll(PDO::FETCH_ASSOC); // Benchmark results $query = $DB->query("\n\t\t\t\tSELECT\trevision, result as benchmark\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\tmetric = 'All'\n\t\t\t\t"); $benchmarks = $query->fetchAll(PDO::FETCH_ASSOC); // Compile meta-results $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'compile'\n\t\t\t\t"); $compile_meta = $query->fetchAll(PDO::FETCH_ASSOC); // Test meta-results $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'test'\n\t\t\t\t"); $test_meta = $query->fetchAll(PDO::FETCH_ASSOC); // Bench meta-results $query = $DB->query("\n\t\t\t\tSELECT\trevision, component, time_taken, test_date, revision_used, failed, redo\n\t\t\t\tFROM\t\tcomponents\n\t\t\t\tWHERE\t\tcomponent == 'benchmark'\n\t\t\t\t"); $bench_meta = $query->fetchAll(PDO::FETCH_ASSOC); $query = $DB->query("SELECT revision FROM running"); $running = $query->fetchAll(PDO::FETCH_ASSOC); $running = $running[0]["revision"]; $revisions = array_reduce(array($completes, $tests, $benchmarks, $compile_meta, $test_meta, $bench_meta), "merge_results"); ksort($revisions); # process data foreach ($revisions as $rev => &$data) { // Always use the correct branch for relative data $branch = $data["branch"]; $data["difference"] = add_difference("pass", $data, $revisions[$prev[$branch]]); add_difference("fail", $data, $revisions[$prev[$branch]]); $prev[$branch] = $rev; } $revisions = array_reverse($revisions, true); # print out rows foreach ($revisions as $rev => $data) { print "<tr>\n"; # pick a color $color = ""; if ($data["difference"] > 0) { $color = get_good_color(); } elseif ($data["difference"] < 0) { $color = get_bad_color(); } unset($data["difference"]); if ($rev == $running) { $color = get_running_color(); } # add a link to revision $data["revision"] = "<a href=\"details.php?rev={$rev}\">{$rev}</a>"; if (isset($data["test_date"])) { $data["test_date"] = date_from_timestamp($data["test_date"]); } if (isset($data["time_taken"])) { $data["time_taken"] = minutes_from_seconds($data["time_taken"]); } foreach ($order as $header) { $value = $data[$header]; print "<td {$color}>{$value}</td>\n"; } print "<a/></tr>\n"; } }