Beispiel #1
0
 /**
  * Parse a tarball of .gcov files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // 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);
         }
     }
     // Recursively search for .gcov files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == "gcov") {
             $this->ParseGcovFile($fileinfo);
         }
     }
     // Insert coverage summary (removing any old results first)
     //$this->CoverageSummary->RemoveAll();
     $this->CoverageSummary->Insert();
     $this->CoverageSummary->ComputeDifference();
     // Delete the directory when we're done.
     DeleteDirectory($dirName);
     return true;
 }
Beispiel #2
0
 /**
  * Parse a tarball of JSON files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // Check if this submission included a  package_map.json file.
     // This tells us how Java packages correspond to CDash subprojects.
     $mapFound = false;
     $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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
function DeleteDirectory($path)
{
    if (substr($path, -1) == "/") {
        $path = substr($path, 0, -1);
    }
    $dir = opendir($path);
    if ($dir) {
        while (($file = readdir($dir)) !== false) {
            if ($file != "." && $file != "..") {
                if (is_link($path . "/" . $file) || is_file($path . "/" . $file)) {
                    unlink($path . "/" . $file);
                } else {
                    DeleteDirectory($path . "/" . $file);
                    rmdir($path . "/" . $file);
                }
            }
        }
        closedir($dir);
    }
}
function DeleteDirectory($dir)
{
    if (is_dir($dir) && $dir != ".svn") {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..' && $file != '.svn') {
                    if (is_dir($dir . '/' . $file)) {
                        echo '<br/>DIR - ' . $dir . '/' . $file;
                        // On supprime le contenu du dossier
                        DeleteDirectory($dir . '/' . $file);
                        // On supprime le dossier
                        rmdir($dir . '/' . $file);
                    } else {
                        echo '<br/>FIL - ' . $dir . '/' . $file;
                        if (is_file($dir . '/' . $file)) {
                            unlink($dir . '/' . $file);
                        }
                    }
                }
            }
            closedir($dh);
        }
    }
}
function DeleteDirectory($dir)
{
    if (is_dir($dir) && $dir != ".svn") {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
                if ($file != '.' && $file != '..' && $file != '.svn') {
                    if (is_dir($dir . '/' . $file)) {
                        echo '<br/>DIR - ' . $dir . '/' . $file;
                        // We delete the directory content
                        DeleteDirectory($dir . '/' . $file);
                        // We delete the directory
                        rmdir($dir . '/' . $file);
                    } else {
                        echo '<br/>FIL - ' . $dir . '/' . $file;
                        if (is_file($dir . '/' . $file)) {
                            unlink($dir . '/' . $file);
                        }
                    }
                }
            }
            closedir($dh);
        }
    }
}
Beispiel #7
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;
 }
/**
 * Deletes a complete directory with its contents (recursive)
 *
 * @param          string $sourcedir
 * @access         private
 * @return         array
 * @author Alexander Mieland
 * @copyright 2000- by Alexander 'dma147' Mieland
 */
function apcms_DeleteDirectory($sourcedir)
{
    if (!is_dir($sourcedir)) {
        return unlink($sourcedir);
    }
    $filearray = array();
    $sourcedir .= "/";
    $handle = @opendir($sourcedir);
    while ($eintrag = @readdir($handle)) {
        $target = $sourcedir . $eintrag;
        if (is_dir($target) && $eintrag != "." && $eintrag != "..") {
            @unlink($target);
            $slashpos = strrpos($target, "/");
            if ($slashpos) {
                $deldir = substr($target, 0, $slashpos);
                @rmdir($deldir);
            }
            $filearray[$target] = DeleteDirectory($target);
            @unlink($target);
            $slashpos = strrpos($target, "/");
            if ($slashpos) {
                $deldir = substr($target, 0, $slashpos);
                @rmdir($deldir);
            }
        } elseif ($eintrag != "." && $eintrag != "..") {
            $filearray[] = $eintrag;
            @unlink($target);
            $slashpos = strrpos($target, "/");
            if ($slashpos) {
                $deldir = substr($target, 0, $slashpos);
                @rmdir($deldir);
            }
        }
    }
    @closedir($handle);
    return $filearray;
}
Beispiel #9
0
 /**
  * Parse a tarball of JSON files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // 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;
                 $coverageSummary->LocUntested += 1;
             } else {
                 $coverage->Covered = 1;
                 $coverage->LocTested += 1;
                 $coverageSummary->LocTested += 1;
             }
         }
         // Save these models to the database.
         $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;
 }
Beispiel #10
0
require_once $rootpath . "/functions.php";
$srcpath = $rootpath . "/repos";
$destpath = $rootpath . "/src";
if (!is_dir($srcpath)) {
    mkdir($srcpath);
}
if (!is_dir($destpath)) {
    mkdir($destpath);
}
// Update the registered repo list.  If nothing has changed, exit.
$numchanged = (int) GitRepoChanged($rootpath) + GitPull($srcpath);
if (!$numchanged) {
    exit;
}
// Always do a full rebuild.
DeleteDirectory($destpath);
// Retrieve a list of all PHP files that contain 'class' + a name.
$files = array();
GetPHPFiles($files, $srcpath);
// Generate final file set.
foreach ($files as $name => $filename) {
    $data = file_get_contents($filename);
    // Remove standard inclusion lines so that the autoloader does its thing.
    $lines = explode("\n", $data);
    foreach ($lines as $num => $line) {
        $line = trim($line);
        if (substr($line, 0, 18) === "if (!class_exists(") {
            $lines[$num] = "";
        }
    }
    $data = implode("\n", $lines);
Beispiel #11
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;
 }