/** * Executes the current command. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|integer null or 0 if everything went fine, or an error code */ protected function execute(InputInterface $input, OutputInterface $output) { try { $oConfig = new \Testy\Config($input->getOption('config')); $oConfig->validate(); $bFirstRun = true; $oWatch = new \Testy\Watch(); while (true) { $oRawConfig = $oConfig->get(); if ($bFirstRun === true or $oConfig->wasUpdated() === true) { $aNotifiers = array(); foreach ($oRawConfig->setup->notifiers as $sNotifier => $oNotifierConfig) { if (isset($oNotifierConfig->enabled) === true and $oNotifierConfig->enabled == true) { $aNotifiers[$sNotifier] = \notifyy\Builder::build($sNotifier, $oNotifierConfig); } } foreach ($oRawConfig->projects as $sProject => $oProjectConfig) { $oWatch->add(\Testy\Project\Builder::build($sProject, $oProjectConfig, $aNotifiers)); } } $oWatch->loop($oRawConfig->setup->parallel, $oRawConfig->setup->sleep); sleep($oRawConfig->setup->sleep); $bFirstRun = false; } } catch (\Testy\Exception $e) { $output->writeln($e->getMessage()); return 1; } return null; }
/** * Test failure */ public function testBuildFailed() { $oConfig = new \stdClass(); try { \Testy\Project\Builder::build(self::PROJECT_NAME, $oConfig, array()); $this->fail('an exception should have been thrown, if no test-command ist configured'); } catch (\Exception $e) { $this->assertStringEndsWith(self::PROJECT_NAME, $e->getMessage()); } }