示例#1
0
$xml .= get_cdash_dashboard_xml_by_name($projectname, $date);
// Build
$xml .= '<build>';
$build = pdo_query("SELECT * FROM build WHERE id='{$buildid}'");
$build_array = pdo_fetch_array($build);
$siteid = $build_array['siteid'];
$site_array = pdo_fetch_array(pdo_query("SELECT name FROM site WHERE id='{$siteid}'"));
$xml .= add_XML_value('site', $site_array['name']);
$xml .= add_XML_value('buildname', $build_array['name']);
$xml .= add_XML_value('buildid', $build_array['id']);
$xml .= add_XML_value('buildtime', $build_array['starttime']);
$xml .= '</build>';
// Load coverage file.
$coverageFile = new CoverageFile();
$coverageFile->Id = $fileid;
$coverageFile->Load();
$xml .= '<coverage>';
$xml .= add_XML_value('fullpath', $coverageFile->FullPath);
// Generating the html file
$file_array = explode('<br>', $coverageFile->File);
$i = 0;
// Load the coverage info.
$log = new CoverageFileLog();
$log->BuildId = $buildid;
$log->FileId = $fileid;
$log->Load();
// Detect if we have branch coverage or not.
$hasBranchCoverage = false;
if (!empty($log->Branches)) {
    $hasBranchCoverage = true;
}
示例#2
0
 /** Update the aggregate coverage build to include these results. */
 public function UpdateAggregate()
 {
     if (!$this->Build) {
         $this->Build = new Build();
         $this->Build->Id = $this->BuildId;
     }
     $this->Build->FillFromId($this->BuildId);
     // Only nightly builds count towards aggregate coverage.
     if ($this->Build->Type !== 'Nightly' || $this->Build->Name === 'Aggregate Coverage') {
         return;
     }
     // Find the build ID for this day's edition of 'Aggregate Coverage'.
     $aggregateBuildId = null;
     if ($this->AggregateBuildId) {
         if ($this->Build->SubProjectId) {
             // For SubProject builds, AggregateBuildId refers to the parent.
             // Look up the ID of the appropriate child.
             $query = "SELECT id FROM build\n                    INNER JOIN subproject2build AS sp2b ON (build.id=sp2b.buildid)\n                    WHERE parentid='{$this->AggregateBuildId}' AND\n                    projectid='" . $this->Build->ProjectId . "' AND\n                    sp2b.subprojectid='" . $this->Build->SubProjectId . "'";
             $row = pdo_single_row_query($query);
             if (!$row || !array_key_exists('id', $row)) {
                 // An aggregate build for this SubProject doesn't exist yet.
                 // Create it here.
                 $aggregateBuild = create_aggregate_build($this->Build);
                 $aggregateBuildId = $aggregateBuild->Id;
             } else {
                 $aggregateBuildId = $row['id'];
             }
         } else {
             // For standalone builds AggregateBuildId is exactly what we're
             // looking for.
             $aggregateBuildId = $this->AggregateBuildId;
         }
         $aggregateBuild = new Build();
         $aggregateBuild->Id = $aggregateBuildId;
         $aggregateBuild->FillFromId($aggregateBuildId);
     } else {
         // AggregateBuildId not specified, look it up here.
         $aggregateBuild = get_aggregate_build($this->Build);
         $aggregateBuildId = $aggregateBuild->Id;
         $aggregateBuild->FillFromId($aggregateBuildId);
     }
     // Abort if this log refers to a different version of the file
     // than the one already contained in the aggregate.
     $row = pdo_single_row_query("SELECT id, fullpath FROM coveragefile WHERE id='{$this->FileId}'");
     $path = $row['fullpath'];
     $row = pdo_single_row_query("SELECT id FROM coveragefile AS cf\n                INNER JOIN coveragefilelog AS cfl ON (cfl.fileid=cf.id)\n                WHERE cfl.buildid='{$aggregateBuildId}' AND cf.fullpath='{$path}'");
     if ($row && array_key_exists('id', $row) && $row['id'] != $this->FileId) {
         add_log("Not appending coverage of '{$path}' to aggregate as it " . 'already contains a different version of this file.', 'CoverageFileLog::UpdateAggregate', LOG_INFO, $this->BuildId);
         return;
     }
     // Append these results to the aggregate coverage log.
     $aggregateLog = clone $this;
     $aggregateLog->BuildId = $aggregateBuildId;
     $aggregateLog->Build = $aggregateBuild;
     $aggregateLog->Insert(true);
     // Update the aggregate coverage summary.
     $aggregateSummary = new CoverageSummary();
     $aggregateSummary->BuildId = $aggregateBuildId;
     $coverageFile = new CoverageFile();
     $coverageFile->Id = $this->FileId;
     $coverageFile->Load();
     $coverageFile->Update($aggregateBuildId);
     // Query the log to get how many lines & branches were covered.
     // We do this after inserting the filelog because we want to
     // accurately reflect the union of the current and previously
     // existing results (if any).
     $stats = $aggregateLog->GetStats();
     $aggregateCoverage = new Coverage();
     $aggregateCoverage->CoverageFile = $coverageFile;
     $aggregateCoverage->LocUntested = $stats['locuntested'];
     $aggregateCoverage->LocTested = $stats['loctested'];
     if ($aggregateCoverage->LocTested > 0 || $aggregateCoverage->LocUntested > 0) {
         $aggregateCoverage->Covered = 1;
     } else {
         $aggregateCoverage->Covered = 0;
     }
     $aggregateCoverage->BranchesUntested = $stats['branchesuntested'];
     $aggregateCoverage->BranchesTested = $stats['branchestested'];
     // Add this Coverage to the summary.
     $aggregateSummary->AddCoverage($aggregateCoverage);
     // Insert/Update the aggregate summary.
     $aggregateSummary->Insert(true);
     $aggregateSummary->ComputeDifference($this->PreviousAggregateParentId);
     if ($this->Build->SubProjectId && $this->AggregateBuildId) {
         // Compute diff for the aggregate parent too.
         $aggregateParentSummary = new CoverageSummary();
         $aggregateParentSummary->BuildId = $this->AggregateBuildId;
         $aggregateParentSummary->ComputeDifference();
     }
 }