public function createProject($name, $path) { $project = new Project(); $project->setName($name)->setPath($path); $this['project_list']->add($project); return $project; }
/** * {@inheritdoc} */ public function getRuns(Project $project = null, $offset = 0, $limit = 100) { if (null === $project) { return $this->getRunsByWhere('1 = 1', array(), $offset, $limit); } return $this->getRunsByWhere('R.project_name = :project_name', array('project_name' => $project->getName()), $offset, $limit); }
public function start(Project $project, \Closure $output) { $path = $project->getPath(); do { $tmp = 'bl_' . md5(uniqid() . microtime(true)); $configFile = $path . '/' . $tmp; } while (file_exists($configFile)); $config = $project->getConfig($this->getRun()->getProperties()); file_put_contents($configFile, Yaml::dump($config)); $pb = new ProcessBuilder(array('php', $project->getBehatBin())); $pb->setWorkingDirectory($project->getPath()); $pb->add('-c')->add($configFile); $feature = $project->getFeaturesPath() . '/' . $this->feature; $pb->add($feature); $pb->setTimeout(null); $argFormats = array(); $argOutputs = array(); foreach ($project->getFormats() as $format) { $argFormats[] = $format; $argOutputs[] = $this->outputFiles->get($format)->getPath(); } $pb->add('-f')->add(implode(',', $argFormats)); $pb->add('--out')->add(implode(',', $argOutputs)); $pb->add('--ansi'); $this->process = $pb->getProcess(); $this->onFinish = function () use($configFile) { unlink($configFile); $this->returnCode = $this->process->getExitCode(); if (null === $this->returnCode) { $this->returnCode = 255; } $this->finishedAt = new \DateTime(); }; $this->process->start(function ($type, $text) use($output) { $output($text, $type != 'out'); $this->outputFiles->append($type == 'out' ? '_stdout' : '_stderr', $text); }); }