示例#1
0
 /**
  * Parse a tarball of JSON files.
  **/
 public function Parse($filename)
 {
     // Create a new directory where we can extract our tarball.
     $dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME);
     mkdir($dirName);
     // Extract the tarball.
     $result = extract_tar($filename, $dirName);
     if ($result === false) {
         add_log('Could not extract ' . $filename . ' into ' . $dirName, 'JSCoverTarHandler::Parse', LOG_ERR);
         return false;
     }
     // Recursively search for .json files and parse them.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     $coverageSummary = $this->CoverageSummaries['default'];
     foreach ($iterator as $fileinfo) {
         // need the longest extension, so getExtension() won't do here.
         $ext = substr(strstr($fileinfo->getFilename(), '.'), 1);
         if ($ext === 'json') {
             $this->ParseJSCoverFile($fileinfo);
         }
     }
     // Record parsed coverage info to the database.
     foreach ($this->CoverageFileLogs as $path => $coverageFileLog) {
         $coverage = $this->Coverages[$path];
         $coverageFile = $this->CoverageFiles[$path];
         // Tally up how many lines of code were covered & uncovered.
         foreach ($coverageFileLog->Lines as $line) {
             if ($line == 0) {
                 $coverage->LocUntested += 1;
             } else {
                 $coverage->Covered = 1;
                 $coverage->LocTested += 1;
             }
         }
         // Save these models to the database.
         $coverageFile->TrimLastNewline();
         $coverageFile->Update($this->Build->Id);
         $coverageFileLog->BuildId = $this->Build->Id;
         $coverageFileLog->FileId = $coverageFile->Id;
         $coverageFileLog->Insert();
         // Add this Coverage to our summary.
         $coverage->CoverageFile = $coverageFile;
         $coverageSummary->AddCoverage($coverage);
     }
     // Insert coverage summaries
     $completedSummaries = array();
     foreach ($this->CoverageSummaries as $coverageSummary) {
         if (in_array($coverageSummary->BuildId, $completedSummaries)) {
             continue;
         }
         $coverageSummary->Insert();
         $coverageSummary->ComputeDifference();
         $completedSummaries[] = $coverageSummary->BuildId;
     }
     // Delete the directory when we're done.
     DeleteDirectory($dirName);
     return true;
 }
示例#2
0
 /**
  * Parse a tarball of JSON files.
  **/
 public function Parse($filename)
 {
     // Create a new directory where we can extract our tarball.
     $dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME);
     mkdir($dirName);
     // Extract the tarball.
     $result = extract_tar($filename, $dirName);
     if ($result === false) {
         add_log('Could not extract ' . $filename . ' into ' . $dirName, 'JavaJSONTarHandler::Parse', LOG_ERR);
         return false;
     }
     // Check if this submission included a  package_map.json file.
     // This tells us how Java packages correspond to CDash subprojects.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == 'package_map.json') {
             $this->ParsePackageMap($fileinfo);
         }
     }
     // Recursively search for .java.json files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         // need the longest extension, so getExtension() won't do here.
         $ext = substr(strstr($fileinfo->getFilename(), '.'), 1);
         if ($ext === 'java.json') {
             $this->ParseJavaJSONFile($fileinfo);
         }
     }
     // Insert coverage summaries
     $completedSummaries = array();
     foreach ($this->CoverageSummaries as $coverageSummary) {
         if (in_array($coverageSummary->BuildId, $completedSummaries)) {
             continue;
         }
         $coverageSummary->Insert();
         $coverageSummary->ComputeDifference();
         $completedSummaries[] = $coverageSummary->BuildId;
     }
     // Delete the directory when we're done.
     DeleteDirectory($dirName);
     return true;
 }
示例#3
0
 /**
  * Parse a tarball of .gcov files.
  **/
 public function Parse($filename)
 {
     // Create a new directory where we can extract our tarball.
     $dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME);
     mkdir($dirName);
     // Extract the tarball.
     $result = extract_tar($filename, $dirName);
     if ($result === false) {
         add_log('Could not extract ' . $filename . ' into ' . $dirName, 'GCovTarHandler::Parse', LOG_ERR);
         return false;
     }
     // Find the data.json file and extract the source directory from it.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == 'data.json') {
             $jsonContents = file_get_contents($fileinfo->getRealPath());
             $jsonDecoded = json_decode($jsonContents, true);
             if (is_null($jsonDecoded) || !array_key_exists('Source', $jsonDecoded) || !array_key_exists('Binary', $jsonDecoded)) {
                 DeleteDirectory($dirName);
                 return false;
             }
             $this->SourceDirectory = $jsonDecoded['Source'];
             $this->BinaryDirectory = $jsonDecoded['Binary'];
             break;
         }
     }
     if (empty($this->SourceDirectory) || empty($this->BinaryDirectory)) {
         DeleteDirectory($dirName);
         return false;
     }
     // Check if any Labels.json files were included
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == 'Labels.json') {
             $this->ParseLabelsFile($fileinfo);
         }
     }
     // Lookup some data used during coverage aggregation.
     $this->Build->ComputeTestingDayBounds();
     if ($this->Build->Type === 'Nightly') {
         $aggregateBuild = get_aggregate_build($this->Build);
         $aggregateParentId = $aggregateBuild->GetParentId();
         if ($aggregateParentId > 0) {
             $this->AggregateBuildId = $aggregateParentId;
             $aggregateParent = new Build();
             $aggregateParent->Id = $aggregateParentId;
             $this->PreviousAggregateParentId = $aggregateParent->GetPreviousBuildId();
         } else {
             $this->AggregateBuildId = $aggregateBuild->Id;
         }
     }
     // Recursively search for .gcov files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == 'gcov') {
             $this->ParseGcovFile($fileinfo);
         }
     }
     // Search for uncovered files.
     if (file_exists("{$dirName}/uncovered")) {
         $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("{$dirName}/uncovered"), RecursiveIteratorIterator::LEAVES_ONLY);
         foreach ($iterator as $fileinfo) {
             if ($fileinfo->isFile()) {
                 // Get the path of this uncovered file relative to its
                 // source directory.
                 $relativePath = str_replace("{$dirName}/uncovered/", "./", $fileinfo);
                 $this->ParseUncoveredSourceFile($fileinfo, $relativePath);
             }
         }
     }
     // Insert coverage summary
     $this->CoverageSummary->Insert(true);
     $this->CoverageSummary->ComputeDifference();
     foreach ($this->SubProjectSummaries as $buildid => $subprojectSummary) {
         $subprojectSummary->Insert(true);
         $subprojectSummary->ComputeDifference();
     }
     // Delete the directory when we're done.
     DeleteDirectory($dirName);
     return true;
 }
示例#4
0
function doStep3()
{
    global $txt;
    $chmod =& $_SESSION['webinstall_state']['chmod'];
    if (ini_get('memory_limit') < 64) {
        ini_set('memory_limit', '64M');
    }
    foreach ($_SESSION['webinstall_state']['files_to_download'] as $i => $file) {
        if ($i < $_GET['substep']) {
            continue;
        }
        $fp = fopen(dirname(__FILE__) . '/smf_install' . $i . '.tmp', 'rb');
        $data = '';
        while (!feof($fp)) {
            $data .= fread($fp, 4096);
        }
        fclose($fp);
        if (!empty($_SESSION['installer_temp_ftp'])) {
            $ftp = new ftp_connection($_SESSION['installer_temp_ftp']['server'], $_SESSION['installer_temp_ftp']['port'], $_SESSION['installer_temp_ftp']['username'], $_SESSION['installer_temp_ftp']['password']);
            $ftp->chdir($_SESSION['installer_temp_ftp']['path']);
            extract_tar($data, dirname(__FILE__), $ftp);
            $ftp->unlink('smf_install' . $i . '.tmp');
            $ftp->close();
        } else {
            extract_tar($data, dirname(__FILE__), null);
            unlink('smf_install' . $i . '.tmp');
        }
        if ($i < $_SESSION['webinstall_state']['files_to_download_total'] - 1) {
            $query_string = '?step=3&substep=' . ($i + 1);
            $percent_done_total = round(($i + 1) / $_SESSION['webinstall_state']['files_to_download_total'] * 100, 2);
            // Pausing time!
            echo '
				<div class="panel">
					<h2 style="margin-top: 2ex;">', $txt['not_done_yet'], '</h2>
					<h3>', $txt['extraction_paused'], '</h3>

					<div style="padding-left: 20%; padding-right: 20%; margin-top: 1ex;">
						<strong>', $txt['extraction_progress'], ':</strong>
						<div style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
							<div style="padding-top: 1pt; width: 100%; z-index: 2; color: black; position: absolute; text-align: center; font-weight: bold;">', $percent_done_total, '%</div>
							<div style="width: ', $percent_done_total, '%; height: 12pt; z-index: 1; background-color: red;">&nbsp;</div>
						</div>
					</div>
					<form action="', $_SERVER['PHP_SELF'], $query_string, '" method="post" name="autoSubmit">
						<div class="righttext" style="margin: 1ex;"><input name="b" type="submit" value="', $txt['continue'], '" /></div>
					</form>
					<script type="text/javascript"><!-- // --><![CDATA[
						window.onload = doAutoSubmit;
						var countdown = 3;

						function doAutoSubmit()
						{
							if (countdown == 0)
								document.autoSubmit.submit();
							else if (countdown == -1)
								return;

							document.autoSubmit.b.value = "', $txt['continue'], ' (" + countdown + ")";
							countdown--;

							setTimeout(doAutoSubmit, 1000);
						}
					// ]]></script>
				</div>';
            return true;
        }
    }
    $_SESSION['webinstall_state']['files_to_download'] = array();
    if (file_exists(dirname(__FILE__) . '/install.php')) {
        header('Location: http://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/install.php');
        exit;
    } elseif (file_exists(dirname(__FILE__) . '/upgrade.php')) {
        header('Location: http://' . (empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']) . (strtr(dirname($_SERVER['PHP_SELF']), '\\', '/') == '/' ? '' : strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')) . '/upgrade.php');
        exit;
    }
    echo '
				<div class="panel">
					<h2>', $txt['extraction_complete'], '</h2>
					<h3>', $txt['extraction_complete_info'], '</h3>

					<form action="', strtr(dirname($_SERVER['PHP_SELF']), array(basename(__FILE__) => 'install.php')), '" method="post">
						<div class="righttext" style="margin: 1ex;"><input type="submit" value="', $txt['continue'], '" /></div>
					</form>
				</div>';
    unset($_SESSION['webinstall_state']);
    return true;
}