Exemple #1
0
 /**
  * Add a projectfile to the xinc processing.
  *
  * @param string $fileName
  */
 private function addProjectFile($fileName)
 {
     try {
         $config = new Xinc_Project_Config($fileName);
         $engineName = $config->getEngineName();
         $engine = Xinc_Engine_Repository::getInstance()->getEngine($engineName);
         $builds = $engine->parseProjects($config->getProjects());
         self::$_buildQueue->addBuilds($builds);
     } catch (Xinc_Project_Config_Exception_FileNotFound $notFound) {
         Xinc_Logger::getInstance()->error('Project Config File ' . $fileName . ' cannot be found');
     } catch (Xinc_Project_Config_Exception_InvalidEntry $invalid) {
         Xinc_Logger::getInstance()->error('Project Config File has an invalid entry: ' . $invalid->getMessage());
     } catch (Xinc_Engine_Exception_NotFound $engineNotFound) {
         Xinc_Logger::getInstance()->error('Project Config File references an unknown Engine: ' . $engineNotFound->getMessage());
     }
 }
 public function testEngineCannotValidate()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testEngineCannotValidate.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
         $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), 'cannot load engine') !== false, 'We should have a log message about the engine not being able to load');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     try {
         $engine = Xinc_Engine_Repository::getInstance()->getEngine('SunriseCannotValidate');
         $this->assertTrue(false, 'Should throw an exception');
     } catch (Xinc_Engine_Exception_NotFound $e) {
         $this->assertTrue(true, 'Right Exception caught');
     } catch (Exception $pe) {
         $this->assertTrue(false, 'Should catch a NotFound exception but caught: ' . get_class($e));
     }
 }
 public function testEngineRegistered()
 {
     /**
      * reset the engines
      */
     Xinc_Engine_Repository::tearDown();
     $workingdir = getcwd();
     $configFile = Xinc_Config_File::load($workingdir . '/test/resources/testSystem.xml');
     $parser = new Xinc_Config_Parser($configFile);
     $engines = $parser->getEngines();
     $this->assertTrue(count($engines) == 1, 'We should have one engine');
     $engineParser = new Xinc_Engine_Parser();
     try {
         $engineParser->parse($engines);
         $this->assertTrue(true, 'Should not throw an exception');
     } catch (Exception $e) {
         $this->assertTrue(false, 'Should not catch an exception but caught: ' . get_class($e));
     }
     $engines = Xinc_Engine_Repository::getInstance()->getEngines();
     /**
      * Engines are registered by their name and classname
      * therefore we expect 2 engines
      */
     $this->assertEquals($engines->count(), 2, 'There should be a registered engine');
     $engine = Xinc_Engine_Repository::getInstance()->getEngine(Xinc_Engine_Sunrise::NAME);
     $this->assertTrue($engine instanceof Xinc_Engine_Sunrise, 'Engine should be a Xinc_engine_Sunrise');
 }