Beispiel #1
0
 /**
  * Parses the projects xml
  * loads all the tasks
  * assigns them to the builds
  *
  * @param Xinc\Core\Project\Iterator $projects
  *
  * @return array the builds
  */
 public function parseProjectOld($project)
 {
     $builds = array();
     //         $this->setters = Xinc_Plugin_Repository::getInstance()
     //             ->getTasksForSlot(Xinc_Plugin_Slot::PROJECT_SET_VALUES);
     $build = null;
     /**
      * trying to recover the last build information
      */
     try {
         $build = \Xinc\Core\Build::unserialize($project);
         $build->setBuildTime(null);
         $build->resetConfigDirective();
     } catch (Xinc_Build_Exception_NotFound $e) {
         Xinc_Logger::getInstance()->info('No status data found for ' . $project->getName());
     } catch (Exception $e) {
         Xinc_Logger::getInstance()->error('Could not unserialize old status of ' . $project->getName());
     }
     $projectXml = $project->getConfig();
     if (!$build instanceof Xinc_Build_Interface) {
         $build = new Xinc_Build($this->engine, $project);
     }
     $build->getProperties()->set('project.name', $project->getName());
     $build->getProperties()->set('build.number', $build->getNumber());
     $build->getProperties()->set('build.label', $build->getLabel());
     $builtinProps = Xinc::getInstance()->getBuiltinProperties();
     foreach ($builtinProps as $prop => $value) {
         $build->getProperties()->set($prop, $value);
     }
     $taskRegistry = new Xinc_Build_Tasks_Registry();
     $this->_parseTasks($build, $projectXml, $taskRegistry);
     $build->setTaskRegistry($taskRegistry);
     $build->process(Xinc_Plugin_Slot::PROJECT_INIT);
     if (!$build->haveScheduler()) {
         // set default scheduler
         $scheduler = new Xinc_Build_Scheduler_Default();
         $build->addScheduler($scheduler);
     }
     $labeler = $build->getLabeler();
     if ($labeler == null) {
         // set default scheduler
         $labeler = new Xinc_Build_Labeler_Default();
         $build->setLabeler($labeler);
     }
     $builds[] = $build;
     return $builds;
 }
Beispiel #2
0
 public function testBuildExceptions()
 {
     $project = new Xinc_Project();
     $project->setName('test');
     $build = new Xinc_Build(new Xinc_Engine_Sunrise(), $project);
     $buildTimestamp = time() + 1;
     $build->setBuildTime($buildTimestamp);
     $build->setStatus(Xinc_Build_Interface::INITIALIZED);
     $build->getProperties()->set('test', 1);
     //$workingDir = getcwd();
     //Xinc::getInstance()->setStatusDir($workingDir);
     try {
         $result = $build->serialize();
         $this->assertTrue(false, 'Should not serialize successfull');
     } catch (Xinc_Build_Exception_NotRun $e) {
         $this->assertTrue(true, 'Serialization should throw an execption');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not throw this exception');
     }
     try {
         $object = Xinc_Build::unserialize($project, $buildTimestamp);
     } catch (Xinc_Build_Exception_NotFound $pe) {
         $this->assertTrue(true, 'Serialization should throw an execption');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Unserialization should not throw an execption');
     }
 }