本文整理汇总了PHP中Build::GetNumberOfErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Build::GetNumberOfErrors方法的具体用法?PHP Build::GetNumberOfErrors怎么用?PHP Build::GetNumberOfErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Build
的用法示例。
在下文中一共展示了Build::GetNumberOfErrors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_email_errors
/** Check for errors for a given build. Return false if no errors */
function check_email_errors($buildid, $checktesttimeingchanged, $testtimemaxstatus, $checkpreviouserrors)
{
// Includes
require_once 'models/buildconfigure.php';
require_once 'models/build.php';
require_once 'models/buildtest.php';
require_once 'models/dynamicanalysis.php';
$errors = array();
$errors['errors'] = true;
$errors['hasfixes'] = false;
// Configure errors
$BuildConfigure = new BuildConfigure();
$BuildConfigure->BuildId = $buildid;
$errors['configure_errors'] = $BuildConfigure->ComputeErrors();
// Build errors and warnings
$Build = new Build();
$Build->Id = $buildid;
$Build->FillFromId($buildid);
$errors['build_errors'] = $Build->GetNumberOfErrors();
$errors['build_warnings'] = $Build->GetNumberOfWarnings();
// Test errors
$BuildTest = new BuildTest();
$BuildTest->BuildId = $buildid;
$errors['test_errors'] = $BuildTest->GetNumberOfFailures($checktesttimeingchanged, $testtimemaxstatus);
// Dynamic analysis errors
$DynamicAnalysis = new DynamicAnalysis();
$DynamicAnalysis->BuildId = $buildid;
$errors['dynamicanalysis_errors'] = $DynamicAnalysis->GetNumberOfErrors();
// Green build we return
if ($errors['configure_errors'] == 0 && $errors['build_errors'] == 0 && $errors['build_warnings'] == 0 && $errors['test_errors'] == 0 && $errors['dynamicanalysis_errors'] == 0) {
$errors['errors'] = false;
}
// look for the previous build
$previousbuildid = $Build->GetPreviousBuildId();
if ($previousbuildid > 0) {
$error_differences = $Build->GetErrorDifferences($buildid);
if ($errors['errors'] && $checkpreviouserrors && $errors['dynamicanalysis_errors'] == 0) {
// If the builderroddiff positive and configureerrordiff and testdiff positive are zero we don't send an email
// we don't send any emails
if ($error_differences['buildwarningspositive'] <= 0 && $error_differences['builderrorspositive'] <= 0 && $error_differences['configurewarnings'] <= 0 && $error_differences['configureerrors'] <= 0 && $error_differences['testfailedpositive'] <= 0 && $error_differences['testnotrunpositive'] <= 0) {
$errors['errors'] = false;
}
}
if ($error_differences['buildwarningsnegative'] > 0 || $error_differences['builderrorsnegative'] > 0 || $error_differences['configurewarnings'] < 0 || $error_differences['configureerrors'] < 0 || $error_differences['testfailednegative'] > 0 || $error_differences['testnotrunnegative'] > 0) {
$errors['hasfixes'] = true;
$errors['fixes']['configure_fixes'] = $error_differences['configurewarnings'] + $error_differences['configureerrors'];
$errors['fixes']['builderror_fixes'] = $error_differences['builderrorsnegative'];
$errors['fixes']['buildwarning_fixes'] = $error_differences['buildwarningsnegative'];
$errors['fixes']['test_fixes'] = $error_differences['testfailednegative'] + $error_differences['testnotrunnegative'];
}
}
return $errors;
}
示例2: ReportLastBuild
/** Report statistics about the last build */
function ReportLastBuild($type, $projectid, $siteid, $projectname, $nightlytime)
{
$xml = "<" . strtolower($type) . ">";
$nightlytime = strtotime($nightlytime);
// Find the last build
$build = pdo_query("SELECT starttime,id FROM build WHERE siteid='{$siteid}' AND projectid='{$projectid}' AND type='{$type}' ORDER BY submittime DESC LIMIT 1");
if (pdo_num_rows($build) > 0) {
$build_array = pdo_fetch_array($build);
$buildid = $build_array["id"];
// Express the date in terms of days (makes more sens)
$buildtime = strtotime($build_array["starttime"] . " UTC");
$builddate = $buildtime;
if (date(FMT_TIME, $buildtime) > date(FMT_TIME, $nightlytime)) {
$builddate += 3600 * 24;
//next day
}
if (date(FMT_TIME, $nightlytime) < '12:00:00') {
$builddate -= 3600 * 24;
// previous date
}
$date = date(FMT_DATE, $builddate);
$days = (time() - strtotime($date)) / (3600 * 24);
if ($days < 1) {
$day = "today";
} else {
if ($days > 1 && $days < 2) {
$day = "yesterday";
} else {
$day = round($days) . " days";
}
}
$xml .= add_XML_value("date", $day);
$xml .= add_XML_value("datelink", "index.php?project=" . urlencode($projectname) . "&date=" . $date);
// Configure
$configure = pdo_query("SELECT status FROM configure WHERE buildid='{$buildid}'");
if (pdo_num_rows($configure) > 0) {
$configure_array = pdo_fetch_array($configure);
$xml .= add_XML_value("configure", $configure_array["status"]);
if ($configure_array["status"] != 0) {
$xml .= add_XML_value("configureclass", "error");
} else {
$xml .= add_XML_value("configureclass", "normal");
}
} else {
$xml .= add_XML_value("configure", "-");
$xml .= add_XML_value("configureclass", "normal");
}
// Update
$update = pdo_query("SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=" . $buildid);
$nupdates = pdo_num_rows($update);
$xml .= add_XML_value("update", $nupdates);
// Find locally modified files
$updatelocal = pdo_query("SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=" . $buildid . " AND uf.author='Local User'");
// Set the color
if (pdo_num_rows($updatelocal) > 0) {
$xml .= add_XML_value("updateclass", "error");
} else {
$xml .= add_XML_value("updateclass", "normal");
}
// Find the number of errors and warnings
$Build = new Build();
$Build->Id = $buildid;
$nerrors = $Build->GetNumberOfErrors();
$xml .= add_XML_value("error", $nerrors);
$nwarnings = $Build->GetNumberOfWarnings();
$xml .= add_XML_value("warning", $nwarnings);
// Set the color
if ($nerrors > 0) {
$xml .= add_XML_value("errorclass", "error");
} else {
if ($nwarnings > 0) {
$xml .= add_XML_value("errorclass", "warning");
} else {
$xml .= add_XML_value("errorclass", "normal");
}
}
// Find the test
$nnotrun = $Build->GetNumberOfNotRunTests();
$nfail = $Build->GetNumberOfFailedTests();
// Display the failing tests then the not run
if ($nfail > 0) {
$xml .= add_XML_value("testfail", $nfail);
$xml .= add_XML_value("testfailclass", "error");
} else {
if ($nnotrun > 0) {
$xml .= add_XML_value("testfail", $nnotrun);
$xml .= add_XML_value("testfailclass", "warning");
} else {
$xml .= add_XML_value("testfail", "0");
$xml .= add_XML_value("testfailclass", "normal");
}
}
$xml .= add_XML_value("NA", "0");
} else {
$xml .= add_XML_value("NA", "1");
}
$xml .= "</" . strtolower($type) . ">";
return $xml;
}
示例3: testBuildModel
function testBuildModel()
{
$this->startCodeCoverage();
$build = new Build();
$builderror = new BuildError();
$builderror->Type = 0;
$builderror->Text = 'error';
$buildwarning = new BuildError();
$buildwarning->Type = 1;
$buildwarning->Text = 'warning';
if ($build->GetName() !== false) {
$this->fail("GetName didn't return false for empty build id");
return 1;
}
if ($build->GetLabels() !== false) {
$this->fail("GetLabels didn't return false for empty build id");
return 1;
}
if ($build->GetGroup() !== false) {
$this->fail("GetGroup didn't return false for empty build id");
return 1;
}
if ($build->GetNumberOfErrors() !== false) {
$this->fail("GetNumberOfErrors didn't return false for empty build id");
return 1;
}
if ($build->GetNumberOfWarnings() !== false) {
$this->fail("GetNumberOfWarnings didn't return false for empty build id");
return 1;
}
if ($build->SetSubProject('1234') !== false) {
$this->fail("SetSubProject didn't return false for empty project id");
return 1;
}
if ($build->GetSubProjectName() !== false) {
$this->fail("GetSubProjectName didn't return false for empty build id");
return 1;
}
if ($build->GetErrorDifferences() !== false) {
$this->fail("GetErrorDifferences didn't return false for empty build id");
return 1;
}
if ($build->ComputeUpdateStatistics() !== false) {
$this->fail("ComputeUpdateStatistics didn't return false for empty build id");
return 1;
}
if ($build->ComputeDifferences() !== false) {
$this->fail("ComputeDifferences didn't return false for empty build id");
return 1;
}
if ($build->ComputeConfigureDifferences() !== false) {
$this->fail("ComputeConfigureDifferences didn't return false for empty build id");
return 1;
}
if ($build->ComputeTestTiming() !== false) {
$this->fail("ComputeTestTiming didn't return false for empty build id");
return 1;
}
if ($build->InsertLabelAssociations() !== false) {
$this->fail("InsertLabelAssocations didn't return false for empty build id");
return 1;
}
if ($build->UpdateEndTime('2010-08-07') !== false) {
$this->fail("UpdateEndTime didn't return false for empty build id");
return 1;
}
if ($build->SaveTotalTestsTime('100') !== false) {
$this->fail("SaveTotalTestsTime didn't return false for empty build id");
return 1;
}
$build->Id = '1';
if ($build->ComputeTestTiming() !== false) {
$this->fail("ComputeTestTiming didn't return false for empty project id");
return 1;
}
if ($build->ComputeUpdateStatistics() !== false) {
$this->fail("ComputeUpdateStatistics didn't return false for empty project id");
return 1;
}
$build->ProjectId = '2';
$build->SiteId = '1';
$build->SetSubProject('8567');
if (strpos(file_get_contents($this->logfilename), "New subproject detected") === false) {
$this->fail("'New subproject detected' not found in log after calling SetSubProject for invalid subproject id");
return 1;
}
if ($build->Exists() == false) {
$this->fail("Exists returned false for a valid build id");
return 1;
}
$build->Id = '98765';
$build->SetStamp('20100610-1901-Experimental');
$build->Type = '';
//force this empty for coverage purposes
$build->StartTime = '2009-12-18 14:19:11';
$build->EndTime = '2009-12-18 14:20:23';
$build->SubmitTime = '2012-01-25 16:43:11';
if ($build->Exists() == true) {
$this->fail("Exists returned true for an invalid build id");
return 1;
//.........这里部分代码省略.........
示例4: ReportLastBuild
/** Report statistics about the last build */
function ReportLastBuild($type, $projectid, $siteid, $projectname, $nightlytime)
{
$xml = '<' . strtolower($type) . '>';
$nightlytime = strtotime($nightlytime);
// Find the last build
$build = pdo_query("SELECT starttime,id FROM build WHERE siteid='{$siteid}' AND projectid='{$projectid}' AND type='{$type}' ORDER BY submittime DESC LIMIT 1");
if (pdo_num_rows($build) > 0) {
$build_array = pdo_fetch_array($build);
$buildid = $build_array['id'];
// Express the date in terms of days (makes more sens)
$buildtime = strtotime($build_array['starttime'] . ' UTC');
$builddate = $buildtime;
if (date(FMT_TIME, $buildtime) > date(FMT_TIME, $nightlytime)) {
$builddate += 3600 * 24;
//next day
}
if (date(FMT_TIME, $nightlytime) < '12:00:00') {
$builddate -= 3600 * 24;
// previous date
}
$date = date(FMT_DATE, $builddate);
$days = (time() - strtotime($date)) / (3600 * 24);
if ($days < 1) {
$day = 'today';
} elseif ($days > 1 && $days < 2) {
$day = 'yesterday';
} else {
$day = round($days) . ' days';
}
$xml .= add_XML_value('date', $day);
$xml .= add_XML_value('datelink', 'index.php?project=' . urlencode($projectname) . '&date=' . $date);
// Configure
$configure = pdo_query("SELECT status FROM configure WHERE buildid='{$buildid}'");
if (pdo_num_rows($configure) > 0) {
$configure_array = pdo_fetch_array($configure);
$xml .= add_XML_value('configure', $configure_array['status']);
if ($configure_array['status'] != 0) {
$xml .= add_XML_value('configureclass', 'error');
} else {
$xml .= add_XML_value('configureclass', 'normal');
}
} else {
$xml .= add_XML_value('configure', '-');
$xml .= add_XML_value('configureclass', 'normal');
}
// Update
$update = pdo_query('SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=' . $buildid);
$nupdates = pdo_num_rows($update);
$xml .= add_XML_value('update', $nupdates);
// Find locally modified files
$updatelocal = pdo_query('SELECT uf.updateid FROM updatefile AS uf,build2update AS b2u WHERE uf.updateid=b2u.updateid AND b2u.buildid=' . $buildid . " AND uf.author='Local User'");
// Set the color
if (pdo_num_rows($updatelocal) > 0) {
$xml .= add_XML_value('updateclass', 'error');
} else {
$xml .= add_XML_value('updateclass', 'normal');
}
// Find the number of errors and warnings
$Build = new Build();
$Build->Id = $buildid;
$nerrors = $Build->GetNumberOfErrors();
$xml .= add_XML_value('error', $nerrors);
$nwarnings = $Build->GetNumberOfWarnings();
$xml .= add_XML_value('warning', $nwarnings);
// Set the color
if ($nerrors > 0) {
$xml .= add_XML_value('errorclass', 'error');
} elseif ($nwarnings > 0) {
$xml .= add_XML_value('errorclass', 'warning');
} else {
$xml .= add_XML_value('errorclass', 'normal');
}
// Find the test
$nnotrun = $Build->GetNumberOfNotRunTests();
$nfail = $Build->GetNumberOfFailedTests();
// Display the failing tests then the not run
if ($nfail > 0) {
$xml .= add_XML_value('testfail', $nfail);
$xml .= add_XML_value('testfailclass', 'error');
} elseif ($nnotrun > 0) {
$xml .= add_XML_value('testfail', $nnotrun);
$xml .= add_XML_value('testfailclass', 'warning');
} else {
$xml .= add_XML_value('testfail', '0');
$xml .= add_XML_value('testfailclass', 'normal');
}
$xml .= add_XML_value('NA', '0');
} else {
$xml .= add_XML_value('NA', '1');
}
$xml .= '</' . strtolower($type) . '>';
return $xml;
}
示例5: ComputeUpdateStatistics
/** Compute the user statistics */
public function ComputeUpdateStatistics()
{
if (!$this->Id) {
add_log('Id is not set', 'Build::ComputeUpdateStatistics', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id);
return false;
}
if (!$this->ProjectId) {
add_log('ProjectId is not set', 'Build::ComputeUpdateStatistics', LOG_ERR, 0, $this->Id);
return false;
}
$previousbuildid = $this->GetPreviousBuildId();
if ($previousbuildid < 1) {
// Nothing to compare the current results against.
return false;
}
// Find how the number of errors, warnings and test failures have changed.
$previousbuild = new Build();
$previousbuild->Id = $previousbuildid;
$errordiff = $this->GetNumberOfErrors() - $previousbuild->GetNumberOfErrors();
$warningdiff = $this->GetNumberOfWarnings() - $previousbuild->GetNumberOfWarnings();
$testdiff = $this->GetNumberOfFailedTests() + $this->GetNumberOfNotRunTests() - ($previousbuild->GetNumberOfFailedTests() + $previousbuild->GetNumberOfNotRunTests());
// Find the number of authors that contributed to this changeset.
$pdo = get_link_identifier()->getPdo();
$nauthors_stmt = $pdo->prepare('SELECT count(author) FROM
(SELECT uf.author FROM updatefile AS uf
JOIN build2update AS b2u ON (b2u.updateid=uf.updateid)
WHERE b2u.buildid=? GROUP BY author)
AS test');
$nauthors_stmt->execute(array($this->Id));
$nauthors_array = $nauthors_stmt->fetch();
$nauthors = $nauthors_array[0];
$newbuild = 1;
$previousauthor = '';
// Record user statistics for each updated file.
$updatefiles_stmt = $pdo->prepare("SELECT author,email,checkindate,filename FROM updatefile AS uf\n JOIN build2update AS b2u ON b2u.updateid=uf.updateid\n WHERE b2u.buildid=? AND checkindate>'1980-01-01T00:00:00'\n ORDER BY author ASC, checkindate ASC");
$updatefiles_stmt->execute(array($this->Id));
add_last_sql_error('Build:ComputeUpdateStatistics', $this->ProjectId, $this->Id);
while ($updatefiles_array = $updatefiles_stmt->fetch()) {
$checkindate = $updatefiles_array['checkindate'];
$author = $updatefiles_array['author'];
$filename = $updatefiles_array['filename'];
$email = $updatefiles_array['email'];
$warnings = 0;
$errors = 0;
$tests = 0;
if ($author != $previousauthor) {
$newbuild = 1;
}
$previousauthor = $author;
if ($warningdiff > 1) {
$warnings = $this->FindRealErrors('WARNING', $author, $this->Id, $filename);
} elseif ($warningdiff < 0) {
$warnings = $this->FindRealErrors('WARNING', $author, $previousbuildid, $filename) * -1;
}
if ($errordiff > 1) {
$errors = $this->FindRealErrors('ERROR', $author, $this->Id, $filename);
} elseif ($errordiff < 0) {
$errors = $this->FindRealErrors('ERROR', $author, $previousbuildid, $filename) * -1;
}
if ($nauthors > 1) {
// When multiple authors contribute to a changeset it is
// too difficult to determine which modified file caused a
// change in test behavior.
$tests = 0;
} else {
$tests = $testdiff;
}
$this->AddUpdateStatistics($author, $email, $checkindate, $newbuild, $warnings, $errors, $tests);
$warningdiff -= $warnings;
$errordiff -= $errors;
$testdiff -= $tests;
$newbuild = 0;
}
return true;
}